Skip to content

Commit 17d38a4

Browse files
feat: initial release v0.1.0 - behavior-driven-testing skill
Systematic testing methodology for exhaustive branch coverage, edge case identification, and production bug prevention. - SKILL.md with core principles and quick reference - 6 reference files with detailed guidance - Complete Unit/Integration/E2E test templates - Branch matrix system for tracking coverage - Pre-release checklists Author: Cong Wang License: MIT
0 parents  commit 17d38a4

File tree

9 files changed

+2033
-0
lines changed

9 files changed

+2033
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Cong Wang
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Behavior-Driven Testing
2+
3+
A systematic testing methodology for exhaustive branch coverage, edge case identification, and production bug prevention.
4+
5+
## Installation
6+
7+
```bash
8+
npx skills add robotlearning123/behavior-driven-testing
9+
```
10+
11+
Or manually copy to your skills directory:
12+
```bash
13+
git clone https://github.com/robotlearning123/behavior-driven-testing.git ~/.agents/skills/behavior-driven-testing
14+
```
15+
16+
## When to Use
17+
18+
- PR review reveals incomplete test coverage
19+
- Tests pass but users report bugs
20+
- Code changes break existing features
21+
- Verifying all branches and edge cases before merge
22+
- Analyzing "it works on my machine" issues
23+
- Planning test strategy for new features
24+
- Debugging flaky tests and race conditions
25+
26+
## Core Philosophy
27+
28+
**Start from user behavior, not code structure.** Every user-reachable path must be tested—no branch left uncovered, no edge case assumed.
29+
30+
## Key Features
31+
32+
- **Branch Matrix System** - Systematic tracking of all code branches
33+
- **Progressive Disclosure** - Quick reference + detailed guides when needed
34+
- **Copy-Paste Templates** - Ready-to-use Unit, Integration, and E2E test templates
35+
- **Pre-Release Checklists** - Verify coverage before shipping
36+
37+
## Structure
38+
39+
```
40+
behavior-driven-testing/
41+
├── SKILL.md # Main entry point
42+
├── LICENSE # MIT License
43+
└── references/
44+
├── analysis-phase.md # Requirements, state machines, branch mapping
45+
├── branch-matrices.md # All branch coverage templates
46+
├── design-phase.md # Test case design, impact analysis
47+
├── execution-phase.md # Implementation, execution, coverage
48+
├── test-templates.md # Complete code templates
49+
└── testing-principles.md # Mock vs Real, creating test conditions
50+
```
51+
52+
## Quick Start
53+
54+
1. **Map branches** - Create a branch matrix for your code changes
55+
2. **Design tests** - Apply equivalence partitioning and boundary analysis
56+
3. **Implement** - Use the provided templates for Unit/Integration/E2E tests
57+
4. **Verify** - Check all P0/P1 branches are covered before shipping
58+
59+
## License
60+
61+
MIT © Cong Wang

