CLI Reference¶
All commands share these global options:
| Option | Description |
|---|---|
--project PATH |
Project root directory (default: current working directory). |
--config PATH |
Path to an explicit pyproject.toml config file. |
init¶
Create a new Behave project from a template.
Arguments:
| Argument | Description |
|---|---|
NAME |
New project directory name. |
Options:
| Option | Default | Description |
|---|---|---|
--template |
default |
Template set to use. |
--template-engine |
string |
Template engine: string or jinja2. |
--kit |
false |
Pre-wire behave-kit in environment.py. |
--data |
false |
Pre-wire behave-data hooks. |
--force |
false |
Overwrite an existing directory. |
Example:
add feature¶
Add a .feature file to the project.
Arguments:
| Argument | Description |
|---|---|
NAME |
Feature name (without extension). |
Options:
| Option | Default | Description |
|---|---|---|
--tags |
none | Comma or space separated tags. |
--template |
default |
Feature template: default or crud. |
Example:
See Feature Templates.
add steps¶
Add real step definitions from a step library.
Options:
| Option | Default | Description |
|---|---|---|
--lib |
required | Step library name: http or auth. |
Example:
See Step Libraries.
add environment¶
Add or update environment.py with ecosystem hooks.
Options:
| Option | Default | Description |
|---|---|---|
--kit |
false |
Add behave-kit fixtures. |
--data |
false |
Add behave-data hooks. |
Example:
add config¶
Add an ecosystem package to pyproject.toml.
Arguments:
| Argument | Description |
|---|---|
NAME |
Config to add: behave-kit or behave-data. |
Example:
from-openapi¶
Generate features and steps from an OpenAPI 3.x spec.
Arguments:
| Argument | Description |
|---|---|
SPEC |
Path to an OpenAPI 3.x spec (YAML or JSON). |
Options:
| Option | Default | Description |
|---|---|---|
--out-dir |
gen |
Output directory for the generated project (creates a features/ subdir). |
--step-lib |
none | Step library to bind (e.g. http). |
--tag |
none | Tag generated scenarios. |
--include-path |
all | Restrict to these paths (repeatable). |
--include-method |
all | Restrict to these HTTP methods (repeatable). |
Example:
behave-gen from-openapi spec.yaml --out-dir gen --step-lib http --tag api
behave-gen from-openapi spec.yaml --include-path /pets --include-method GET
See Generators.
from-postman¶
Generate features and steps from a Postman collection.
Arguments:
| Argument | Description |
|---|---|
COLLECTION |
Path to a Postman Collection v2.1 JSON file. |
Options:
| Option | Default | Description |
|---|---|---|
--out-dir |
gen |
Output directory for the generated project (creates a features/ subdir). |
--step-lib |
none | Step library to bind (e.g. http). |
--tag |
none | Tag generated scenarios. |
Example:
See Generators.
from-swagger¶
Generate features and steps from a Swagger 2.0 spec.
Arguments:
| Argument | Description |
|---|---|
SPEC |
Path to a Swagger 2.0 spec (JSON). |
Options:
| Option | Default | Description |
|---|---|---|
--out-dir |
gen |
Output directory for the generated project (creates a features/ subdir). |
--step-lib |
none | Step library to bind (e.g. http). |
--tag |
none | Tag generated scenarios. |
Example:
See Generators.
migrate¶
Migrate a Cucumber project to Behave.
Arguments:
| Argument | Description |
|---|---|
SOURCE_DIR |
Cucumber project to migrate. |
Options:
| Option | Default | Description |
|---|---|---|
--out-dir |
migrated |
Output directory for the migrated project (creates a features/ subdir). |
Example:
See Cucumber Migration.
check¶
Check project health via behave-doctor.
Options:
| Option | Default | Description |
|---|---|---|
--format |
text |
Output format: text or json. |
Example:
doctor¶
Alias for check.
lint¶
Lint .feature files via behave-lint.
Options:
| Option | Default | Description |
|---|---|---|
--fix |
false |
Apply fixes where possible. |
--path |
features dir | Path to lint (repeatable); defaults to the features directory. |
Example:
format¶
Format .feature files via behave-format.
Options:
| Option | Default | Description |
|---|---|---|
--check |
false |
Check formatting without writing. |
--path |
features dir | Path to format (repeatable); defaults to the features directory. |
Example:
preview¶
Preview a feature file with resolved examples and tables.
Arguments:
| Argument | Description |
|---|---|
FEATURE |
Path to a .feature file. |
Example:
stats¶
Report project statistics.
Options:
| Option | Default | Description |
|---|---|---|
--format |
text |
Output format: text or json. |
Example:
update¶
Re-apply generated environment and step libraries to an existing project.
Options:
| Option | Default | Description |
|---|---|---|
--kit |
false |
Include behave-kit wiring in environment.py. |
--data |
false |
Include behave-data wiring in environment.py. |
--force |
false |
Regenerate files even if they were user-modified. |
Example:
Files generated by behave-gen (marked with Generated by behave-gen) are
refreshed. User-modified files without the marker are skipped unless --force
is used.