-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Approach #2: Behavior-Driven Development (BDD) for User Journey Validation
Overview
Write executable specifications in natural language (Gherkin). Specifications become tests. Tests become living documentation. Validates complete end-to-end user workflows.
Theory
Feature files are human-readable specifications that execute as automated tests:
Feature: User approves request
As a service provider
I want to approve booking requests
So I can manage my capacity
Scenario: Approve request with sufficient capacity
Given I am logged in as a provider
And I have capacity for 4 items
And a customer has requested 2 items
When I navigate to "Pending Requests"
And I tap "Accept" on the first request
Then the request status should change to "Accepted"
And the available capacity should decrease to 2
And the customer should receive confirmationCritical User Journeys (Generic Examples)
1. Resource Creation
Given I am a verified provider
When I create an offering from Location A to Location B
And I set available capacity to 4
And I set start time to tomorrow 9 AM
And I publish the offering
Then the offering should appear in search results
And other providers should not see my offering2. Customer Booking
Given I am a customer
When I search for offerings from Location A to Location B
And I select an offering with 4 available slots
And I request 2 slots
Then the provider should receive a notification
And my booking status should be "pending"
And I should see estimated cost3. Request Approval/Rejection
Given a customer has requested 2 slots for my offering
When I navigate to pending requests
Then I should see 1 pending request
When I tap "Accept"
Then available capacity should decrease to 2
And the customer should be notified
And payment should be authorized4. Payment Processing
Given my booking was approved
When the payment is captured
Then I should see transaction confirmation
And the provider's earnings should increase
And I should receive a receipt5. Service Completion & Rating
Given the service has ended
When I rate the provider 5 stars
And I leave a review "Great service!"
Then the provider should see my rating
And their average rating should update
And I should be able to report issues if neededImplementation Steps
Week 1: Setup
- Install BDD testing framework (
flutter_gherkin,cucumber, etc.) - Create
features/directory structure - Write first feature file (resource creation)
- Implement step definitions
- Configure test runner (headed mode support)
Week 2: Core Journeys
- Write Gherkin scenarios for 5 critical journeys
- Implement all step definitions
- Add test data fixtures (users, resources, bookings)
- Run tests in headed mode (visible browser/UI)
Week 3: Discovery & Fixing
- For each failing scenario:
- Capture screenshot/video
- Analyze root cause
- Create GitHub issue
- Implement fix
- Verify scenario passes
Week 4: Integration
- Add BDD tests to CI pipeline
- Require passing scenarios before merge
- Generate HTML reports from test runs
- Document: scenario → feature mapping
Tools
Dart/Flutter: flutter_gherkin
dev_dependencies:
flutter_gherkin: ^3.0.0JavaScript/TypeScript: @cucumber/cucumber
{
"devDependencies": {
"@cucumber/cucumber": "^9.0.0"
}
}Configuration Example:
FlutterTestConfiguration(
features: [Glob('features/**.feature')],
reporters: [
ProgressReporter(),
TestRunSummaryReporter(),
JsonReporter(path: './report.json'),
],
stepDefinitions: [
GivenIAmLoggedInAs(),
WhenINavigateTo(),
ThenIShouldSee(),
],
hooks: [AttachScreenshotOnFailedStepHook()],
);Success Criteria
✅ 5 critical journeys fully specified in Gherkin
✅ All scenarios have step definitions
✅ Tests run in headed mode (visible execution)
✅ 100% scenario pass rate
✅ Screenshots captured on failures
✅ Living documentation generated from features
Strengths
✅ Business-readable - Non-technical stakeholders understand
✅ Living documentation - Specs stay in sync with code
✅ Collaboration - Shared language between roles
✅ Executable specs - Tests ARE requirements
✅ Regression suite - Scenarios accumulate over time
Weaknesses
❌ Maintenance burden - Brittle step definitions
❌ Slow execution - High-level tests are slower
❌ Over-specification - Too much detail makes fragile
❌ Step duplication - Similar steps across files
Rating
⭐⭐⭐⭐ (4/5) - Excellent for user journeys
References
- Research:
.forge/research-spike-alternative-approaches.md(Section 4) - Agent: QA-02-BDD-Journeys
- Related: Multi-Agent Quality Assurance: Preventing Shallow AI Implementations #4, Approach #1: Property-Based Testing for AI Code Quality #5
Current Status
📋 Approach documented - Ready for implementation
Labels: enhancement, bdd, user-journeys
Priority: High
Effort: Medium (3-4 weeks)