write-tests
Test implementation skill for HypermediaEngine. Takes a confirmed test plan from design-test-cases and produces compilable, runnable xUnit tests following project conventions. Validates coverage quality through mutation testing. Invoked by the sqa-engineer agent after the test plan is approved.
- License 许可
- GPL-3.0
- 最近更新
- 2026-06-06
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- write-tests
- model
- claude-opus-4-7
- tools
- Read, Write, Edit, Grep, Glob, Bash, TodoWrite
- description
- Test implementation skill for HypermediaEngine. Takes a confirmed test plan from design-test-cases and produces compilable, runnable xUnit tests following project conventions. Validates coverage quality through mutation testing. Invoked by the sqa-engineer agent after the test plan is approved.
03 SKILL.md 正文
You are executing the write-tests skill on behalf of the sqa-engineer agent. Your job is to implement the confirmed test plan as working, convention-compliant xUnit test code. This skill expects a confirmed test plan as input — test case design is handled by the design-test-cases skill. Do not redesign test strategy here; implement what the plan specifies.
Input
The calling agent will pass:
- A confirmed test plan produced by the
design-test-casesskill - The component under test (file path and class name)
Process
Phase 0 — Context Load (silent, no user interaction)
Before writing any code:
- Read
CLAUDE.mdto internalize conventions. - Invoke
Skill("manage-memory", args: "sqa-engineer")to load prior knowledge about test fixtures and patterns. - Read the confirmed test plan in full — every TC specification is a work item.
- Locate the test project using Glob. Read several existing test files to internalize:
- Test framework (xUnit)
- Assertion library in use
- Test double approach (NSubstitute, hand-rolled, etc.)
- Naming convention
- Fixture and setup patterns (
IClassFixture, constructors,[ClassFixture])
- Add every TC from the plan as a
TodoWriteitem before writing a single line of code.
Phase 1 — Test Implementation
Implement each TC from the confirmed plan in order. For every test file written:
Structure
Use Arrange / Act / Assert in every test method:
[Fact]
public async Task MethodName_StateUnderTest_ExpectedBehavior()
{
// Arrange
...
// Act
ResultType result = await sut.MethodNameAsync(input, ct);
// Assert
...
}
Naming
Three-part names that read as a specification: MethodName_StateUnderTest_ExpectedBehavior
Validate_WhenAuthHeaderIsMissing_ReturnsErrorResultDispatch_WhenHandlerSucceeds_ReturnsPopulatedDataProcess_WhenTokenIsCancelled_ThrowsOperationCanceledException
Convention checklist (apply to every test file)
- [ ] Explicit type declarations:
MyService sut = new(mockDep);notvar sut = ... - [ ]
await usingfor any disposable test fixtures - [ ] Assert both
dataanderrorfields for every{ data, error }result — never assert only one side - [ ] Each
[Fact]tests exactly one behavior from the TC specification - [ ] Use
[Theory]with[InlineData]or[MemberData]for parameterized edge cases listed in the plan - [ ] No
Thread.Sleepor arbitrary delays — useCancellationTokenproperly - [ ] Mock only the dependencies the TC exercises — minimal mock configuration
- [ ] Never mock the system under test itself
- [ ] No shared mutable state between test cases
Integration tests
For TCs marked as integration type in the plan:
- Use
WebApplicationFactory<T>or an in-memoryIHost - Register test doubles in the test host's DI — do not modify production registrations
- Each test must leave shared infrastructure in a clean state
Mark each TodoWrite TC item complete immediately after its test is written and compiling.
Phase 2 — Run and Verify
dotnet test
- All new tests must pass
- No previously passing test may fail — a test that breaks existing tests is itself a defect; report it to the software-engineer rather than modifying production code
- If a test fails because the implementation has a bug: stop, report the bug to the software-engineer, do not modify production code yourself
- If a test fails because the test setup is wrong: fix the test setup only
Phase 3 — Mutation Testing
dotnet stryker
For each surviving mutant in code covered by the new tests:
- Map the mutant back to the TC that should have caught it
- Strengthen or add a test case that produces observably different output when the mutation is present
- Re-run
dotnet strykerto confirm the mutant is killed
Acceptable reasons to leave a mutant alive (add a comment in the test file):
- The mutant is in logging-only code with no observable output difference
- The code path is architecturally unreachable without breaking DI or middleware contracts
Do not mark work complete with unresolved surviving mutants unless each one is explicitly justified.
Quality Gate
Do not mark the test suite complete until:
- [ ] Every TC from the confirmed plan has a corresponding test method
- [ ] Every AC listed in the plan maps to at least one passing test
- [ ]
dotnet testexits with 0 failures - [ ]
dotnet strykerproduces no surviving mutants on new code paths (or each survivor is commented and justified) - [ ] Both
dataanderrorare asserted in every{ data, error }result test - [ ] No previously passing test was broken
- [ ] No production code was modified
Output
Report completion with:
Tests implemented for: [component name] — [N tests written, dotnet test: pass, dotnet stryker: N survivors / all killed]
04 同仓库更多 Skills
write-documentation
Structured documentation writing workflow for HypermediaEngine. Writes or updates README.md files at the repo root and in each project directory (src/, tests/, samples/, etc.) based on current implementation, ADRs, and architecture decisions.
write-adr
Writes a numbered Architecture Decision Record (ADR) for a significant architectural choice in the HypermediaEngine project. Invoked by the software-architect agent whenever a consequential design decision is made or ratified. Saves the ADR to docs/architecture/decisions/.
tunit-playwright-ui-testing
Comprehensive guidance for writing coded end-to-end UI tests in C# using TUnit.Playwright. Tests inherit from PageTest — the base class manages all browser lifecycle. Covers NuGet setup, PageTest inheritance, Page Object Model, browser configuration, parallelism limiting, and CI integration. Based on the official TUnit docs at https://tunit.dev/docs/examples/playwright.
triage
Task classification, decomposition, dependency mapping, and routing skill. Invoked by the triage-agent to break any user request into discrete, independently-routable work items with assigned priorities and agent chains.
system-design
Expert system design skill. Use PROACTIVELY to design systems, review architectures, and assist software engineers in learning design principles and implementing them in the code with design patterns.
spec-driven-development
Manages the full lifecycle of a feature specification — from collaborative drafting to enforcement during implementation and testing.