How Behat is used in Acquia Projects?

Behat is used in BLT for functional testing. All tests in BLT are contained in test/behat directory at root level.

tests ├── behat - contains all Behat tests │ ├── features │ │ ├── bootstrap │ │ └── Example.feature │ ├── behat.yml - contains behat configuration common to all behat profiles. │ └── integration.yml - contains behat configuration for the integration profile, which is used to run tests on the integration environment. ├── jmeter - contains all jMeter tests └── phpunit - contains all PHPUnit tests

BLT and Behat

To run behat tests using BLT

  • To execute all behat test in the project blt tests:behat

  • To execute a single featureblt tests:behat -Dbehat.paths=${PWD}/tests/behat/features/Examples.feature

  • To execute a single scenario i.e 4th Scenario (with Phing):blt tests:behat -Dbehat.paths=${PWD}/tests/behat/features/Examples.feature:4

  • To execute a single scenario i.e 4th Scenario (with Phing) for local profile:./vendor/bin/behat -c tests/behat/local.yml tests/behat/features/Examples.feature -p local

For more details on Testing in BLT https://github.com/acquia/blt/blob/8.x/readme/testing.md

Behat in Lightning

Behat in Lighting

Lightning also defines 6 Context which extends DrupalSubContextBase Some of the subcontext defined by behat are:

  • CkEditorSubContext

  • EntitySubContext

  • LightningSubContext

  • MediaLibrarySubContext

  • PanelsSubContext

  • PreviewSubContext

Behat in Lighting Example Example of a scenario of behat in Lightning

@api @lightning Feature: Lightning Content Types Makes sure that the article content type was created during installation. Scenario: Make sure that the content types provided by Lightning at installation are present. Given I am logged in as a user with the administrator role When I visit "/node/add" Then I should see "Basic page" And I should see "Landing Page"

Behat extension comes with scenarios by default

run the following command

to ouput

Last updated

Was this helpful?