Skip to content

Commit dc09894

Browse files
committed
Added initial support for Behat out of the box
1 parent 329a486 commit dc09894

12 files changed

Lines changed: 822 additions & 2 deletions

File tree

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,17 @@ code-fix: # Fix minor errors using Drupal standards
231231
-$(CURDIR)/bin/tool phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info /var/www/webroot/modules/custom
232232
-$(CURDIR)/bin/tool phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,info /var/www/webroot/themes/custom
233233

234+
behat-start:
235+
docker-compose -f tests/behat/docker-compose.yml up -d
236+
237+
behat-run:
238+
-./bin/behat
239+
240+
behat-stop:
241+
docker-compose -f tests/behat/docker-compose.yml down -v
242+
243+
behat: behat-start behat-run behat-stop
244+
234245
##
235246
# Removes "No rule to make target" message which allows us to pass an argument
236247
# without having to specify the name when running the make command.

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,32 @@ currently being done in the environment.
398398
When possible, update during a state of clean development. Between the two
399399
commands, `make update` should be used _much_ more often.
400400

401+
### Running Behat Tests
402+
403+
Some tests require the use of a browser, real or headless. This environment
404+
has Behat installed as a dependency and runs Selenium with drivers for Chrome
405+
and Firefox preconfigured. These browsers are run in a self-contained docker
406+
environment.
407+
408+
Feature yaml files can be placed in tests/behat/features. These features can
409+
be run with `make behat`. By default, the Firefox browser is used. If Chrome
410+
is preferred, call the handler script with the option: `bin/behat -p chrome`.
411+
412+
For debugging purposes, the processes around bring the testing environment up,
413+
running the tests, and finally bringing the environment down are isolated into
414+
separate make targets:
415+
416+
* `make behat-start`
417+
* `make behat-run`
418+
* `make behat-stop`
419+
420+
While the environment is running, it can be accessed via a VNC connection:
421+
422+
* [Firefox (localhost:5900)](vnc://localhost:5900)
423+
* [Chrome (localhost:5901)](vnc://localhost:5901)
424+
425+
The password to the VNC environment is "secret".
426+
401427
### Problems With Permissions
402428

403429
The environment runs in two different fashions concurrently: locally and in

bin/behat

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
readonly PROGDIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd)"
4+
readonly PROJECT="$(basename "$(dirname "$PROGDIR")" | tr '[:upper:]' '[:lower:]')"
5+
6+
PARAMS=""
7+
8+
for PARAM in "$@"
9+
do
10+
PARAMS="${PARAMS} \"${PARAM}\""
11+
done
12+
docker exec -it ${PROJECT}-php sh -c "cd /var/www/tests/behat && ../../vendor/bin/behat --config /var/www/tests/behat/behat.yml ${PARAMS}"

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
},
3030
"require-dev": {
3131
"webflo/drupal-core-require-dev": "^8.7.0",
32+
"behat/behat": "^3.5.0",
33+
"emuse/behat-html-formatter": "^0.1.0",
34+
"bex/behat-screenshot": "^1.2",
35+
"drupal/drupal-extension": "~3.2",
36+
"jarnaiz/behat-junit-formatter": "^1.3.2",
3237
"drupal/devel": "^1.0",
3338
"jakub-onderka/php-parallel-lint": "^0.9.2",
3439
"jakub-onderka/php-console-highlighter": "^0.3.2"

0 commit comments

Comments
 (0)