Context
As the DDD restructuring of app/matching/ progresses (#23), we need automated validation that domain behaviors match business specifications. BDD (Behavior-Driven Development) frameworks allow expressing domain rules as executable Gherkin-style scenarios that serve as both documentation and tests.
Related issues:
Goal
Evaluate BDD frameworks for Python that integrate with our existing pytest-based test infrastructure. Determine which best fits the project for encoding domain rules as executable specifications.
Candidates
Primary
Also consider
Evaluation Criteria
1. Feature Fit
2. pytest Integration
3. DDD Alignment
4. Security & snip Supply Chain
5. Reputation & snip Ecosystem
Deliverables
- Comparison matrix — scoring each candidate across criteria above
- PoC spike — implement 2–3 matching domain scenarios in the top candidate against
app/matching/ domain services
- Recommendation — which framework to adopt, with migration path from current pytest-only approach
- Security audit — dependency review of recommended framework
Non-Goals
- Replacing existing pytest tests — BDD layer supplements, not replaces
- Frontend BDD (separate spike if needed)
- Full migration plan (follow-up issue if recommended)
Example Domain Scenarios to Spike
From #23 domain model, these behaviors would benefit from BDD validation:
Feature: Voter matching
As a campaign organizer
I want OCR-extracted names matched against voter records
So that I can verify petition signatures accurately
Scenario: Exact match with high confidence
Given a voter record for "John Smith" at "Ward 3 Precinct 1"
And an OCR candidate "John Smith" with confidence 0.95
When the matching service processes the candidate
Then the match prediction should be "accepted"
And the confidence level should be "high"
Scenario Outline: Fuzzy matching threshold
Given a voter record for "<voter_name>"
And an OCR candidate "<ocr_text>" with confidence <ocr_confidence>
When the matching service processes the candidate
Then the match status should be <expected_status>
Examples:
| voter_name | ocr_text | ocr_confidence | expected_status |
| John Smith | Jon Smith | 0.90 | accepted |
| John Smith | J. Smith | 0.85 | needs_review |
| John Smith | Jane Doe | 0.70 | rejected |
Context
As the DDD restructuring of
app/matching/progresses (#23), we need automated validation that domain behaviors match business specifications. BDD (Behavior-Driven Development) frameworks allow expressing domain rules as executable Gherkin-style scenarios that serve as both documentation and tests.Related issues:
app/matching/(primary consumer of BDD scenarios)Goal
Evaluate BDD frameworks for Python that integrate with our existing pytest-based test infrastructure. Determine which best fits the project for encoding domain rules as executable specifications.
Candidates
Primary
@given/@when/@thendecoratorsAlso consider
Evaluation Criteria
1. Feature Fit
.featurefile support (Given/When/Then scenarios)@slow,@integration)2. pytest Integration
conftest.pyfixturespytest-asyncio(project is async)pytest.markmarkers3. DDD Alignment
4. Security & snip Supply Chain
uv5. Reputation & snip Ecosystem
Deliverables
app/matching/domain servicesNon-Goals
Example Domain Scenarios to Spike
From #23 domain model, these behaviors would benefit from BDD validation: