| name | bdd-test-runner |
| description | Executes BDD-compliant GIVEN-WHEN-THEN tests with vanilla JUnit5, validates test naming compliance, analyzes coverage, and ensures tests follow project testing standards. Use when running tests, validating test patterns, checking coverage, or when user mentions "run tests", "BDD", "GIVEN-WHEN-THEN", "test coverage", or "validate tests". |
| allowed-tools | Read, Bash, Grep, Glob, TodoWrite |
BDD Test Runner & Compliance Validator
Executes GIVEN-WHEN-THEN tests with comprehensive compliance validation and coverage analysis for the Fakt compiler plugin.
Core Mission
This Skill enforces THE ABSOLUTE TESTING STANDARD: GIVEN-WHEN-THEN pattern with vanilla JUnit5 + kotlin-test, ensuring all tests follow project guidelines and Metro-inspired patterns.
Instructions
1. Understand Test Request
Extract from conversation:
- Test pattern to run (e.g., "Generic*", "Compiler*", "all")
- Scope (compiler tests, sample tests, integration tests)
- Validation requirements (naming compliance, coverage analysis)
Common requests:
- "Run all tests" โ Execute full test suite
- "Run compiler tests" โ Focus on compiler module
- "Validate test naming" โ BDD compliance check only
- "Check coverage" โ Coverage analysis
2. Pre-Execution BDD Compliance Check
Before running tests, validate BDD compliance:
# Find all test files
find compiler/src/test/kotlin -name "*Test.kt"
# Check for GIVEN-WHEN-THEN pattern
grep -r "fun \`GIVEN" compiler/src/test/kotlin/
# Check for forbidden "should" pattern (MUST BE ZERO)
grep -r "fun \`should" compiler/src/test/kotlin/
Compliance checklist:
- All test methods use
GIVEN-WHEN-THENnaming (uppercase) - No "should" pattern found (forbidden in this project)
- All test classes have
@TestInstance(TestInstance.Lifecycle.PER_CLASS) - Using vanilla assertions (assertEquals, assertTrue, etc.)
If non-compliant tests found:
๐จ BDD COMPLIANCE VIOLATION DETECTED
โ Found {count} tests using "should" pattern (forbidden)
๐ Tests must follow GIVEN-WHEN-THEN pattern
Files to fix:
- {list of non-compliant files}
๐ Reference: resources/testing-guidelines-reference.md
Do not proceed with execution until compliance is confirmed or user acknowledges violations.
3. Execute Tests
Determine test scope:
All tests:
cd fakt && ./gradlew test
Compiler module only:
cd fakt && ./gradlew :compiler:test
Pattern-based:
cd fakt && ./gradlew :compiler:test --tests "*{Pattern}*"
# Examples:
./gradlew :compiler:test --tests "*Generic*"
./gradlew :compiler:test --tests "*GIVEN*WHEN*THEN*"
./gradlew :compiler:test --tests "*CompilerPluginRegistrar*"
Capture output:
- Total tests run
- Tests passed/failed/skipped
- Execution time
- Any warnings or errors
4. Analyze Results
Parse test output:
Success scenario:
โ
53 tests passed (0 failed, 0 skipped)
โฑ๏ธ Execution time: 4.2s
๐ All tests follow GIVEN-WHEN-THEN pattern
Failure scenario:
โ 3 tests failed (50 passed, 0 skipped)
Failed tests:
1. GIVEN interface with generics WHEN generating THEN should preserve types
โ Error: Type mismatch (Phase 2 limitation)
2. GIVEN complex interface WHEN generating THEN should compile
โ Error: Missing import for cross-module type
3. GIVEN async interface WHEN generating factory THEN should work
โ Error: Suspend function handling edge case
๐ก Suggested actions:
- For generic issues: Consult generic-type-handling.md
- For compilation: Run /validate-compilation
- For async: Check suspend function patterns
5. Coverage Analysis
Compare actual vs claimed coverage:
# Count total test files
find compiler/src/test/kotlin -name "*Test.kt" | wc -l
# Count GIVEN-WHEN-THEN tests
grep -r "fun \`GIVEN" compiler/src/test/kotlin/ | wc -l
# Identify coverage gaps
find compiler/src/main/kotlin -name "*.kt" | while read file; do
testFile="${file/src\/main/src\/test}"
testFile="${testFile/.kt/Test.kt}"
if [ ! -f "$testFile" ]; then
echo "Missing tests for: $file"
fi
done
Coverage report format:
๐ TEST COVERAGE ANALYSIS
Total implementation files: {count}
Total test files: {count}
Coverage ratio: {percentage}%
GIVEN-WHEN-THEN tests: 53
Legacy tests (disabled): {count}
Coverage gaps identified: {count}
Missing coverage for:
- {list of files without tests}
๐ Reference: `.claude/docs/development/validation/testing-guidelines.md`
6. Metro Pattern Validation
Check if tests follow Metro testing approach:
Metro testing patterns:
- Compiler plugin tests in compiler/src/test/
- Compilation validation tests
- Generated code verification
- API compatibility tests
Validation:
# Check for compilation tests
grep -r "compiles successfully" compiler/src/test/kotlin/
# Check for Metro-style context tests
grep -r "IrPluginContext" compiler/src/test/kotlin/
# Check for generated code validation
grep -r "build/generated" compiler/src/test/kotlin/
For detailed Metro patterns:
- Consult
resources/metro-testing-patterns.md
7. Output Structured Report
Standard test execution report:
๐งช BDD TEST EXECUTION REPORT
๐ Compliance Status: โ
PASSED
- GIVEN-WHEN-THEN naming: 53/53 tests โ
- @TestInstance annotation: All classes โ
- Vanilla assertions: No custom matchers โ
- "should" pattern: 0 violations โ
โก Execution Results:
- Total: 53 tests
- Passed: 53 โ
- Failed: 0
- Skipped: 0
- Time: 4.2s
๐ Coverage: 85%
- Implementation files: 20
- Test files: 17
- Coverage gaps: 3 files
๐ Metro Alignment: โ
- Compiler plugin tests: Present
- Compilation validation: Present
- Generated code tests: Present
๐ Test output: build/test-results/
8. Suggest Follow-Up Actions
Based on test results:
If tests fail:
- Analyze errors and suggest relevant Skills
- For generic issues โ
generic-scoping-analyzer - For compilation โ
compilation-validator - For IR issues โ
kotlin-ir-debugger
If coverage gaps:
- Suggest files needing tests
- Offer to generate tests with
behavior-analyzer-tester
If compliance violations:
- List non-compliant tests
- Suggest fixing patterns
- Reference testing guidelines
9. Update Test Status Tracking
If user requests, update status files:
# Update test metrics in current-status.md (optional)
# Test status tracking can be done via test output or CI
# No need to maintain separate test-status.md file
Supporting Files
Progressive disclosure for detailed testing documentation:
resources/testing-guidelines-reference.md- Complete GIVEN-WHEN-THEN standard (loaded on-demand)resources/metro-testing-patterns.md- Metro compiler testing approach (loaded on-demand)resources/coverage-analysis-guide.md- Coverage analysis techniques (loaded on-demand)resources/test-failure-diagnostics.md- Common test failure patterns (loaded on-demand)
Test Execution Patterns
Quick Test Run
User: "Run all tests"
โ Execute: ./gradlew test
โ Report: Pass/fail summary
Compliance Check Only
User: "Validate test naming"
โ Skip execution
โ Check: GIVEN-WHEN-THEN compliance
โ Report: Violations if any
Pattern-Based Testing
User: "Run generic tests"
โ Execute: ./gradlew test --tests "*Generic*"
โ Report: Subset results
Full Analysis
User: "Run tests and check coverage"
โ Execute: ./gradlew test
โ Analyze: Coverage gaps
โ Report: Comprehensive analysis
Related Skills
This Skill composes with:
behavior-analyzer-tester- Generate missing testscompilation-validator- Validate generated codekotlin-ir-debugger- Debug IR generation issuesmetro-pattern-validator- Check Metro alignment
Best Practices
- Always validate BDD compliance before execution
- Report coverage gaps to maintain quality
- Suggest actionable fixes for failures
- Reference testing guidelines for violations
- Track test metrics over time
Known Testing Standards
From .claude/docs/development/validation/testing-guidelines.md:
- โ GIVEN-WHEN-THEN naming (uppercase, mandatory)
- โ @TestInstance(PER_CLASS) lifecycle (required)
- โ Vanilla JUnit5 + kotlin-test (no custom matchers)
- โ runTest for coroutines
- โ Isolated instances per test (no shared state)
- โ "should" pattern (forbidden in this project)
- โ Custom BDD frameworks (not allowed)
- โ Mocks (use fakes instead)
Current Status (Phase 1)
- 53 tests passing with GIVEN-WHEN-THEN pattern
- 85% compilation success rate target
- Zero "should" violations (enforced)
- Metro-aligned testing approach