diff --git a/.claude/skills/code-formatting/SKILL.md b/.claude/skills/code-formatting/SKILL.md index 55e0627035c0..1eac7ec8b54c 100644 --- a/.claude/skills/code-formatting/SKILL.md +++ b/.claude/skills/code-formatting/SKILL.md @@ -13,6 +13,8 @@ description: "MANDATORY: When writing Go tests, you MUST use 'When...it should.. ## Test Conventions - MANDATORY +### Test naming + **NON-NEGOTIABLE RULE**: Every Go test name MUST follow this exact format: ```go name: "When , it should " @@ -35,7 +37,30 @@ name: "When encryption is enabled, it should configure disk encryption set" - ✅ "When NodePool has ImageID, it should create basic Azure machine template" - ✅ "When subnet ID is invalid, it should return error with subnet parse message" +### Unit test function naming + +Unit test functions MUST be named after the function they test, using the standard Go `Test` convention: + +```go +// Testing function ReconcileNodePool +func TestReconcileNodePool(t *testing.T) { ... } + +// Testing function buildAzureMachineTemplate +func TestBuildAzureMachineTemplate(t *testing.T) { ... } +``` + +**NEVER use generic or disconnected test function names like:** +- ❌ `TestNodePoolFeatures` +- ❌ `TestAzureIntegration` +- ❌ `TestVariousCases` + +Each test function should map 1:1 to the function under test. If a function is complex enough to warrant many test cases, use table-driven tests within a single `Test` function with the "When...it should..." naming for each case. + +### Unit test placement + - **Always include unit tests** when creating new functions or modifying existing ones +- **Place unit tests next to the code they test** — in the same package directory, in a `_test.go` file +- **Do NOT place new tests in `test/integration/`** — this is a legacy directory. New unit tests go alongside the code under test. New integration-style tests that require a cluster should use `test/e2e/` or `test/envtest/` ## Quick Checklist