LinuxCommandLibrary

behat

TLDR

Initialize a new Behat project

$ behat --init
copy
Run all feature tests
$ behat
copy
Run tests for a specific feature file
$ behat [features/login.feature]
copy
Run a specific scenario by line number
$ behat [features/login.feature:15]
copy
Run tests with a specific tag
$ behat --tags [smoke]
copy
Generate step definitions for undefined steps
$ behat --snippets-for --append-snippets
copy
Run tests with verbose output
$ behat -v
copy
Output results in JUnit format
$ behat --format junit --out [reports/]
copy

SYNOPSIS

behat [options] [featurefile_]

DESCRIPTION

behat is a BDD (Behavior-Driven Development) framework for PHP that tests business expectations using human-readable scenarios. It is the PHP implementation of Cucumber, using Gherkin syntax to define test scenarios.
Behat allows teams to describe application behavior in plain language that developers, QA, and stakeholders can all understand. Scenarios are written in feature files and executed against step definitions implemented in PHP.

PARAMETERS

--init

Initialize a new Behat project with the necessary directory structure
--tags value
Run only scenarios with matching tags (e.g., @smoke, @regression)
-f, --format value
Output format: pretty, progress, html, junit, json
--out value
Write output to a file or directory
--snippets-for value
Generate step definition snippets for undefined steps
--append-snippets
Append generated snippets to context files
-v, --verbose
Increase verbosity of output
--colors / --no-colors
Force colored or non-colored output
--suite value
Run only the specified test suite
--profile value
Use a specific configuration profile

CAVEATS

Behat requires PHP 5.3.1 or higher. Feature files must use Gherkin syntax with proper indentation. Step definitions must be unique; duplicate definitions cause ambiguity errors. The default context file is FeatureContext.php in features/bootstrap/.

HISTORY

Behat was created by Konstantin Kudryashov (everzet) in 2010 as the PHP port of Cucumber. It became the de facto BDD testing framework for PHP, widely adopted in the Symfony and Drupal communities for acceptance testing.

SEE ALSO

phpunit(1), phpspec(1), cucumber(1)

Copied to clipboard