HOME

TheInfoList



OR:

Behat is a test framework for
behavior-driven development Behavior-driven development (BDD) involves naming software tests using domain language to describe the behavior of the code. BDD involves use of a domain-specific language (DSL) using natural-language constructs (e.g., English-like sentences) ...
written in the PHP programming language. Behat was created by Konstantin Kudryashov and its development is hosted on
GitHub GitHub () is a Proprietary software, proprietary developer platform that allows developers to create, store, manage, and share their code. It uses Git to provide distributed version control and GitHub itself provides access control, bug trackin ...
.


Purpose

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 A pickled cucumber – commonly known as a pickle in the United States, Canada and Australia and a gherkin ( ) in Britain, Ireland, South Africa, and New Zealand – is a usually small or miniature cucumber that has been pickled in a brine, ...
, a business-readable domain-specific language following defined patterns.


Benefits

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 Selenium is a chemical element; it has symbol (chemistry), symbol Se and atomic number 34. It has various physical appearances, including a brick-red powder, a vitreous black solid, and a grey metallic-looking form. It seldom occurs in this elem ...
to remote control browsers as part of the scenarios. The browsers under remote control can take videos or screenshots of failures. Using selenium or tools like selenoid a "grid" of browsers can be remote controlled for parallel test execution. There is also a module for running php only scenarios. 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 An annotation is extra information associated with a particular point in a document or other piece of information. It can be a note that includes a comment or explanation. Annotations are sometimes presented in the margin of book pages. For anno ...
of a class that extends the BehatContext. Behat can output test results in a number of different formats, including
JUnit JUnit is a test automation framework for the Java programming language. JUnit is often used for unit testing, and is one of the xUnit frameworks. JUnit is linked as a JAR at compile-time. The latest version of the framework, JUnit 5, resides ...
XML and HTML


Examples

The preconditions after "Given" correspond to the PHP method name to execute: Feature: Simple description of this feature’s story Describe benefit, role and feature or user story Use as many lines as needed Background: Given some step run for all scenarios Scenario: Scenario or example description Given I setup preconditions with: , data column 1 , data column 2 , , alice , bob , When I press the "blue" button Then the result is: """ A multiple line string of data """ #comments can be added as needed Scenario Outline: Scenario or example description Given I setup config with "" When I push button "