mcpField
B
behavior-driven-testing

behavior-driven-testing

github.com/agent-nextTesting & quality1153 installsUpdated 34w ago
Repository

About behavior-driven-testing

behavior-driven-testing is a software testing skill for developers planning and validating code changes around user-visible behavior. Its staged workflow and branch matrices guide coverage of boundaries, error paths, and real-environment scenarios.

Key features

  1. 01Organizes testing into analysis, design, and execution
  2. 02Defines expected behavior with Gherkin
  3. 03Maps state transitions and branches
  4. 04Designs equivalence and boundary tests
  5. 05Combines unit, integration, and end-to-end tests
  6. 06Checks coverage and release criteria

Use cases

  1. 01Define testable behavior for a new requirement
  2. 02Review branches affected by a code change
  3. 03Add tests for empty values, boundaries, and errors
  4. 04Verify tests and coverage before release

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/agent-next/behavior-driven-testing --skill behavior-driven-testing

After installing, type/behavior-driven-testingin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

README.md
LICENSE
references/
analysis-phase.md
design-phase.md
branch-matrices.md
execution-phase.md
testing-principles.md
test-templates.md

Details

From the project README

Behavior-Driven Testing

Start from user behavior, not code structure. Every user-reachable path must be tested—no branch left uncovered, no edge case assumed.

Core Principles

  1. Behavior over Implementation - Test what users see, not how code works
  2. Exhaustive Coverage - Every branch, every condition, every edge case
  3. Context Awareness - Every test must define its preconditions explicitly
  4. Real Environment Validation - Mocks are tools, not destinations

Workflow Overview

Testing follows three phases. Follow them in order:

Analysis → Design → Execution → Verify Coverage → Ship (or loop back)

Analysis Phase:

  1. Requirements Definition - Define "correct" behavior with Gherkin specs
  2. Code Change Tracking - Know exactly what changed
  3. State Machine Analysis - Map all UI states and transitions
  4. Branch Mapping - Create the branch matrix (core artifact)

Design Phase: 5. Test Case Design - Apply equivalence partitioning, boundary analysis 6. Impact Analysis - Ensure new code doesn't break existing behavior 7. Test Prioritization - P0 (every commit) → P3 (periodic)

Execution Phase: 8. Test Data Preparation - Create fixtures, mocks, factories 9. Test Implementation - Write unit, integration, E2E tests 10. Test Execution - Run tests in phases (local → CI → staging) 11. Coverage Verification - Verify branch matrix completion

Quick Reference: Must-Test Branches

CategoryTest CasesPriority
Empty valuesnull, undefined, "", " " (whitespace), [], {}P0
Boundariesmin-1, min, min+1, max-1, max, max+1P1
Auth stateslogged in, logged out, loading, session expiredP0
API responses200+data, 200+empty, 400, 401, 403, 404, 500, timeout, offlineP0
User chaosdouble-click, rapid navigation, refresh mid-action, back buttonP1
The Whitespace Trap (Most Common Bug)
// ❌ WRONG - whitespace "   " is truthy!
if (!text) throw new Error('Required');

// ✅ CORRECT
if (!text?.trim()) throw new Error('Required');

Common Mistakes

MistakeWhy It's BadFix
Only happy pathError paths are 50% of codeTest ALL branches
Skip empty value testsMost common production bugsTest null, undefined, "", whitespace separately
Mock everythingMocks hide real problemsAdd integration + E2E tests
"Tested manually"Not repeatable, not reliableAutomate it
Ignore loading statesUsers interact during loadTest loading behavior
Skip double-click testUsers double-click everythingTest rapid interactions

Branch Matrix Template

For each code change, create a branch matrix:

| ID | Condition | True Behavior | False Behavior | Priority | Status |
|----|-----------|---------------|----------------|:--------:|:------:|
| B01 | user.isPremium | Skip credit check | Check credits | P0 | ⬜ |
| B02 | credits >= required | Proceed | Show error | P0 | ⬜ |
| B03 | credits == required | Boundary: Proceed | - | P1 | ⬜ |

Status: ⬜ Pending | ✅ Passed | ❌ Failed

Detailed References

Load these files only when you need detailed guidance:

Pre-Release Checklist

Before shipping, verify:

## Mock Tests (CI)
- [ ] All unit tests pass
- [ ] All integration tests pass
- [ ] Coverage thresholds met

## Real Tests (Before release)
- [ ] E2E tests pass on staging
- [ ] Manual smoke test on staging
- [ ] Core paths verified in real environment

## Branch Matrix
- [ ] All P0 branches tested
- [ ] All P1 branches tested
- [ ] No untested edge cases

## Production (After deploy)
- [ ] Smoke test passes
- [ ] Error rate monitoring normal

Related Skills

  • test-driven-development - Write tests first, then implementation
  • systematic-debugging - Debug issues methodically

Comments

Markdown supported