You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(write-tests): boundary/wire mocking over interface fakes
The skill taught patterns that a real Go CLI testing effort found to be
anti-patterns. Bring it in line.
- Replace the three-layer strategy (which framed interface-based fakes as a
legitimate boundary approach) with boundary-first testing: fake the
executable on PATH and assert the real argv, or httptest and assert the
method/path/body. Drop the CommandRunner interface pattern — asserting
"Run was called" proves the code called the fake, not that it built the
right command, and it couples tests to a test-only interface.
- Stop recommending t.Skip() when the binary is absent — that is a
false-green (the coverage gate runs `go test` without building first).
Build the binary in TestMain; a miss is a hard failure. Note that
subprocess tests don't count toward a package's coverage, so command
logic needs in-process cobra tests (with an os.Stdout capture helper,
since commands print via fmt.Printf, not cmd.OutOrStdout).
- Switch examples from testify to stdlib `testing` (t.Fatalf preconditions,
t.Errorf checks, reflect.DeepEqual, errors.Is/As) to match stdlib
codebases; keep a note to match testify only where a project already uses it.
- Add the "prove the negative" pattern for destructive ops (fake fails the
test on any mutating call) and a Determinism section (map-iteration and
unseeded-RNG bugs).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AfCuqUGhxYxbvo4FgkBtFm
Copy file name to clipboardExpand all lines: plugins/launchpad/skills/write-tests/SKILL.md
+43-34Lines changed: 43 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: write-tests
3
-
description: Use when writing tests, adding test coverage, choosing test types, testing a specific function, or when asked "should I mock this", "how should I test this", "write tests for", "add tests", "test this function", "write integration tests", or "rewrite test suite". Provides three-layer testing strategy, specification-grade testing workflow, boundary mocking, and Go-specific patterns including Cobra command, Bubble Tea model, and runner testing.
3
+
description: Use when writing tests, adding test coverage, choosing test types, testing a specific function, or when asked "should I mock this", "how should I test this", "write tests for", "add tests", "test this function", "write integration tests", or "rewrite test suite". Provides a boundary-first testing strategy (wire-level fakes, httptest, in-process commands), specification-grade workflow, and Go-specific patterns including Cobra command, Bubble Tea model, and runner testing.
4
4
---
5
5
6
6
# Writing Specification-Grade Tests
@@ -58,42 +58,45 @@ tools/cluster/
58
58
-**`test/`** — E2E tests that execute the built binary
59
59
-**`testdata/`** — static fixtures (ignored by Go tooling)
60
60
61
-
## Three-Layer Testing Strategy
61
+
## Testing Strategy: Test at the Boundary
62
62
63
63
> "The more your tests resemble the way your software is used, the more
64
64
> confidence they can give you." — Kent C. Dodds
65
65
66
-
**Every testable behavior gets a Layer 3 (E2E) test.** Layers 1 and 2 supplement
67
-
Layer 3 — they keep CI green when real tools aren't available, but they never
0 commit comments