skills/mav-bp-unit-testing/SKILL.md
Unit testing conventions for applications. Covers test design, isolation, structure, mocking discipline, and project testing guidance. Applied when writing or reviewing unit tests.
npx skillsauth add thermiteau/maverick mav-bp-unit-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Ensure unit tests are meaningful, fast, and maintainable. Tests verify behaviour, not implementation.
Every test follows three phases:
One act per test. If you need multiple acts, you need multiple tests.
| Type | Purpose | When to use | | ---- | ------- | ----------- | | Stub | Returns canned data | Replace a dependency that provides input to the unit | | Mock | Verifies interactions | Verify the unit calls a dependency correctly (use sparingly) | | Fake | Simplified implementation | Replace complex infrastructure (in-memory DB, fake HTTP server) | | Spy | Records calls to real implementation | Verify a side effect while keeping real behaviour |
should return empty array when no items match filterdescribe blocksdescribe('functionName', () => { it('should [behaviour] when [condition]') })All projects must maintain a minimum 60% line coverage for unit tests. This is a floor, not a target — teams should aim higher where it adds value, but 60% ensures a meaningful safety net exists.
coverageThreshold in config--cov-fail-under=60 flaggo test -cover outputminimumCoverageRatio in build config| Coverage tells you | Coverage does NOT tell you | | --- | --- | | Which lines were executed during tests | Whether assertions are meaningful | | Which branches were taken | Whether edge cases are covered | | Which functions were called | Whether the tests would catch real bugs | | Where test gaps exist | Whether the tested behaviour matters |
Use coverage to find untested areas, not to prove quality. A file at 90% coverage with no assertions is worse than a file at 65% coverage with thorough assertions.
Before applying these standards, load the project-specific testing implementation:
digraph lookup {
"docs/maverick/skills/unit-testing/SKILL.md exists?" [shape=diamond];
"Read and use alongside these standards" [shape=box];
"Invoke upskill" [shape=box];
"Read generated skill" [shape=box];
"docs/maverick/skills/unit-testing/SKILL.md exists?" -> "Read and use alongside these standards" [label="yes"];
"docs/maverick/skills/unit-testing/SKILL.md exists?" -> "Invoke upskill" [label="no"];
"Invoke upskill" -> "Read generated skill";
"Read generated skill" -> "Read and use alongside these standards";
}
docs/maverick/skills/unit-testing/SKILL.mddo-upskill skill with:
describe\(|it\(|test\(|expect\(|assert|@Test|func Test**/*.test.*, **/*.spec.*, **/test_*.*| Pattern | Issue | Fix | | ------- | ----- | --- | | Test with no assertions | False confidence | Add meaningful assertions | | Mocking internal modules | Brittle tests | Mock at boundaries only | | Test name describes implementation | Couples to internals | Describe behaviour instead | | Shared mutable state between tests | Test pollution | Use beforeEach/factory functions | | Test catches and swallows errors | Hidden failures | Let errors propagate or assert on them | | >3 mocks in one test | Unit has too many dependencies | Refactor the unit's design | | Test duplicates implementation logic | Tautological test | Assert on outputs, not reimplemented logic | | Commented-out tests | Dead tests hiding failures | Delete or fix |
<!-- maverick-plugin-version: 3.3.7 -->development
--- name: do-test description: Write or update tests for a code change. Operates in two modes: `unit` (module-scoped, fast, deterministic) and `integration` (crosses module / service / database boundaries). Intended to be invoked once per testable change from inside a do-issue-* or do-epic phase. Mode is required. argument-hint: mode: unit or integration user-invocable: true disable-model-invocation: false --- **Depends on:** mav-bp-unit-testing, mav-bp-integration-testing, mav-local-verificati
development
Implement a focused code change. Use this skill as the wrapper for any implementation work so the Maverick workflow report captures what was done and so the agent applies the project's coding standards before editing. Intended to be invoked once per task from inside a do-issue-* or do-epic phase, not standalone.
testing
How to stack a PR on top of an unmerged sibling branch, and how to retarget it to the repo's default branch once the sibling merges. Prevents orphan-merge incidents when a dependent story is ready before its parent.
development
Claim, lease, heartbeat, and release protocols for when multiple Claude Code instances may act on the same issue or epic concurrently. GitHub labels and marker comments are the coordination surface; local state is a cache.