Behat is intended to aid communication between developers, clients and other stakeholders during a software development process. It allows the clear documentation of testable examples of the software's intended behaviour. Behat test scenarios are written with Gherkin,1 a business-readable domain-specific language following defined patterns.
Tests can be run at any point new code is introduced into a codebase to confirm no regressions within the existing test coverage are introduced. It can be used to directly test php code and is often used with Selenium to remote control browsers as part of the scenarios. The browsers under remote control can take videos2 or screenshots of failures. Using selenium or tools like selenoid3 a "grid" of browsers can be remote controlled for parallel test execution. There is also a module for running php only scenarios.4
Like other BDD frameworks, Behat scenarios are a series of Given, When, and Then steps that explain a business case. The definition of these steps exist within method annotations of a class that extends the BehatContext.5
Behat can output test results in a number of different formats, including JUnit XML and HTML6
The preconditions after "Given" correspond to the PHP method name to execute:
"Cucumber Common Components". GitHub. 14 November 2021. https://github.com/cucumber/cucumber/wiki/Gherkin ↩
community, Alexander Andryashin, Ivan Krutov, Kirill Merkushev and the Aerokube. "Aerokube Selenoid | A cross browser Selenium solution for Docker". aerokube.com. Retrieved 2024-02-19.{{cite web}}: CS1 maint: multiple names: authors list (link) https://aerokube.com/selenoid/latest ↩
aerokube/selenoid, Aerokube, 2024-02-17, retrieved 2024-02-19 https://github.com/aerokube/selenoid ↩
Marynicz, Daniel (2023-11-17), Daniel-Marynicz/BehatParallelExtension, retrieved 2024-02-19 https://github.com/Daniel-Marynicz/BehatParallelExtension ↩
BDD With Behat - Tuts+ Code Tutorial. Code.tutsplus.com (2013-12-23). Retrieved on 2015-03-19. http://code.tutsplus.com/tutorials/bdd-with-behat--net-36171 ↩
Vanmeert, Neal (2024-01-24), dutchiexl/BehatHtmlFormatterPlugin, retrieved 2024-02-19 https://github.com/dutchiexl/BehatHtmlFormatterPlugin ↩