Testing Skill
When to use
- Writing unit or integration tests (Go or frontend)
- Writing E2E/API integration tests in
test/ folder with BDD stage patterns
- Applying TDD: failing test first, then implementation, then refactor
- Reproducing a bug with a test before fixing it
- Creating or updating bug reports when not fixing immediately
- Improving or verifying test coverage
Test Structure Pattern
Critical Rule: Main test functions must contain subtests.
Go Tests
- Main test functions (
TestXxx) MUST contain one or more subtests using t.Run
- Each test case should be a subtest within the main test function
- Group related scenarios as subtests within the same main test function
- Use separate main test functions for different behaviors or distinct test groups
// ✅ GOOD: Main function contains subtests
func TestNewEmail_WithInvalidInput_ReturnsError(t *testing.T) {
t.Run("returns error for invalid email format", func(t *testing.T) {
// test case
})
t.Run("returns error for empty string", func(t *testing.T) {
// test case
})
}
Frontend Tests
- Main test suites should use
describe blocks to organize related test cases
- Each
test or it block should test one specific behavior
- Group related test cases within the same
describe block
// ✅ GOOD: Main describe block contains multiple test cases
describe('LoginPage', () => {
test('user can submit login form', async () => { /* ... */ });
test('displays error when email is invalid', async () => { /* ... */ });
});
References
| File |
Purpose |
| .cursor/rules/go-testing-practices.mdc |
Go testing (testify, t.Run subtests pattern, unit tests with mocks, integration tests with testcontainers), test naming, coverage, test data factories |
| .cursor/rules/frontend-testing-practices.mdc |
Frontend testing (React Testing Library, describe/test blocks, MSW), build verification, TypeScript compilation checks |
| .cursor/rules/test-driven-development.mdc |
TDD core principles, Iron Law, verification checklist, red flags |
| .cursor/skills/tdd-workflow/SKILL.md |
Detailed TDD workflow with examples, common rationalizations, bug fix walkthrough |
| .cursor/rules/e2e-testing-standards.mdc |
E2E tests in test/ folder: Given-When-Then architecture, stage files (*_test_stage.go), functional options, file organization |
| .cursor/rules/e2e-test-overview.mdc |
Quick reference for E2E BDD pattern, when to use, method naming |
| .cursor/rules/e2e-test-examples.mdc |
7 complete examples (POST, GET, PATCH, DELETE, auth, event-driven) |
| .cursor/rules/testing-agent.mdc |
Bug handling and prioritization (critical vs low), bug report template, BUG_NNN naming, systematic testing checklist, when to fix vs when to backlog |
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: testing-473description: Implements Test-Driven Development for this project—unit tests, integration tests with testcontainers, mocks, and regression tests. Use when writing or fixing tests, reproducing bugs with tests, or improving coverage. Use when this capability is needed.4---56# Testing Skill78## When to use910- Writing unit or integration tests (Go or frontend)11- Writing E2E/API integration tests in `test/` folder with BDD stage patterns12- Applying TDD: failing test first, then implementation, then refactor13- Reproducing a bug with a test before fixing it14- Creating or updating bug reports when not fixing immediately15- Improving or verifying test coverage1617## Test Structure Pattern1819**Critical Rule**: Main test functions must contain subtests.2021### Go Tests22- **Main test functions** (`TestXxx`) **MUST** contain one or more subtests using `t.Run`23- Each test case should be a subtest within the main test function24- Group related scenarios as subtests within the same main test function25- Use separate main test functions for different behaviors or distinct test groups2627```go28// ✅ GOOD: Main function contains subtests29func TestNewEmail_WithInvalidInput_ReturnsError(t *testing.T) {30 t.Run("returns error for invalid email format", func(t *testing.T) {31 // test case32 })33 t.Run("returns error for empty string", func(t *testing.T) {34 // test case35 })36}37```3839### Frontend Tests40- **Main test suites** should use `describe` blocks to organize related test cases41- Each `test` or `it` block should test one specific behavior42- Group related test cases within the same `describe` block4344```typescript45// ✅ GOOD: Main describe block contains multiple test cases46describe('LoginPage', () => {47 test('user can submit login form', async () => { /* ... */ });48 test('displays error when email is invalid', async () => { /* ... */ });49});50```5152## References5354| File | Purpose |55|------|---------|56| [.cursor/rules/go-testing-practices.mdc](.cursor/rules/go-testing-practices.mdc) | Go testing (testify, t.Run subtests pattern, unit tests with mocks, integration tests with testcontainers), test naming, coverage, test data factories |57| [.cursor/rules/frontend-testing-practices.mdc](.cursor/rules/frontend-testing-practices.mdc) | Frontend testing (React Testing Library, describe/test blocks, MSW), build verification, TypeScript compilation checks |58| [.cursor/rules/test-driven-development.mdc](.cursor/rules/test-driven-development.mdc) | TDD core principles, Iron Law, verification checklist, red flags |59| [.cursor/skills/tdd-workflow/SKILL.md](.cursor/skills/tdd-workflow/SKILL.md) | Detailed TDD workflow with examples, common rationalizations, bug fix walkthrough |60| [.cursor/rules/e2e-testing-standards.mdc](.cursor/rules/e2e-testing-standards.mdc) | E2E tests in test/ folder: Given-When-Then architecture, stage files (*_test_stage.go), functional options, file organization |61| [.cursor/rules/e2e-test-overview.mdc](.cursor/rules/e2e-test-overview.mdc) | Quick reference for E2E BDD pattern, when to use, method naming |62| [.cursor/rules/e2e-test-examples.mdc](.cursor/rules/e2e-test-examples.mdc) | 7 complete examples (POST, GET, PATCH, DELETE, auth, event-driven) |63| [.cursor/rules/testing-agent.mdc](.cursor/rules/testing-agent.mdc) | Bug handling and prioritization (critical vs low), bug report template, BUG_NNN naming, systematic testing checklist, when to fix vs when to backlog |6465---66> Converted and distributed by [TomeVault](https://tomevault.io/claim/pedromsmoreira) — claim your Tome and manage your conversions.67<!-- tomevault:4.0:skill_md:2026-04-13 -->