lakedrops / behat4drupal
Composer Plugin to prepare Drupal project for Behat tests.
Requires
- php: >=8.1
- composer-plugin-api: ^2
- behat/behat: ^3.12
- behat/mink: ^1.10
- behat/mink-browserkit-driver: ^2.2
- behat/mink-selenium2-driver: ^1.6
- drupal/drupal-extension: ^3.4||^4.1||^5.0
- drush-ops/behat-drush-endpoint: ^9.4
- lakedrops/composer-json-utils: ^2.5||dev-develop
- lakedrops/docker4drupal: ^3.10||dev-develop
Requires (Dev)
- composer/composer: ^2
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-10-24 09:13:01 UTC
README
This composer plugin prepares your Drupal project for Behat tests.
Requirements
The plugin works with any composer based Drupal project and can be added to such projects with composer require lakedrops/behat4drupal
. It's recommended to also use the Docker4Drupal plugin (added with composer require lakedrops/docker4drupal
) which will provide all the Docker containers for your development environment as well as those for Selenium and Chrome.
If your project is based on either Drupal 8 Project Template or Drupal 9 Project Template, then everything is already included for you automatically.
Usage
You will find links to further documentation on how to write Behat tests at the end of this file. Here we simply describe on how you can run your tests once they have been defined.
Command line
The easiest way to run Behat tests is to use the prepared Ahoy commands. Just call a behat
to get a list of all available commands. In the background, they call the same commands that are described in detail in the following paragraphs.
You need to execute Behat inside of the PHP Docker container. From the root of your project you can launch the containers with docker-compose up -d
and then enter the PHP container with docker-compose exec --user root php sh
.
Inside of the container you'll be located at /var/www/html
and in that directory you can run the Behat test suite with the command vendor/bin/behat --no-interaction --config /var/www/html/tests/behat/behat.yml
PhpStorm
In any of the JetBrains IDEs you can call the Behat tests directly from the UI when preparing the project in 2 steps beforehand:
- Configure the PHP CLI interpreter: Go to the project settings in Languages & Frameworks > PHP and configure the remote PHP interpreter for Docker similar to this screenshot
- Configure the Run/Debug Configuration: Simply select Behat and of you go, see this second screenshot
Links
For more details we recommend the following links:
- Behat Documentation
- Others