test-generation
暂无简介
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 6
- Forks
- 0
03 SKILL.md 正文
Test Generation
Goal
Produce high-signal tests that verify behavior and catch regressions.
When to use
- Writing unit, integration, or E2E tests
- Adding regression tests for known bugs
- Covering edge cases and failure paths
- Creating test plans for new features
- Improving test coverage
When not to use
- Performance benchmarking or load testing
- Observability or monitoring setup
- TDD methodology guidance (use test-driven-development)
- Production incident response
Process
- Identify behavior under test.
- Choose the right test level.
- Cover happy path, failures, and edge cases.
- Prefer deterministic inputs and assertions.
- Add regression cases for known bugs.
- Note required fixtures or mocks.
Framework-specific patterns
Jest / Vitest
beforeEach(() => {
jest.resetModules()
jest.clearAllMocks()
})
jest.useFakeTimers()
jest.advanceTimersByTime(1000)
expect(component).toMatchInlineSnapshot(`
<div>
<h1>Hello</h1>
</div>
`)
pytest
@pytest.fixture
def db():
conn = create_connection()
yield conn
conn.close()
@pytest.mark.parametrize("input,expected", [
("hello", "HELLO"),
("", ""),
("123", "123"),
])
def test_uppercase(input, expected):
assert uppercase(input) == expected
def test_api_call(monkeypatch):
monkeypatch.setattr("requests.get", mock_get)
result = fetch_data()
assert result == expected
Go
func TestAdd(t *testing.T) {
tests := []struct {
name string
a, b int
expected int
}{
{"positive", 1, 2, 3},
{"zero", 0, 0, 0},
{"negative", -1, -2, -3},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Add(tt.a, tt.b); got != tt.expected {
t.Errorf("Add(%d, %d) = %d, want %d", tt.a, tt.b, got, tt.expected)
}
})
}
}
Fixture strategy
| Fixture Type | When to Use | Example |
|---|---|---|
| Inline | Simple, self-contained | { name: "test" } |
| Factory | Multiple similar objects | createUser(overrides) |
| Snapshot | Complex output verification | toMatchSnapshot() |
| Database | Stateful tests | setUpTestData() |
| External service | API integration | Wiremock, VCR |
Flaky test anti-patterns
| Anti-Pattern | Why It's Flaky | Fix |
|---|---|---|
sleep() for timing |
Race conditions | Event-based waits |
| Shared mutable state | Test order dependency | Isolate state per test |
| Real network calls | External dependency | Mock or use VCR |
| System time dependency | Time zone, DST issues | Mock Date.now() |
| Random data | Non-deterministic | Seed random generators |
| Parallel test interference | File/DB conflicts | Unique resources per test |
Output format
- Test target
- Level
- Cases
- Missing setup
- Proposed tests
04 同仓库更多 Skills
invoice-organizer
Automatically organizes invoices and receipts for tax preparation by reading messy files, extracting key information, renaming them consistently, and sorting them into logical folders. Turns hours of manual bookkeeping into minutes of automated organization.
file-organizer
Intelligently organizes your files and folders across your computer by understanding context, finding duplicates, suggesting better structures, and automating cleanup tasks. Reduces cognitive load and keeps your digital workspace tidy without manual effort.
developer-growth-analysis
Analyzes your recent Claude Code chat history to identify coding patterns, development gaps, and areas for improvement, curates relevant learning resources from HackerNews, and automatically sends a personalized growth report to your Slack DMs.
connect
暂无简介
twitter-algorithm-optimizer
暂无简介
tailored-resume-generator
暂无简介