Agent skill
test-engineering
Use when the Integrator is writing unit tests, e2e tests, designing test strategies, improving test coverage, creating test fixtures, or mocking dependencies. Activates for any testing-related work including TDD, test refactoring, or test debugging.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/test-engineering
SKILL.md
Test Engineering Expertise
When This Applies
Apply this guidance when:
- Writing unit tests for new or existing code
- Designing end-to-end test scenarios
- Creating test fixtures and mocks
- Evaluating test coverage
- Debugging failing tests
Unit Test Principles
Structure: Arrange-Act-Assert
Every test should follow this pattern:
test("should calculate total with tax", () => {
// Arrange — Set up test data and dependencies
const cart = createCart([{ price: 100 }, { price: 50 }]);
const taxRate = 0.1;
// Act — Execute the code under test
const total = calculateTotal(cart, taxRate);
// Assert — Verify the result
expect(total).toBe(165);
});
What to Test
| Test | Example |
|---|---|
| Happy path | Valid input produces expected output |
| Edge cases | Empty input, boundary values, max/min |
| Error cases | Invalid input, missing data, exceptions |
| State transitions | Before/after mutation operations |
What NOT to Test
- Private implementation details (test behavior, not internals)
- Third-party library functionality
- Trivial getters/setters with no logic
- The programming language itself
Naming Convention
Test names should describe the scenario and expected outcome:
should return empty array when no items match filtershould throw ValidationError when email is invalidshould update timestamp after successful save
E2E Test Design
Scenario Structure
Feature: User authentication
Scenario: Successful login
Given a registered user with email "[email protected]"
When they submit valid credentials
Then they receive an auth token
And they can access protected resources
E2E Best Practices
- Test user-visible behavior — Not internal APIs
- Use realistic data — Don't test with "test123"
- Independent tests — Each test sets up and tears down its own state
- Stable selectors — Use data-testid, not CSS classes
- Reasonable timeouts — Account for async operations
Mocking Strategy
When to Mock
| Mock | Don't Mock |
|---|---|
| External APIs and services | The code under test |
| Database in unit tests | Pure functions |
| File system in unit tests | Data transformations |
| Time/randomness | Simple dependencies |
Mock Levels
- Stub — Returns canned data (simplest)
- Spy — Records calls for verification
- Mock — Stubs + spies + expected behavior
- Fake — Working alternative implementation (e.g., in-memory database)
Test Coverage Guidelines
- Aim for meaningful coverage, not 100% line coverage
- New features: cover all public interfaces and error paths
- Bug fixes: add a regression test that fails without the fix
- Critical paths (auth, payments, data mutations): high coverage required
- Utilities and helpers: cover edge cases thoroughly
Pre-Commit Test Checklist
Before committing (via /commit-work), verify:
- All existing tests still pass
- New tests added for new functionality
- Regression test added for bug fixes
- No test depends on external services without mocking
- No flaky tests (run twice to confirm)
- Test names clearly describe what they verify
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?