Skip to content

Commit c5ce78e

Browse files
committed
Completed README to explain how to run the test locally and on Codeship
1 parent 840a28c commit c5ce78e

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

README.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,52 @@
1-
codeship
2-
========
1+
# Testing Codeship.io
32

4-
Testing Codeship with Selenium and PHP
3+
This short repository contains an example of a WebDriver test that runs in a running instance of Chrome on Codeship.io.
54

6-
https://www.codeship.io/projects/71d754e0-b63b-0130-ee60-52e2877ac259/status
5+
The test is in the `test` folder.
6+
7+
8+
## How to run the test locally
9+
10+
To run the test locally:
11+
12+
1. Clone the repo in some local folder: `git clone https://github.com/tidoust/codeship.git`
13+
2. Install Composer if needed: `curl -sS https://getcomposer.org/installer | php`
14+
3. Install PHP dependencies: `composer install`
15+
4. Download ChromeDriver `http://chromedriver.storage.googleapis.com/index.html?path=2.9/`
16+
5. Run ChromeDriver in the background, the server should start listening on port 9515
17+
6. Run the test: `vendor/bin/phpunit`
18+
19+
This should open up a Chrome instance that will load GitHub's home page and assert that the title is the right one.
20+
21+
22+
## How to run the test on Codeship
23+
24+
Create a new project associated with your cloned repository.
25+
26+
In *Modify your Setup commands*, enter:
27+
28+
```bash
29+
# Set php version through phpenv. 5.3, 5.4 and 5.5 available
30+
phpenv local 5.4
31+
32+
# Install dependencies through Composer
33+
composer install --prefer-source --no-interaction
34+
35+
# Run ChromeDriver
36+
nohup bash -c "chromedriver 2>&1 &" && sleep 4; cat nohup.out
37+
```
38+
39+
In *Modify yout Test commands*, enter:
40+
41+
```bash
42+
vendor/bin/phpunit
43+
```
44+
45+
That's it, Codeship will run the test accordingly.
46+
47+
48+
## Additional notes
49+
50+
- If you prefer to plan another Web browser, you'll have to download and start the standalone WebDriver server instead
51+
- It would be wise not to hardcode the URL of the ChromeDriver server in each and every test and use a constant instead
52+
- Similarly, it might be better to keep the `webDriver` variable around instead of launching Chrome for each and every test

0 commit comments

Comments
 (0)