Command for single-setup of behat tests

This commit is contained in:
Damian Mooyman 2018-03-16 11:42:37 +13:00
parent 42efff5eac
commit 3cf7db107b
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
3 changed files with 39 additions and 0 deletions

View File

@ -102,6 +102,22 @@ This will start a Firefox browser by default. Other browsers and profiles can be
For example, if you want to start a Chrome Browser you can following the instructions provided [here](docs/chrome-behat.md).
### Running with stand-alone command
If running with `silverstripe/serve` and `chromedriver`, you can also use the following command
which will automatically start and stop these services for individual tests.
vendor/bin/behat-ss @framework
This automates:
- starting server
- starting chromedriver
- running behat
- shutting down chromedriver
- shutting down server
Make sure you set `SS_BASE_URL` to `http://localhost:8080` in `.env`
## Tutorials
* [Tutorial: Testing Form Submissions](docs/tutorial.md)

20
bin/behat-ss Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
echo "setting up /artifacts"
mkdir -p artifacts
echo "starting chromedriver"
chromedriver &> artifacts/chromedriver.log 2> artifacts/chromedriver-error.log &
cd_pid=$!
echo "starting webserver"
vendor/bin/serve &> artifacts/serve.log 2> artifacts/serve-error.log &
ws_pid=$!
echo "starting behat"
vendor/bin/behat "$@"
echo "killing webserver (PID: $ws_pid)"
pkill -TERM -P $ws_pid &> /dev/null
echo "killing chromedriver (PID: $cd_pid)"
kill -9 $cd_pid &> /dev/null

View File

@ -47,6 +47,9 @@
"3.x-dev": "3.1.x-dev"
}
},
"bin": [
"bin/behat-ss"
],
"scripts": {
"lint": "phpcs --standard=PSR2 -n src/ tests/php/"
},