Loading...
Loading...
This skill should be used when writing tests, fixing bugs, adding features, or modifying the gateway layer. Use when you need guidance on testing architecture, working with fakes, implementing ABC gateway interfaces, or understanding the defense-in-depth testing strategy. Essential for maintaining test quality and understanding where different types of tests belong.
npx skill4agent add dagster-io/erk fake-driven-testingdignified-python-313┌─────────────────────────────────────────┐
│ Layer 5: Business Logic Integration Tests (5%) │ ← Smoke tests over real system
├─────────────────────────────────────────┤
│ Layer 4: Business Logic Tests (70%) │ ← Tests over fakes (MOST TESTS)
├─────────────────────────────────────────┤
│ Layer 3: Pure Unit Tests (10%) │ ← Zero dependencies, isolated testing
├─────────────────────────────────────────┤
│ Layer 2: Integration Sanity Tests (10%)│ ← Fast validation with mocking
├─────────────────────────────────────────┤
│ Layer 1: Fake Infrastructure Tests (5%)│ ← Verify test doubles work
└─────────────────────────────────────────┘quick-reference.mdworkflows.md#adding-a-new-featuretesting-strategy.mdpython-specific.mdgateway-architecture.mdworkflows.md#adding-a-gateway-methodgateway-architecture.md#gateways-vs-backendspatterns.mdanti-patterns.mdquick-reference.mdgateway-architecture.mdtesting-strategy.mdpython-specific.mdworkflows.mdpatterns.mdanti-patterns.mdquick-reference.mdquick-reference.mdworkflows.md#adding-a-new-featurepatterns.mdanti-patterns.mdworkflows.md#fixing-a-bugpatterns.md#constructor-injection-for-fakesquick-reference.md#example-tests-to-referencegateway-architecture.mdworkflows.md#adding-a-gateway-methodquick-reference.md#quick-checklist-adding-a-new-gateway-methodanti-patterns.md#not-updating-all-layersquick-reference.md#decision-treetesting-strategy.mdquick-reference.md#example-tests-to-referencepatterns.mdquick-reference.md#common-test-patternsanti-patterns.mdworkflows.md┌──────────────────────────────────────────────────────────────┐
│ Layer 5: Business Logic Integration Tests (5%) │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Real database, filesystem, APIs, actual subprocess │ │
│ │ Purpose: Smoke tests, catch integration issues │ │
│ │ When: Sparingly, for critical workflows │ │
│ │ Speed: Seconds per test │ │
│ │ Location: tests/e2e/ or tests/integration/ │ │
│ └──────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────┐
│ Layer 4: Business Logic Tests (70%) ← MOST TESTS HERE │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ FakeDatabase, FakeApiClient, FakeFileSystem │ │
│ │ Purpose: Test features and business logic extensively │ │
│ │ When: For EVERY feature and bug fix │ │
│ │ Speed: Milliseconds per test │ │
│ │ Location: tests/unit/, tests/services/, tests/commands/ │ │
│ └──────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────┐
│ Layer 3: Pure Unit Tests (10%) │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Zero dependencies, no fakes, no mocks │ │
│ │ Purpose: Test isolated utilities and helpers │ │
│ │ When: For pure functions, data structures, parsers │ │
│ │ Speed: Milliseconds per test │ │
│ │ Location: tests/unit/ │ │
│ └──────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────┐
│ Layer 2: Integration Sanity Tests (10%) │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ RealDatabase with mocked connections │ │
│ │ Purpose: Quick validation, catch syntax errors │ │
│ │ When: When adding/changing real implementation │ │
│ │ Speed: Fast (mocked) │ │
│ │ Location: tests/integration/test_real_*.py │ │
│ └──────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────┐
│ Layer 1: Fake Infrastructure Tests (5%) │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Test FakeDatabase itself │ │
│ │ Purpose: Verify test infrastructure is reliable │ │
│ │ When: When adding/changing fake implementation │ │
│ │ Speed: Milliseconds per test │ │
│ │ Location: tests/unit/fakes/test_fake_*.py │ │
│ └──────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘sanitize_branch_name("feat/FOO")"feat-foo"parse_git_status("## main"){"branch": "main"}LinkedList.append()create_worktree(fake_git, name="feature")submit_pr(fake_gh, fake_git, ...)pytesttmp_pathquick-reference.mdquick-reference.mdtesting-strategy.mdgateway-architecture.mdworkflows.mdpatterns.mdanti-patterns.mdpython-specific.md