Demo for talk on how Behaviour Driven Development (BDD) can be used to test multiple contexts for modern websites separated into single page applications and REST APIs
This demonstrates how you can spin up a front-end and back-end container (which in reality would live in separate repositories) and run behavioural tests against one and both independently
For this demo to work you'll need Docker installed
docker swarm init
docker stack deploy -c docker-compose.yml bddtalk
You should see the following output if this works successfully
Creating network bddtalk_default
Creating service bddtalk_testrunner
Creating service bddtalk_frontend
Creating service bddtalk_backend
Because the behavioural tests rely on internal DNS within the Docker Swarm, you will need a local hosts file entry to point the Angular application at the REST API
127.0.0.1 backend
The container running the single page JavaScript application should be available locally on port 8888 (which is forwarded to port 80 in the container)
The container running the REST API should display Swagger Open API documentation locally on port 9999
There are scripts to run the tests within their respective containers. If these are non-executable you'll need to allow them to be run
chmod +x bdd-tests.sh
There is a shortcut script provided which will determine which container is the test runner then run the Behat tests on it
./bdd-tests.sh
cd backend && bin/phpspec run && cd -
cd backend && bin/phpunit --coverage-php data/coverage/phpunit_coverage.cov && cd -