Linux command
behat 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Initialize a new Behat project
behat --init
Run all feature tests
behat
Run tests for a specific feature file
behat [features/login.feature]
Run a specific scenario
behat [features/login.feature:15]
Run tests with a specific tag
behat --tags [smoke]
Generate step definitions
behat --snippets-for --append-snippets
Run tests with verbose output
behat -v
Output results in JUnit format
behat --format junit --out [reports/]
说明
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.
参数
- --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
FAQ
What is the behat command used for?
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.
How do I run a basic behat example?
Run `behat --init` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --init do in behat?
Initialize a new Behat project with the necessary directory structure