← ClaudeAtlas

test-refactoring-cataloglisted

Use when refactoring tests — extracting helpers, renaming for business clarity, deduplicating fixtures, consolidating parametrized cases, or restructuring test classes after GREEN phase without changing behavior coverage
SebastienDegodez/skraft-plugin · ★ 4 · Testing & QA · score 60
Install: claude install-skill SebastienDegodez/skraft-plugin
# Test Refactoring Catalog Safe transformations for test code that preserve behavioral coverage while improving readability, maintainability, and signal-to-noise ratio. ## When to Load - After GREEN: tests pass, you notice duplication or unclear naming. - During COMMIT & VERIFY: cleanup before commit, no new behavior. - Reviewing test code that smells (long arrange, repeated setup, cryptic names). ## Hard Rule **Every refactoring below is behavior-preserving.** Run the full test suite before AND after. If a test turns red, REVERT — the refactoring was wrong. --- ## Catalog ### R1 — Extract Arrange Helper **Smell:** Multiple tests repeat the same 5+ lines of setup. **Transform:** ```csharp // Before — duplicated in 4 tests var driver = new DriverInfo(Age: 25, LicenseYears: 5); var vehicle = new VehicleInfo(Type: "sedan", Age: 2); var policy = new EligibilityPolicy(); // After — one helper, parameters for what varies private static EligibilityPolicy CreatePolicy() => new(); private static DriverInfo ADriver(int age = 25, int licenseYears = 5) => new(Age: age, LicenseYears: licenseYears); private static VehicleInfo AVehicle(string type = "sedan", int age = 2) => new(Type: type, Age: age); ``` **Rules:** - Helper name starts with `A`, `An`, or `Create` + business noun. - Parameters only for what VARIES across tests. Defaults for the happy path. - Helper lives in the same test class or a shared `TestKit` project. --- ### R2 — Rename for Business Intent **Sme