CLI toolkit for scaffolding and evolving Behave BDD projects.
Project description
behave-gen
A CLI toolkit for scaffolding and evolving Behave BDD projects.
behave-gen helps you create, extend, and maintain Behave (Python BDD)
projects. It scaffolds new projects, generates .feature files and concrete
step definitions, integrates ecosystem tools (behave-doctor, behave-lint,
behave-format), and migrates Cucumber projects to Behave.
Features
| Command | Description |
|---|---|
init |
Scaffold a new Behave project with sensible defaults. |
add feature |
Generate .feature files from templates (default, CRUD). |
add steps |
Add real, runnable step libraries (HTTP, auth). No empty skeletons. |
add environment |
Rewrite environment.py with behave-kit/behave-data wiring. |
add config |
Add ecosystem packages to pyproject.toml idempotently. |
check |
Run behave-doctor diagnostics with actionable suggestions. |
doctor |
Alias for check. |
lint |
Lint .feature files via behave-lint. |
format |
Format .feature files via behave-format. |
from-openapi |
Generate features and HTTP steps from an OpenAPI 3.x spec. |
from-postman |
Generate features from a Postman Collection v2.1. |
from-swagger |
Convert Swagger 2.0 to OpenAPI 3.x and generate features. |
migrate |
Migrate a Cucumber (Java) project to Behave. |
preview |
Pretty-print a .feature file. |
stats |
Report project statistics (features, scenarios, steps, tags). |
update |
Re-apply generated environment and step libraries. |
Installation
pip install behave-gen
Requirements
- Python 3.11 or newer.
- A working
pip/venvenvironment.
Optional extras extend functionality as shown below.
With optional extras:
pip install behave-gen[doctor,lint,format,openapi]
pip install behave-gen[all]
| Extra | Provides |
|---|---|
doctor |
behave-doctor — static analysis for check/doctor. |
lint |
behave-lint — Gherkin linting for lint. |
format |
behave-format — Gherkin formatting for format. |
openapi |
pyyaml — YAML parsing for from-openapi/from-swagger. |
jinja2 |
jinja2 — alternative template engine. |
kit |
behave-kit — environment hooks. |
data |
behave-data — test data fixtures. |
all |
All of the above. |
Quick start
# Create a new Behave project
behave-gen init my-project
cd my-project
# Add a feature file
behave-gen add feature login
# Add HTTP step definitions
behave-gen add steps --lib http
# Check project health
behave-gen check
# Run tests
behave
Generating from an OpenAPI spec
behave-gen from-openapi spec.yaml --out-dir gen --step-lib http --tag api
This produces .feature files grouped by path, each with scenarios that use
the HTTP step library syntax. The --step-lib http flag also generates a
concrete, runnable http_steps.py module.
Migrating from Cucumber
behave-gen migrate path/to/cucumber-project --out-dir migrated
Feature files are copied into a Behave features/ layout. Java step
definitions are not auto-translated; use behave-gen add steps to generate
Python equivalents.
Examples
The examples/ directory contains ready-to-run projects that
demonstrate each workflow:
basic-project—init+add feature+add stepswith HTTP and auth step libraries.openapi-project—from-openapigenerating features and HTTP steps from a Petstore OpenAPI 3.0 spec.migrated-project—migrateconverting a Cucumber (Java) project to Behave feature files.
See examples/README.md for details.
Architecture
behave_gen/
cli/ Typer CLI application
commands/ One module per CLI command
generators/ Pluggable code generators (OpenAPI, Postman)
plugins/ Source-specific parsers and builders
step_libraries/ Built-in step library templates (HTTP, auth)
templates/ Project and feature templates
diagnostics.py Optional-dependency handling
Supply chain & trust
- Trusted Publishing (OIDC) — releases to PyPI use Trusted Publishing via GitHub Actions OIDC. No long-lived API tokens are stored in secrets.
- Pinned actions — all GitHub Actions are pinned to specific versions
(e.g.
@v4,@v1.12.4). - Minimal dependencies — only
behave,behave-model, andtyperat runtime. All other dependencies are optional extras. py.typedmarker — the package ships with inline type hints.- Reproducible builds —
hatchlingbuild backend with no dynamic metadata.
Development
git clone https://github.com/MathiasPaulenko/behave-gen.git
cd behave-gen
pip install -e ".[dev]"
pre-commit install
| Command | Description |
|---|---|
make help |
Show all available targets. |
make dev |
Install with dev extras. |
make lint |
Run ruff check + mypy --strict. |
make lint-fix |
Auto-fix lint issues. |
make format |
Format the code with ruff format. |
make format-check |
Verify formatting without changes. |
make test |
Run the test suite. |
make test-cov |
Run tests with coverage. |
make build |
Build sdist + wheel into ref/output/dist/. |
make clean |
Remove build artifacts and caches. |
See CONTRIBUTING.md for full guidelines.
Documentation
Full documentation, including the CLI reference, configuration guide, and Python API docs, is published at mathiaspaulenko.github.io/behave-gen.
Acknowledgements
- Built on top of Behave and the Python packaging ecosystem.
- Template and scaffolding patterns inspired by the Python open source community's emphasis on minimal, composable tools.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file behave_gen-1.1.1.tar.gz.
File metadata
- Download URL: behave_gen-1.1.1.tar.gz
- Upload date:
- Size: 96.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf8776213e66c9092875d02a70df5e1b370fe279e8945da5d58be082bf71cf6b
|
|
| MD5 |
6dcca6129b4b1a6dd27b6832555e74e5
|
|
| BLAKE2b-256 |
c5d96f348b779fc23ebdad094eb736815e2bf69a25b2bfb5cc29057898d9b606
|
Provenance
The following attestation bundles were made for behave_gen-1.1.1.tar.gz:
Publisher:
release.yml on MathiasPaulenko/behave-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_gen-1.1.1.tar.gz -
Subject digest:
cf8776213e66c9092875d02a70df5e1b370fe279e8945da5d58be082bf71cf6b - Sigstore transparency entry: 2256677909
- Sigstore integration time:
-
Permalink:
MathiasPaulenko/behave-gen@acff9ae9609d1b9f9a504bc5726ec751314a4cf4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MathiasPaulenko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@acff9ae9609d1b9f9a504bc5726ec751314a4cf4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file behave_gen-1.1.1-py3-none-any.whl.
File metadata
- Download URL: behave_gen-1.1.1-py3-none-any.whl
- Upload date:
- Size: 75.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c65bd0606984c4287435e65593c04a59fa6cbd9a5ef1538f2723309f68a68446
|
|
| MD5 |
ad797b4cee4f2c8eb5bc313ceeb53c69
|
|
| BLAKE2b-256 |
bb0be8bdd8114ec713ef52350480896d49b1e46ba8e4c3b63f506ccb5419ea28
|
Provenance
The following attestation bundles were made for behave_gen-1.1.1-py3-none-any.whl:
Publisher:
release.yml on MathiasPaulenko/behave-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_gen-1.1.1-py3-none-any.whl -
Subject digest:
c65bd0606984c4287435e65593c04a59fa6cbd9a5ef1538f2723309f68a68446 - Sigstore transparency entry: 2256677911
- Sigstore integration time:
-
Permalink:
MathiasPaulenko/behave-gen@acff9ae9609d1b9f9a504bc5726ec751314a4cf4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MathiasPaulenko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@acff9ae9609d1b9f9a504bc5726ec751314a4cf4 -
Trigger Event:
push
-
Statement type: