Quick Start¶
This guide walks through the most common behave-gen workflows.
1. Create a project¶
This creates:
my-project/
features/
sample.feature Placeholder feature (replace or remove)
steps/
.gitkeep
environment.py Behave hooks (before/after scenario)
behave.toml Behave configuration
pyproject.toml Project metadata + [tool.behave-gen] config
README.md
Verify the project runs:
2. Add a feature¶
Creates features/login.feature:
@smoke @auth
Feature: Login
Description for Login.
Scenario: Login scenario
Given a precondition for Login
When an action is performed
Then the result is observed
Use the CRUD template for scenario outlines:
See Feature Templates for details.
3. Add step definitions¶
This copies real, runnable step libraries into features/steps/:
http_steps.py— HTTP requests withurllib(no extra dependencies).auth_steps.py— Session and authentication state management.
See Step Libraries for the full list of available steps.
4. Write features that use the step libraries¶
The placeholder templates use generic step text. Replace them with steps that match the libraries you added:
@smoke @auth
Feature: Login
Scenario: Successful login
Given the base URL is "http://localhost:8080"
And I am not authenticated
When I send a POST request to "/auth/login" with body
"""
{"username": "admin", "password": "secret"}
"""
Then the response status should be 200
And the response JSON should contain "token"
5. Check project health¶
Runs behave-doctor diagnostics and reports undefined steps, unused definitions, and other issues.
6. Run tests¶
7. Generate from an OpenAPI spec¶
Produces .feature files grouped by path, each with scenarios that use the
HTTP step library. See Generators.
8. Migrate from Cucumber¶
Copies .feature files into a Behave layout. See
Cucumber Migration.
9. Report statistics¶
10. Preview a feature¶
Pretty-prints the feature with resolved examples and tables.