# How Behat is used in Acquia Projects?

Behat is used in BLT for functional testin&#x67;**.** 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<br>

### BLT and Behat&#x20;

To run behat tests using BLT

* &#x20;To execute all behat test in the project\
  `blt tests:behat`
* To execute a single feature`blt 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&#x20;

![](/files/-LZlKSdTa08Z-5XGaKsV)

### Behat in Lighting&#x20;

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

* CkEditorSubContext
* EntitySubContext
* LightningSubContext
* MediaLibrarySubContext
* PanelsSubContext
* PreviewSubContext<br>

Behat in Lighting Example\
Example of a scenario of behat in Lightning<br>

`@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.`\
&#x20;`Given I am logged in as a user with the administrator role`\
&#x20;`When I visit "/node/add"`\
&#x20;`Then I should see "Basic page"`\
&#x20;`And I should see "Landing Page"`<br>

### Behat extension comes with scenarios by default

run the following command&#x20;

```
./vendor/bin/behat -dl -c tests/behat/local.yml -p local
```

to ouput&#x20;

```bash
root@c2963444466f:/var/www# ./vendor/bin/behat -dl -c tests/behat/local.yml -p local
default | Given I am an anonymous user
default | Given I am not logged in
default | Given I am logged in as a user with the :role role(s)
default | Given I am logged in as a/an :role
default | Given I am logged in as a user with the :role role(s) and I have the following fields:
default | Given I am logged in as :name
default | Given I am logged in as a user with the :permissions permission(s)
default | Then I should see (the text ):text in the :rowText row
default | Then I should not see (the text ):text in the :rowText row
default | Given I click :link in the :rowText row
default | Then I (should )see the :link in the :rowText row
default | Given the cache has been cleared
default | Given I run cron
default | Given I am viewing a/an :type (content )with the title :title
default | Given a/an :type (content )with the title :title
default | Given I am viewing my :type (content )with the title :title
default | Given :type content:
default | Given I am viewing a/an :type( content):
default | Then I should be able to edit a/an :type( content)
default | Given I am viewing a/an :vocabulary term with the name :name
default | Given a/an :vocabulary term with the name :name
default | Given users:
default | Given :vocabulary terms:
default | Given the/these (following )languages are available:
default | Then (I )break
default | Given I am at :path
default | When I visit :path
default | When I click :link
default | Given for :field I enter :value
default | Given I enter :value for :field
default | Given I wait for AJAX to finish
default | When /^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/
default | When I press the :button button
default | Given I press the :char key in the :field field
default | Then I should see the link :link
default | Then I should not see the link :link
default | Then I should not visibly see the link :link
default | Then I (should )see the heading :heading
default | Then I (should )not see the heading :heading
default | Then I (should ) see the button :button
default | Then I (should ) see the :button button
default | Then I should not see the button :button
default | Then I should not see the :button button
default | When I follow/click :link in the :region( region)
default | Given I press :button in the :region( region)
default | Given I fill in :value for :field in the :region( region)
default | Given I fill in :field with :value in the :region( region)
default | Then I should see the heading :heading in the :region( region)
default | Then I should see the :heading heading in the :region( region)
default | Then I should see the link :link in the :region( region)
default | Then I should not see the link :link in the :region( region)
default | Then I should see( the text) :text in the :region( region)
default | Then I should not see( the text) :text in the :region( region)
default | Then I (should )see the text :text
default | Then I should not see the text :text
default | Then I should get a :code HTTP response
default | Then I should not get a :code HTTP response
default | Given I check the box :checkbox
default | Given I uncheck the box :checkbox
default | When I select the radio button :label with the id :id
default | When I select the radio button :label
default | Given /^(?:|I )am on (?:|the )homepage$/
default | When /^(?:|I )go to (?:|the )homepage$/
default | Given /^(?:|I )am on "(?P<page>[^"]+)"$/
default | When /^(?:|I )go to "(?P<page>[^"]+)"$/
default | When /^(?:|I )reload the page$/
default | When /^(?:|I )move backward one page$/
default | When /^(?:|I )move forward one page$/
default | When /^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/
default | When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/
default | When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with:$/
default | When /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/
default | When /^(?:|I )fill in the following:$/
default | When /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
default | When /^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
default | When /^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/
default | When /^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/
default | When /^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/
default | Then /^(?:|I )should be on "(?P<page>[^"]+)"$/
default | Then /^(?:|I )should be on (?:|the )homepage$/
default | Then /^the (?i)url(?-i) should match (?P<pattern>"(?:[^"]|\\")*")$/
default | Then /^the response status code should be (?P<code>\d+)$/
default | Then /^the response status code should not be (?P<code>\d+)$/
default | Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/
default | Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/
default | Then /^(?:|I )should see text matching (?P<pattern>"(?:[^"]|\\")*")$/
default | Then /^(?:|I )should not see text matching (?P<pattern>"(?:[^"]|\\")*")$/
default | Then /^the response should contain "(?P<text>(?:[^"]|\\")*)"$/
default | Then /^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/
default | Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
default | Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
default | Then /^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/
default | Then /^the "(?P<element>[^"]*)" element should not contain "(?P<value>(?:[^"]|\\")*)"$/
default | Then /^(?:|I )should see an? "(?P<element>[^"]*)" element$/
default | Then /^(?:|I )should not see an? "(?P<element>[^"]*)" element$/
default | Then /^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/
default | Then /^the "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/
default | Then /^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/
default | Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/
default | Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox is checked$/
default | Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" (?:is|should be) checked$/
default | Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should (?:be unchecked|not be checked)$/
default | Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox is (?:unchecked|not checked)$/
default | Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" should (?:be unchecked|not be checked)$/
default | Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" is (?:unchecked|not checked)$/
default | Then /^print current URL$/
default | Then /^print last response$/
default | Then /^show last response$/
default | Then I should see the error message( containing) :message
default | Then I should see the following error message(s):
default | Given I should not see the error message( containing) :message
default | Then I should not see the following error messages:
default | Then I should see the success message( containing) :message
default | Then I should see the following success messages:
default | Given I should not see the success message( containing) :message
default | Then I should not see the following success messages:
default | Then I should see the warning message( containing) :message
default | Then I should see the following warning messages:
default | Given I should not see the warning message( containing) :message
default | Then I should not see the following warning messages:
default | Then I should see the message( containing) :message
default | Then I should not see the message( containing) :message
default | Given I run drush :command
default | Given I run drush :command :arguments
default | Then drush output should contain :output
default | Then drush output should match :regex
default | Then drush output should not contain :output
default | Then print last drush output
default | Given I set the configuration item :name with key :key to :value
default | Given I set the configuration item :name with key :key with values:
```

###


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://allierays.gitbook.io/drupal-project-resources/development-resources/behat/how-behat-is-used-in-acquia-projects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
