| name | testing-strategy |
| description | Comprehensive testing workflow combining TDD, real implementations (no mocking), and E2E testing. Use when implementing features, writing tests, or setting up test infrastructure. |
| allowed-tools | Read, Glob, Grep, Edit, Write, Bash |
| license | MIT |
| metadata | {"author":"obra/superpowers","version":"2.0"} |
Testing Strategy
TDD์ ์ค์ ๊ตฌํ ๊ธฐ๋ฐ ํ
์คํธ๋ฅผ ๊ฒฐํฉํ ํตํฉ ํ
์คํธ ์คํฌ์
๋๋ค.
Iron Law
"NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST"
RED-GREEN-REFACTOR Cycle
1. RED - ์คํจํ๋ ํ
์คํธ ์์ฑ
- ์ํ๋ ๋์์ ๋ณด์ฌ์ฃผ๋ ์ต์ํ์ ํ
์คํธ ์์ฑ
- ํ
์คํธ๊ฐ ์คํจํ๋์ง ๋ฐ๋์ ํ์ธ
2. GREEN - ํ
์คํธ ํต๊ณผ์ํค๊ธฐ
- ํ
์คํธ๋ฅผ ํต๊ณผ์ํค๋ ๊ฐ์ฅ ๋จ์ํ ์ฝ๋ ์์ฑ
- ์๋ฒฝํ ์ฝ๋ X, ๋์ํ๋ ์ฝ๋ O
3. REFACTOR - ๋ฆฌํฉํ ๋ง
- ์ฝ๋ ์ ๋ฆฌ (์ค๋ณต ์ ๊ฑฐ, ๋ช
๋ช
๊ฐ์ )
- ํ
์คํธ๊ฐ ๊ณ์ ํต๊ณผํ๋์ง ํ์ธ
No Mocking Policy
์ค์ ๊ตฌํ์ ํ
์คํธํ๋ผ
โ ๊ธ์ง
jest.mock('./database');
jest.mock('./api');
โ
ํ์ฉ
const db = await createTestDatabase();
const server = setupServer(
rest.get('/api/users', (req, res, ctx) => {
return res(ctx.json([{ id: 1, name: 'Test' }]));
})
);
E2E Testing (Playwright)
test('user can complete checkout', async ({ page }) => {
await page.goto('/products');
await page.click('[data-testid="add-to-cart"]');
await page.click('[data-testid="checkout"]');
await expect(page.locator('.confirmation')).toBeVisible();
});
Test Categories
| ์ ํ | ๋ฒ์ | ๋๊ตฌ |
|---|
| Unit | ํจ์/ํด๋์ค | Vitest, Jest |
| Integration | ๋ชจ๋ ๊ฐ ์ฐ๋ | ์ค์ DB, MSW |
| E2E | ์ ์ฒด ์ฌ์ฉ์ ํ๋ฆ | Playwright |
Checklist