SKILL.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
name: behavior-driven-testing
3+
description: Systematic testing methodology for exhaustive branch coverage, edge case identification, and production bug prevention. Use when PR review reveals incomplete test coverage, when tests pass but users report bugs, when code changes break existing features, when verifying all branches and edge cases before merge, when analyzing "it works on my machine" issues, when planning test strategy for new features, or when debugging flaky tests and race conditions.
4+
license: MIT
5+
metadata:
6+
author: Cong Wang
7+
version: "0.1.0"
8+
category: testing
9+
---
10+
11+
# Behavior-Driven Testing
12+
13+
Start from user behavior, not code structure. Every user-reachable path must be tested—no branch left uncovered, no edge case assumed.
14+
15+
## Core Principles
16+
17+
1. **Behavior over Implementation** - Test what users see, not how code works
18+
2. **Exhaustive Coverage** - Every branch, every condition, every edge case
19+
3. **Context Awareness** - Every test must define its preconditions explicitly
20+
4. **Real Environment Validation** - Mocks are tools, not destinations
21+
22+
## Workflow Overview
23+
24+
Testing follows three phases. Follow them in order:
25+
26+
```
27+
Analysis → Design → Execution → Verify Coverage → Ship (or loop back)
28+
```
29+
30+
**Analysis Phase:**
31+
1. Requirements Definition - Define "correct" behavior with Gherkin specs
32+
2. Code Change Tracking - Know exactly what changed
33+
3. State Machine Analysis - Map all UI states and transitions
34+
4. Branch Mapping - Create the branch matrix (core artifact)
35+
36+
**Design Phase:**
37+
5. Test Case Design - Apply equivalence partitioning, boundary analysis
38+
6. Impact Analysis - Ensure new code doesn't break existing behavior
39+
7. Test Prioritization - P0 (every commit) → P3 (periodic)
40+
41+
**Execution Phase:**
42+
8. Test Data Preparation - Create fixtures, mocks, factories
43+
9. Test Implementation - Write unit, integration, E2E tests
44+
10. Test Execution - Run tests in phases (local → CI → staging)
45+
11. Coverage Verification - Verify branch matrix completion
46+
47+
## Quick Reference: Must-Test Branches
48+
49+
| Category | Test Cases | Priority |
50+
|----------|------------|:--------:|
51+
| **Empty values** | null, undefined, "", " " (whitespace), [], {} | P0 |
52+
| **Boundaries** | min-1, min, min+1, max-1, max, max+1 | P1 |
53+
| **Auth states** | logged in, logged out, loading, session expired | P0 |
54+
| **API responses** | 200+data, 200+empty, 400, 401, 403, 404, 500, timeout, offline | P0 |
55+
| **User chaos** | double-click, rapid navigation, refresh mid-action, back button | P1 |
56+
57+
### The Whitespace Trap (Most Common Bug)
58+
59+
```javascript
60+
// ❌ WRONG - whitespace " " is truthy!
61+
if (!text) throw new Error('Required');
62+
63+
// ✅ CORRECT
64+
if (!text?.trim()) throw new Error('Required');
65+
```
66+
67+
## Common Mistakes
68+
69+
| Mistake | Why It's Bad | Fix |
70+
|---------|--------------|-----|
71+
| Only happy path | Error paths are 50% of code | Test ALL branches |
72+
| Skip empty value tests | Most common production bugs | Test null, undefined, "", whitespace separately |
73+
| Mock everything | Mocks hide real problems | Add integration + E2E tests |
74+
| "Tested manually" | Not repeatable, not reliable | Automate it |
75+
| Ignore loading states | Users interact during load | Test loading behavior |
76+
| Skip double-click test | Users double-click everything | Test rapid interactions |
77+
78+
## Branch Matrix Template
79+
80+
For each code change, create a branch matrix:
81+
82+
```markdown
83+
| ID | Condition | True Behavior | False Behavior | Priority | Status |
84+
|----|-----------|---------------|----------------|:--------:|:------:|
85+
| B01 | user.isPremium | Skip credit check | Check credits | P0 ||
86+
| B02 | credits >= required | Proceed | Show error | P0 ||
87+
| B03 | credits == required | Boundary: Proceed | - | P1 ||
88+
89+
Status: ⬜ Pending | ✅ Passed | ❌ Failed
90+
```
91+
92+
## Detailed References
93+
94+
Load these files only when you need detailed guidance:
95+
96+
- **Analysis details**: See [references/analysis-phase.md](references/analysis-phase.md)
97+
- Gherkin specification format
98+
- State machine diagrams
99+
- Complete branch mapping methodology
100+
101+
- **Test templates**: See [references/test-templates.md](references/test-templates.md)
102+
- Unit test structure (Vitest/Jest)
103+
- Integration test patterns
104+
- E2E test examples (Playwright)
105+
106+
- **Branch matrices**: See [references/branch-matrices.md](references/branch-matrices.md)
107+
- Entry point branches
108+
- Authentication branches
109+
- API response branches
110+
- Input validation branches
111+
112+
- **Testing principles**: See [references/testing-principles.md](references/testing-principles.md)
113+
- Mock vs Real testing
114+
- Creating test conditions you don't have
115+
- Progressive testing strategy (Day 1-4)
116+
117+
## Pre-Release Checklist
118+
119+
Before shipping, verify:
120+
121+
```markdown
122+
## Mock Tests (CI)
123+
- [ ] All unit tests pass
124+
- [ ] All integration tests pass
125+
- [ ] Coverage thresholds met
126+
127+
## Real Tests (Before release)
128+
- [ ] E2E tests pass on staging
129+
- [ ] Manual smoke test on staging
130+
- [ ] Core paths verified in real environment
131+
132+
## Branch Matrix
133+
- [ ] All P0 branches tested
134+
- [ ] All P1 branches tested
135+
- [ ] No untested edge cases
136+
137+
## Production (After deploy)
138+
- [ ] Smoke test passes
139+
- [ ] Error rate monitoring normal
140+
```
141+
142+
## Related Skills
143+
144+
- test-driven-development - Write tests first, then implementation
145+
- systematic-debugging - Debug issues methodically

0 commit comments

Comments
 (0)