Skip to main content

CLI toolkit for scaffolding and evolving Behave BDD projects.

Project description

behave-gen

A CLI toolkit for scaffolding and evolving Behave BDD projects.

CI Docs PyPI Python License Code style: ruff Types: mypy

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 Upgrade generated files to the latest behave-gen versions.

Installation

pip install behave-gen

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-projectinit + add feature + add steps with HTTP and auth step libraries.
  • openapi-projectfrom-openapi generating features and HTTP steps from a Petstore OpenAPI 3.0 spec.
  • migrated-projectmigrate converting 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, and typer at runtime. All other dependencies are optional extras.
  • py.typed marker — the package ships with inline type hints.
  • Reproducible buildshatchling build backend with no dynamic metadata.

Development

git clone https://github.com/behave-gen/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 dist/.
make clean Remove build artifacts and caches.

See CONTRIBUTING.md for full guidelines.

License

MIT

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

behave_gen-0.1.0.tar.gz (57.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

behave_gen-0.1.0-py3-none-any.whl (61.5 kB view details)

Uploaded Python 3

File details

Details for the file behave_gen-0.1.0.tar.gz.

File metadata

  • Download URL: behave_gen-0.1.0.tar.gz
  • Upload date:
  • Size: 57.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for behave_gen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b832599419fc279e40f8610c0d730d47dffb3d502ec6dd68b49f85c96cee38c
MD5 eb9eddb5454838b7c9c62fd7d044e270
BLAKE2b-256 3d1244735cdef2285dd331ccedbbab7292a6d50ff93c90b650f397169926d2fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for behave_gen-0.1.0.tar.gz:

Publisher: release.yml on MathiasPaulenko/behave-gen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file behave_gen-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: behave_gen-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 61.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for behave_gen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 769e224640ba20512720612e67707c9adf762f337e31a2c55fa7f3088bdfb5d0
MD5 95342f381aee28d3c24ec702b873ca54
BLAKE2b-256 fa435aaaf71d3bb894a1a3c8f0bb7121cbff4b0d29cc9008f8329946f67996de

See more details on using hashes here.

Provenance

The following attestation bundles were made for behave_gen-0.1.0-py3-none-any.whl:

Publisher: release.yml on MathiasPaulenko/behave-gen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page