write-tests
Write comprehensive, principled tests for code.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Write comprehensive, principled tests for code.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when drafting or editing prose or copy, including reports, research write-ups, guidance, documentation, READMEs, emails, announcements, summaries, blog posts, marketing copy, product copy, or any text meant to be read. Triggers whenever the user asks to draft, write, rewrite, edit, or polish copy. Applies GOV.UK and GDS house style, favoring plain English, active voice, front-loaded content, sentence case, and no bold or italics for emphasis. Balances that house style against ASD-STE100 Simplified Technical English, then runs Orwell's rules from 'Politics and the English Language' over the result. Simplified Technical English stays on for all prose unless the author explicitly asks for it to be switched off, and the agent announces that it is in use and offers to switch it off. Use it to compose new prose and to keep editing, not to audit finished text.
Use when drafting or editing prose or copy, including reports, research write-ups, guidance, documentation, READMEs, emails, announcements, summaries, blog posts, marketing copy, product copy, or any text meant to be read. Triggers whenever the user asks to draft, write, rewrite, edit, or polish copy. Applies GOV.UK and GDS house style, favoring plain English, active voice, front-loaded content, sentence case, and no bold or italics for emphasis. Balances that house style against ASD-STE100 Simplified Technical English, then runs Orwell's rules from 'Politics and the English Language' over the result. Simplified Technical English stays on for all prose unless the author explicitly asks for it to be switched off, and the agent announces that it is in use and offers to switch it off. Use it to compose new prose and to keep editing, not to audit finished text.
This skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.
Respond to code review comments point by point, quoting each reviewer point verbatim and answering directly beneath it.
Use when moving local sessions between Claude Code and Codex, converting Claude Code JSONL into Codex rollout format, converting Codex rollout JSONL into Claude scrollback, or debugging cross-agent resume state.
Use when moving local sessions between Codex and Claude Code, converting Codex rollout JSONL into Claude scrollback, converting Claude Code JSONL into Codex rollout format, or debugging cross-agent resume state.
| name | write-tests |
| description | Write comprehensive, principled tests for code. |
| when_to_use | Use when the user asks to write tests, add tests, create a test suite, test a file/function/module, or improve coverage. |
| argument-hint | <file, function, or module to test> |
| allowed-tools | ["Bash","Read","Edit","Write","Grep","Glob"] |
Write comprehensive, principled tests for the specified target: $ARGUMENTS
Before writing code, list the test cases you will write. Organize by category:
Happy path — Normal expected usage with valid inputs. Edge cases — Empty inputs, None/null, zero, single element, maximum/minimum values, unicode, whitespace. Error cases — Invalid inputs, missing required fields, type errors, permission failures. Boundary conditions — Off-by-one, empty collections, very large inputs, concurrent access. Integration points — If the code interacts with external systems, plan integration tests separately from unit tests.
Announce your test plan before writing any tests.
FIRST:
Test behavior, not implementation:
One concept per test:
test_process, test_function_workstest_returns_empty_list_when_no_items_match, test_raises_value_error_for_negative_amountArrange-Act-Assert:
# Arrange — set up inputs and dependencies
# Act — call the thing being tested (one action)
# Assert — verify the result
One act per test. If you need multiple acts, it's multiple tests.
| Mock | Don't Mock |
|---|---|
| External APIs, network calls | Your own internal functions |
| Databases (in unit tests) | Pure logic and computations |
| Filesystem, time, randomness | Deterministic code |
| Third-party services | Simple data transformations |
json.loads parses JSON).Before finishing, check each test against these criteria:
import pytest
class TestCalculateTax:
def test_calculates_tax_for_positive_amount(self):
result = calculate_tax(amount=100, rate=0.08)
assert result == 8.0
def test_returns_zero_for_zero_amount(self):
result = calculate_tax(amount=0, rate=0.08)
assert result == 0.0
def test_raises_for_negative_amount(self):
with pytest.raises(ValueError, match="must be positive"):
calculate_tax(amount=-100, rate=0.08)
@pytest.mark.parametrize("amount,rate,expected", [
(100, 0.10, 10.0),
(200, 0.05, 10.0),
(0, 0.10, 0.0),
])
def test_calculates_correctly_for_various_inputs(self, amount, rate, expected):
assert calculate_tax(amount, rate) == expected
pytest conventions:
conftest.py for shared fixtures. Don't duplicate fixture logic across files.@pytest.fixture for setup, not setUp/tearDown methods.@pytest.mark.parametrize for data-driven tests instead of copy-pasting.tmp_path fixture for filesystem tests instead of creating real temp directories.monkeypatch for patching instead of unittest.mock when possible.describe('calculateTax', () => {
it('calculates tax for positive amount', () => {
const result = calculateTax(100, 0.08);
expect(result).toBe(8);
});
it('returns zero for zero amount', () => {
expect(calculateTax(0, 0.08)).toBe(0);
});
it('throws for negative amount', () => {
expect(() => calculateTax(-100, 0.08)).toThrow('must be positive');
});
});
func TestCalculateTax(t *testing.T) {
tests := []struct {
name string
amount float64
rate float64
expected float64
}{
{"positive amount", 100, 0.08, 8.0},
{"zero amount", 0, 0.08, 0.0},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := CalculateTax(tt.amount, tt.rate)
if got != tt.expected {
t.Errorf("CalculateTax(%v, %v) = %v, want %v", tt.amount, tt.rate, got, tt.expected)
}
})
}
}
| Anti-Pattern | Why It's Bad | Do This Instead |
|---|---|---|
| Testing private methods directly | Couples tests to implementation | Test through the public interface |
| Multiple asserts testing different concepts | Unclear what failed and why | One concept per test |
| Copy-paste test code everywhere | Hard to maintain, hides intent | Extract fixtures/helpers, but keep tests readable (DAMP > DRY) |
| Testing the mock instead of the code | Proves nothing about real behavior | Assert on outputs, not on mock call counts |
| Chasing 100% coverage blindly | Wastes time on trivial code | Focus coverage on critical and complex paths |
| Shared mutable state between tests | Order-dependent failures, flakiness | Fresh state per test via setup/fixtures |
| Testing framework behavior | Proves the framework works, not your code | Only test your logic |
| Sleeping in tests | Slow and flaky | Use proper async patterns or mocked time |
describe/it blocks (JS) or test classes/functions (Python) for clear organization.