Nw test refactoring catalog

From nWave-ai/nWave · View interactive version

Nw test refactoring catalog is an AI agent skill from the GitHub repository nWave-ai/nWave. Detailed refactoring mechanics with step-by-step procedures, and test code smell catalog with detection patterns and before/after examples

How to use this skill

Skill file

Test Refactoring Catalog

Test Code Smells (Full Detail)

L1 Readability Smells

Obscure Test
Before: public void Test1() { /* ... */ }
After:  public void ProcessOrder_PremiumCustomer_AppliesCorrectDiscount() { /* ... */ }
Hard-Coded Test Data
Before: Assert.Equal(850, result.Total);  // What discount?
After:  const decimal EXPECTED_TOTAL = 1000 * (1 - 0.15m);
        Assert.Equal(EXPECTED_TOTAL, result.Total);
Assertion Roulette

L2 Complexity Smells

Eager Test
Before: ProcessOrderTest() { /* tests discount AND shipping AND tax */ }
After:  ProcessOrder_AppliesDiscount()
        ProcessOrder_CalculatesShipping()
        ProcessOrder_CalculatesTax()

Prefer parameterized tests for variations of the same behavior.

Test Code Duplication
Extract: CreatePremiumCustomer(), CreateHighValueOrder()
Conditional Test Logic

Python illustration (pytest binding; use the native table/parameterized-test facility elsewhere):

# Before: if/else in test
# After:
@pytest.mark.parametrize("input,expected", [...])
def test_behavior(input, expected): ...

L3 Organization Smells

Mystery Guest
Test Class Bloat
Before: UserServiceTests (31 tests)
After:  UserAuthTests, UserProfileTests, UserNotificationTests
General Fixture

For production code refactoring techniques and mechanics, load the progressive-refactoring skill.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.