AGENT SKILL

test-writer

Write tests for the current implementation

使用场景测试与质量
License 许可
MIT
最近更新
2026-10-28
Stars
★ 1
Forks
0

01 前言 Front Matter

name
test-writer
description
Write tests for the current implementation

03 SKILL.md 正文

User Input

$ARGUMENTS

Objective

Act as a Senior Test Engineer responsible for creating and maintaining automated tests for the current implementation.

Your responsibility is to ensure the implemented behavior is correctly covered by reliable, maintainable tests.

Do NOT implement production functionality unless a minimal change is strictly required to make the tests possible.

1. Understand the Context

Read and understand:

  • The current Issue or Epic
  • Acceptance criteria
  • Relevant implementation changes
  • Existing tests
  • Test conventions
  • Project architecture
  • Testing tools and frameworks

Use the conventions from epic-repository-rules (call it if they are not already in context). Repository rules always override workflow defaults.

2. Current Tool Documentation

Before using or installing any testing tool or library, use epic-current-documentation (or its result already in context).

3. Analyze Test Coverage

Before writing tests:

  1. Identify the behavior introduced or changed.
  2. Identify existing tests covering that behavior.
  3. Identify important untested paths.
  4. Identify edge cases and failure scenarios.
  5. Avoid duplicating existing coverage.

Prioritize tests that protect actual business behavior and acceptance criteria.

4. Write Tests

Create or update tests appropriate to the project.

Prefer:

  • Unit tests for isolated business logic.
  • Integration tests for component interactions.
  • API tests for API behavior.
  • E2E tests for critical user flows.

Follow the existing project's testing patterns.

Tests should be:

  • Deterministic
  • Readable
  • Maintainable
  • Focused
  • Independent
  • Fast when possible

Do not over-mock the system.

Prefer testing observable behavior over implementation details.

Command Bus

Follow command-bus-architecture. Business behavior lives in Handles, so:

  • Test stores in store/store.test.ts: set primitives through setters and assert every $ derived value, especially $<part>UI presentation values for each state.
  • Test Handles by mounting them, dispatching through actions and asserting the resulting MobX store state and dispatched actions.
  • Test components by asserting they render the values from $<part>UI and dispatch the expected actions.
  • Always unmount Handles between tests so registrations are disposed.

5. Test Scenarios

Cover, when applicable:

  • Happy paths
  • Validation
  • Error handling
  • Boundary conditions
  • Important edge cases
  • Regression scenarios
  • Authorization or permission behavior
  • Relevant integration behavior

Do not create tests for hypothetical scenarios with no meaningful product or technical value.

6. Run Tests

Run the relevant test suite.

If tests fail:

  1. Determine whether the failure is caused by the implementation or the test.
  2. Fix the test when the test is incorrect.
  3. Report implementation defects to the caller instead of modifying production behavior unnecessarily.

Do not weaken or remove a test simply to make the suite pass.

7. Validate Test Quality

Before finishing, verify:

  • Tests pass.
  • Tests actually exercise the intended behavior.
  • No important acceptance criterion is left untested when testing is applicable.
  • No unnecessary duplicate tests were created.
  • Tests follow repository conventions.
  • Tests do not depend on execution order.
  • Tests do not rely on unstable external state.

8. Final Output

Return:

  • Tests created or modified
  • Behaviors covered
  • Test commands executed
  • Test results
  • Any implementation defects discovered

Do not modify unrelated tests.

Do not implement unrelated production code.

Return this output to the calling skill and continue its flow. Do not end the run here unless this skill was invoked directly by the user.

04 同仓库更多 Skills