This project uses Behavior-Driven Development to create executable specifications that serve as both documentation and automated tests. The BDD scenarios define exactly what alfred-timein does for users.
BDD scenarios answer three critical questions:
- What does the system do? (Feature descriptions)
- How do users interact with it? (Scenario steps)
- Why does it matter? (User value statements)
Each feature file is a contract that ensures the system delivers real user value, not just technical functionality.
Our BDD test suite covers five core feature areas:
- Finding timezones for major cities, landmarks, and locations with spaces
- Handling unknown locations gracefully with helpful error messages
- Performance requirements and caching behavior
- Case insensitive lookup and whitespace handling
- Human-readable time formatting with locale awareness
- Timezone validation before time display
- Different formats for different timezones
- Error handling for invalid inputs
- Alfred Script Filter JSON format compliance
- Error formatting for Alfred interface
- Cache indicators in Alfred results
- Proper cache duration headers
- Basic command usage for both
geotzandtimein - Pipeline workflows (
geotz | timein) - Format options (plain text vs Alfred JSON)
- Error handling and help text
- Cache hit/miss performance characteristics
- LRU eviction policy compliance
- Cache persistence across restarts
- TTL expiration behavior
- Graceful handling of corrupted cache entries
make test-bddmake test-allgo test -run TestBDD -vgo test -run TestBDD -godog.features=features/timezone_lookup.featureBDD tests produce human-readable output showing:
- ✅ Green: Scenarios that pass (business requirements met)
- 🟡 Yellow: Undefined steps (features documented but not yet implemented)
- ❌ Red: Failed scenarios (business requirements violated)
Current Status: Clean output with 12 passing scenarios and 64 passing steps. Additional scenarios are documented in comments but temporarily removed to avoid undefined step pollution.
Example output:
Feature: Timezone Lookup by City
Scenario: Finding timezone for a major city
Given I want to know the timezone for "Tokyo"
When I request the timezone information
Then I should get "Asia/Tokyo" as the timezone
And the response should be fast
- Feature files serve as executable specifications
- Business stakeholders can validate requirements
- No gap between documentation and implementation
- Ensures user-facing behavior remains consistent
- Catches breaking changes before they reach users
- Validates end-to-end workflows
- Natural language scenarios bridge technical/business divide
- Clear acceptance criteria for new features
- Shared understanding of system behavior
- Business rules are tested with every build
- Performance requirements are continuously validated
- Cache behavior is verified across scenarios
When adding new features:
- Start with the business need in natural language
- Write scenarios before implementation (outside-in development)
- Use Given/When/Then structure consistently
- Focus on outcomes, not implementation details
- Make scenarios readable by non-technical stakeholders
Example template:
Feature: [Business Capability]
As a [user type]
I want to [goal]
So that [business value]
Scenario: [Specific behavior]
Given [initial context]
When [action performed]
Then [expected outcome]
And [additional validation]- Step definitions in
bdd_test.gobridge natural language to code - Test context maintains state between steps
- Service integration tests real adapters and use cases
- Timeout handling ensures tests complete within reasonable time
- Cache management provides isolation between scenarios
This BDD implementation ensures our timezone tools meet real user needs while providing confidence that changes don't break existing functionality.