Skip to main content

Translate between Python tests, Gherkin behavior specs, and BDD execution evidence

Project description

PyPI - Version PyPI - Python Version decov](https://codecov.io/gh/holgern/specweave/graph/badge.svg?token=CjRFwWvyYm)](https://codecov.io/gh/holgern/specweave) PyPI - Downloads codecov

specweave

SpecWeave translates between canonical Gherkin behavior specs, plain pytest enforcement, and normalized execution evidence.

It is not a task ledger, architecture ledger, or CI system.

Canonical layout

specs/behavior/features/<area>/<feature>.feature.md
specs/behavior/features/<area>/<feature>.feature
tests/test_<area>_<feature>.py
reports/behavior/*.xml
.specweave/reports/*.json
.specweave/evidence/*.json
.specweave/mappings/taskledger/*.json

Canonical behavior specs live under specs/behavior/features. When [gherkin].document_format = "markdown" (the default), agents must create .feature.md files. If a classic .feature file is produced, run:

specweave convert <file> --to markdown
specweave convert --all --to markdown

and review the resulting .feature.md before committing. Executable enforcement is plain pytest directly under tests/.

SpecWeave does not require:

  • pytest-bdd
  • behave
  • step-definition modules
  • tests/bdd/
  • tests/behavior/
  • Taskledger as a Python dependency

Behavior workflow

1. Lint behavior specs

specweave behavior check

2. Generate the behavior index and manifest

specweave behavior index \
  --features specs/behavior/features \
  --out specs/behavior/README.md \
  --manifest specs/behavior/manifest.json

3. Generate plain pytest skeletons

Single feature:

specweave behavior generate-tests \
  specs/behavior/features/task-management/plan-gates.feature.md \
  --out tests/test_task_management_plan_gates.py

Whole tree:

specweave behavior generate-tests \
  --features specs/behavior/features \
  --tests-dir tests

4. Check static behavior coverage

specweave behavior coverage \
  --features specs/behavior/features \
  --tests tests \
  --format text

Write JSON or Markdown artifacts when needed:

specweave behavior coverage \
  --features specs/behavior/features \
  --tests tests \
  --json .specweave/reports/behavior-coverage.json

specweave behavior coverage \
  --features specs/behavior/features \
  --tests tests \
  --format markdown \
  --out .specweave/reports/behavior-coverage.md

List the raw explicit pytest mappings discovered by the scanner:

specweave behavior mappings --tests tests --format text

5. Import pytest/JUnit evidence

pytest tests/test_task_management_plan_gates.py \
  --junitxml=reports/behavior/task-management-plan-gates-junit.xml

specweave behavior import-report \
  reports/behavior/task-management-plan-gates-junit.xml \
  --format junit-xml \
  --out .specweave/evidence/task-management-plan-gates.pytest-evidence.json

Optional Taskledger integration

Taskledger integration is file-based and optional. SpecWeave can import a Taskledger acceptance export into a canonical behavior feature:

specweave behavior import-taskledger \
  .specweave/mappings/taskledger/task-0123.json \
  --out specs/behavior/features/task-management/plan-gates.feature.md

This does not make Taskledger the canonical owner of the behavior file. Taskledger exports are input artifacts. SpecWeave evidence JSON is output artifact data. Taskledger remains responsible for importing that evidence into task validation state.

Trace and cross-ledger diagnostics are read-only:

specweave trace @bdd-login-success --format json
specweave combi check --json .specweave/reports/combi-check.json

Archledger integration renders draft candidate markdown only. SpecWeave does not accept or persist Archledger records. Shared file contracts are documented as JSON Schema under specweave/schemas/.

Compatibility aliases

These aliases point to the behavior workflow:

specweave bdd check
specweave bdd index
specweave bdd generate-tests
specweave bdd coverage

Legacy draft, bind, report, and other bridge commands remain available for older experiments, but they are not the canonical SpecWeave workflow.

Converting feature files

Convert between classic .feature and Markdown .feature.md formats:

specweave convert specs/behavior/features/auth/login.feature
specweave convert specs/behavior/features --to markdown
specweave convert --all --to markdown
specweave --json convert specs/behavior/features/auth/login.feature
specweave convert login.feature.md --to classic
specweave convert login.feature --dry-run
specweave convert specs/behavior/features --to markdown --replace-source

Source files are kept by default. Use --replace-source only when you want to delete successfully converted classic .feature sources after the Markdown target exists. After a bulk conversion, run specweave behavior coverage or specweave review specs to catch stale explicit mappings that still point to classic paths.

Installation

pip install specweave

Or install from source with development dependencies:

pip install -e ".[dev]"

Development

pip install -e ".[dev]"
pytest -q
ruff check .
ruff format --check .
mypy specweave

License

Apache 2.0

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

specweave-0.1.0.tar.gz (157.8 kB view details)

Uploaded Source

Built Distribution

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

specweave-0.1.0-py3-none-any.whl (99.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: specweave-0.1.0.tar.gz
  • Upload date:
  • Size: 157.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for specweave-0.1.0.tar.gz
Algorithm Hash digest
SHA256 41f940bc5a3ab6e0363e2b220feb72083e54174fa4516c5c5e4945d7c6992124
MD5 b69c70fcc991d3bdf42dce0d696faf3b
BLAKE2b-256 4d1990a2efdef9b49a2ab012f2210e8f2f308c1504236778de656ca0217f13cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: specweave-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 99.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for specweave-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 410c462213571f05f28473db49fbc98e0df42d1e1f911fe818b08d6343d26337
MD5 e974fb75f8900b2703cd905da2cc692f
BLAKE2b-256 74a5cf0a8c6b389f8547cd0b8345016b1f3a082f44aed4fc565bcda0e93ba0a9

See more details on using hashes here.

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