Go Testing Compatibility: Diff examples may use . Resource Routing - - Run when generating a table-driven test scaffold. - - Use as a copyable table-test starting point. - - Read when choosing table tests, subtests, or parallel test patterns. - - Read when writing helpers, fixtures, cleanup, or test doubles. - - Read when structuring packages, black-box tests, or larger test suites. - - Read when choosing , , , or assertion style. - - Read when testing external services, HTTP handlers, databases, or long-running setup. Quick Reference | Pattern | Use When | |---------|----------| | | Default…

\\t'/\\\\t}\"\n s=\"${s//

Go Testing Compatibility: Diff examples may use . Resource Routing - - Run when generating a table-driven test scaffold. - - Use as a copyable table-test starting point. - - Read when choosing table tests, subtests, or parallel test patterns. - - Read when writing helpers, fixtures, cleanup, or test doubles. - - Read when structuring packages, black-box tests, or larger test suites. - - Read when choosing , , , or assertion style. - - Read when testing external services, HTTP handlers, databases, or long-running setup. Quick Reference | Pattern | Use When | |---------|----------| | | Default…

\\r'/}\"\n s=\"${s//

Go Testing Compatibility: Diff examples may use . Resource Routing - - Run when generating a table-driven test scaffold. - - Use as a copyable table-test starting point. - - Read when choosing table tests, subtests, or parallel test patterns. - - Read when writing helpers, fixtures, cleanup, or test doubles. - - Read when structuring packages, black-box tests, or larger test suites. - - Read when choosing , , , or assertion style. - - Read when testing external services, HTTP handlers, databases, or long-running setup. Quick Reference | Pattern | Use When | |---------|----------| | | Default…

\\n'/\\\\n}\"\n printf '%s' \"$s\"\n}\n\nOUTPUT=\"\"\nPARALLEL=false\nJSON_OUTPUT=false\nFORCE=false\nPOSITIONAL=()\n\nwhile [[ $# -gt 0 ]]; do\n case \"$1\" in\n -h|--help) usage; exit 0 ;;\n -v|--version) echo \"$SCRIPT_NAME v$VERSION\"; exit 0 ;;\n --output) OUTPUT=\"${2:?error: --output requires a file path}\"; shift 2 ;;\n --force) FORCE=true; shift ;;\n --parallel) PARALLEL=true; shift ;;\n --json) JSON_OUTPUT=true; shift ;;\n -*) echo \"error: unknown option: $1\" >&2; usage >&2; exit 2 ;;\n *) POSITIONAL+=(\"$1\"); shift ;;\n esac\ndone\n\nif [[ ${#POSITIONAL[@]} -lt 2 ]]; then\n echo \"error: FuncName and package are required\" >&2\n usage >&2\n exit 2\nfi\n\nFUNC=\"${POSITIONAL[0]}\"\nPKG=\"${POSITIONAL[1]}\"\n\nif [[ ! \"$FUNC\" =~ ^[A-Z][A-Za-z0-9_]*$ ]]; then\n echo \"error: FuncName '$FUNC' must be an exported Go identifier\" >&2\n exit 2\nfi\n\nif [[ ! \"$PKG\" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then\n echo \"error: package '$PKG' must be a valid Go package identifier\" >&2\n exit 2\nfi\n\ncase \"$PKG\" in\n _|break|default|func|interface|select|case|defer|go|map|struct|chan|else|goto|package|switch|const|fallthrough|if|range|type|continue|for|import|return|var)\n echo \"error: package '$PKG' must not be a Go keyword or blank identifier\" >&2\n exit 2\n ;;\nesac\n\ngenerate_test() {\n local parallel_top=\"\" parallel_sub=\"\"\n if $PARALLEL; then\n parallel_top=

Go Testing Compatibility: Diff examples may use . Resource Routing - - Run when generating a table-driven test scaffold. - - Use as a copyable table-test starting point. - - Read when choosing table tests, subtests, or parallel test patterns. - - Read when writing helpers, fixtures, cleanup, or test doubles. - - Read when structuring packages, black-box tests, or larger test suites. - - Read when choosing , , , or assertion style. - - Read when testing external services, HTTP handlers, databases, or long-running setup. Quick Reference | Pattern | Use When | |---------|----------| | | Default…

\\tt.Parallel()\\n'\n parallel_sub=

Go Testing Compatibility: Diff examples may use . Resource Routing - - Run when generating a table-driven test scaffold. - - Use as a copyable table-test starting point. - - Read when choosing table tests, subtests, or parallel test patterns. - - Read when writing helpers, fixtures, cleanup, or test doubles. - - Read when structuring packages, black-box tests, or larger test suites. - - Read when choosing , , , or assertion style. - - Read when testing external services, HTTP handlers, databases, or long-running setup. Quick Reference | Pattern | Use When | |---------|----------| | | Default…

\\t\\t\\tt.Parallel()\\n'\n fi\n\n cat \u003c\u003cEOF\npackage ${PKG}\n\nimport (\n\t\"testing\"\n)\n\nfunc Test${FUNC}(t *testing.T) {\n${parallel_top}\ttests := []struct {\n\t\tname string\n\t\tgive string // TODO: replace with actual input type\n\t\twant string // TODO: replace with actual output type\n\t}{\n\t\t{\n\t\t\tname: \"basic case\",\n\t\t\tgive: \"\",\n\t\t\twant: \"\",\n\t\t},\n\t\t// TODO: add more test cases\n\t}\n\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n${parallel_sub}\t\t\tgot := ${FUNC}(tt.give)\n\t\t\tif got != tt.want {\n\t\t\t\tt.Errorf(\"${FUNC}(%q) = %q, want %q\", tt.give, got, tt.want)\n\t\t\t}\n\t\t\t// For richer diffs, consider:\n\t\t\t// if diff := cmp.Diff(tt.want, got); diff != \"\" {\n\t\t\t// t.Errorf(\"${FUNC}() mismatch (-want +got):\\n%s\", diff)\n\t\t\t// }\n\t\t})\n\t}\n}\nEOF\n}\n\nif [[ -n \"$OUTPUT\" ]]; then\n OUTPUT_DIR=\"$(dirname \"$OUTPUT\")\"\n if [[ ! -d \"$OUTPUT_DIR\" ]]; then\n echo \"error: directory '$OUTPUT_DIR' does not exist\" >&2\n exit 2\n fi\n if [[ -f \"$OUTPUT\" ]] && ! $FORCE; then\n echo \"error: '$OUTPUT' already exists (use --force to overwrite)\" >&2\n exit 2\n fi\n generate_test > \"$OUTPUT\"\n if $JSON_OUTPUT; then\n FUNC_ESC=\"$(json_escape \"$FUNC\")\"\n PKG_ESC=\"$(json_escape \"$PKG\")\"\n OUTPUT_ESC=\"$(json_escape \"$OUTPUT\")\"\n cat \u003c\u003cEOF\n{\"func\":\"$FUNC_ESC\",\"package\":\"$PKG_ESC\",\"output_file\":\"$OUTPUT_ESC\",\"parallel\":$PARALLEL,\"written\":true}\nEOF\n else\n echo \"Wrote test scaffold to $OUTPUT\"\n fi\nelse\n if $JSON_OUTPUT; then\n generate_test >&2\n FUNC_ESC=\"$(json_escape \"$FUNC\")\"\n PKG_ESC=\"$(json_escape \"$PKG\")\"\n cat \u003c\u003cEOF\n{\"func\":\"$FUNC_ESC\",\"package\":\"$PKG_ESC\",\"output_file\":\"\",\"parallel\":$PARALLEL,\"written\":false}\nEOF\n else\n generate_test\n fi\nfi\n\nexit 0\n","content_type":"application/x-sh; charset=utf-8","language":"bash","size":4798,"content_sha256":"c6c93a95a23546c001509317b75ce038f7bc4f904bbd170f5b60ba85dbf181a7"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"Go Testing","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Compatibility: Diff examples may use ","type":"text"},{"text":"github.com/google/go-cmp","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Resource Routing","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"scripts/gen-table-test.sh","type":"text","marks":[{"type":"code_inline"}]},{"text":" - Run when generating a table-driven test scaffold.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"assets/table-test-template.go","type":"text","marks":[{"type":"code_inline"}]},{"text":" - Use as a copyable table-test starting point.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"references/TABLE-DRIVEN-TESTS.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" - Read when choosing table tests, subtests, or parallel test patterns.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"references/TEST-HELPERS.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" - Read when writing helpers, fixtures, cleanup, or test doubles.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"references/TEST-ORGANIZATION.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" - Read when structuring packages, black-box tests, or larger test suites.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"references/VALIDATION-APIS.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" - Read when choosing ","type":"text"},{"text":"t.Error","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"t.Fatal","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"cmp.Diff","type":"text","marks":[{"type":"code_inline"}]},{"text":", or assertion style.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"references/INTEGRATION.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" - Read when testing external services, HTTP handlers, databases, or long-running setup.","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Quick Reference","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Pattern","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Use When","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"t.Error","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Default — report failure, keep running","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"t.Fatal","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Setup failed or continuing is meaningless","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"cmp.Diff","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Comparing structs, slices, maps, protos","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Table-driven","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Many cases share identical logic","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Subtests","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Need filtering, parallel execution, or naming","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"t.Helper()","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Any test helper function (call as first statement)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"t.Cleanup()","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Teardown in helpers instead of defer","type":"text"}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Useful Test Failures","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Normative","type":"text","marks":[{"type":"strong"}]},{"text":": Test failures must be diagnosable without reading the test source.","type":"text"}]}]},{"type":"paragraph","content":[{"text":"Every failure message must include: function name, inputs, actual (got), and expected (want). Use the format ","type":"text"},{"text":"YourFunc(%v) = %v, want %v","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"go"},"content":[{"text":"// Good:\nt.Errorf(\"Add(2, 3) = %d, want %d\", got, 5)\n\n// Bad: Missing function name and inputs\nt.Errorf(\"got %d, want %d\", got, 5)","type":"text"}]},{"type":"paragraph","content":[{"text":"Always print got before want: ","type":"text"},{"text":"got %v, want %v","type":"text","marks":[{"type":"code_inline"}]},{"text":" — never reversed.","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"No Assertion Libraries","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Normative","type":"text","marks":[{"type":"strong"}]},{"text":": Do not use assertion libraries. Use ","type":"text"},{"text":"cmp.Diff","type":"text","marks":[{"type":"code_inline"}]},{"text":" for complex comparisons.","type":"text"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":"go"},"content":[{"text":"if diff := cmp.Diff(want, got); diff != \"\" {\n t.Errorf(\"GetPost() mismatch (-want +got):\\n%s\", diff)\n}","type":"text"}]},{"type":"paragraph","content":[{"text":"For protocol buffers, add ","type":"text"},{"text":"protocmp.Transform()","type":"text","marks":[{"type":"code_inline"}]},{"text":" as a cmp option. Always include the direction key ","type":"text"},{"text":"(-want +got)","type":"text","marks":[{"type":"code_inline"}]},{"text":" in diff messages. Avoid comparing JSON/serialized output — compare semantically instead.","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"t.Error vs t.Fatal","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Normative","type":"text","marks":[{"type":"strong"}]},{"text":": Use ","type":"text"},{"text":"t.Error","type":"text","marks":[{"type":"code_inline"}]},{"text":" by default to report all failures in one run. Use ","type":"text"},{"text":"t.Fatal","type":"text","marks":[{"type":"code_inline"}]},{"text":" only when continuing is impossible.","type":"text"}]}]},{"type":"paragraph","content":[{"text":"Choose ","type":"text","marks":[{"type":"strong"}]},{"text":"t.Fatal","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" when:","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Setup fails (DB connection, file load)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"The next assertion depends on the previous one succeeding (e.g., decode after encode)","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"Never call ","type":"text","marks":[{"type":"strong"}]},{"text":"t.Fatal","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":"/","type":"text","marks":[{"type":"strong"}]},{"text":"t.FailNow","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" from a goroutine","type":"text","marks":[{"type":"strong"}]},{"text":" other than the test goroutine — use ","type":"text"},{"text":"t.Error","type":"text","marks":[{"type":"code_inline"}]},{"text":" instead.","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Table-Driven Tests","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"See ","type":"text"},{"text":"assets/table-test-template.go","type":"text","marks":[{"type":"code_inline"}]},{"text":" when scaffolding a new table-driven test and need the canonical struct, loop, and subtest layout.","type":"text"}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Advisory","type":"text","marks":[{"type":"strong"}]},{"text":": Use table-driven tests when many cases share identical logic.","type":"text"}]}]},{"type":"paragraph","content":[{"text":"Use table tests when:","type":"text","marks":[{"type":"strong"}]},{"text":" all cases run the same code path with no conditional setup, mocking, or assertions. A single ","type":"text"},{"text":"shouldErr","type":"text","marks":[{"type":"code_inline"}]},{"text":" bool is acceptable.","type":"text"}]},{"type":"paragraph","content":[{"text":"Don't use table tests when:","type":"text","marks":[{"type":"strong"}]},{"text":" cases need complex setup, conditional mocking, or multiple branches — write separate test functions instead.","type":"text"}]},{"type":"paragraph","content":[{"text":"Key rules:","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use field names when cases span many lines or have same-type adjacent fields","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Include inputs in failure messages — never identify rows by index","type":"text"}]}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Validation","type":"text","marks":[{"type":"strong"}]},{"text":": After generating or modifying tests, run ","type":"text"},{"text":"go test -run TestXxx -v","type":"text","marks":[{"type":"code_inline"}]},{"text":" to verify the tests compile and pass. Fix any compilation errors before proceeding.","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Test Helpers","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Normative","type":"text","marks":[{"type":"strong"}]},{"text":": Test helpers must call ","type":"text"},{"text":"t.Helper()","type":"text","marks":[{"type":"code_inline"}]},{"text":" first and use ","type":"text"},{"text":"t.Cleanup()","type":"text","marks":[{"type":"code_inline"}]},{"text":" for teardown.","type":"text"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":"go"},"content":[{"text":"func setupTestDB(t *testing.T) *sql.DB {\n t.Helper()\n db, err := sql.Open(\"sqlite3\", \":memory:\")\n if err != nil {\n t.Fatalf(\"Could not open database: %v\", err)\n }\n t.Cleanup(func() { db.Close() })\n return db\n}","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Test Error Semantics","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Advisory","type":"text","marks":[{"type":"strong"}]},{"text":": Test error semantics, not error message strings.","type":"text"}]}]},{"type":"code_block","attrs":{"wrap":false,"language":"go"},"content":[{"text":"// Bad: Brittle string comparison\nif err.Error() != \"invalid input\" { ... }\n\n// Good: Semantic check\nif !errors.Is(err, ErrInvalidInput) { ... }","type":"text"}]},{"type":"paragraph","content":[{"text":"For simple presence checks when specific semantics don't matter:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"go"},"content":[{"text":"if gotErr := err != nil; gotErr != tt.wantErr {\n t.Errorf(\"f(%v) error = %v, want error presence = %t\", tt.input, err, tt.wantErr)\n}","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Related Skills","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Error testing","type":"text","marks":[{"type":"strong"}]},{"text":": See ","type":"text"},{"text":"go-error-handling","type":"text","marks":[{"type":"link","attrs":{"href":"../go-error-handling/SKILL.md","title":null}}]},{"text":" when testing error semantics with ","type":"text"},{"text":"errors.Is","type":"text","marks":[{"type":"code_inline"}]},{"text":"/","type":"text"},{"text":"errors.As","type":"text","marks":[{"type":"code_inline"}]},{"text":" or sentinel errors","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Interface mocking","type":"text","marks":[{"type":"strong"}]},{"text":": See ","type":"text"},{"text":"go-interfaces","type":"text","marks":[{"type":"link","attrs":{"href":"../go-interfaces/SKILL.md","title":null}}]},{"text":" when creating test doubles by implementing interfaces at the consumer side","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Naming test functions","type":"text","marks":[{"type":"strong"}]},{"text":": See ","type":"text"},{"text":"go-naming","type":"text","marks":[{"type":"link","attrs":{"href":"../go-naming/SKILL.md","title":null}}]},{"text":" when naming test functions, subtests, or test helper utilities","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Linter integration","type":"text","marks":[{"type":"strong"}]},{"text":": See ","type":"text"},{"text":"go-linting","type":"text","marks":[{"type":"link","attrs":{"href":"../go-linting/SKILL.md","title":null}}]},{"text":" when running linters alongside tests in CI or pre-commit hooks","type":"text"}]}]}]}]},"metadata":{"date":"2026-11-02","name":"go-testing","author":"@skillopedia","source":{"stars":188,"repo_name":"golang-skills","origin_url":"https://github.com/cxuu/golang-skills/blob/HEAD/skills/go-testing/SKILL.md","repo_owner":"cxuu","body_sha256":"ffb89933de7a5c75d09c97f633221c8f1b85f75f8c81944194cf0fb31e638f93","cluster_key":"038080a8c8e86953e10bf9d527bf1760ec416567c6bafc1cf6c0a861c9507c08","clean_bundle":{"format":"clean-skill-bundle-v1","source":"cxuu/golang-skills/skills/go-testing/SKILL.md","text_bytes":25392,"source_commit":"91f0c2eef559a3168f9d3c38f5f99936d472b508","skills_sh_rank":10449,"attachment_count":7,"text_attachments":7,"attachment_storage":"skill_attachments","binary_attachments":0},"cluster_size":1,"skill_md_path":"skills/go-testing/SKILL.md","import_metadata":{"date":"2026-11-02","author":"@skillopedia","version":"v1","category":"testing-qa","category_label":"Testing"},"exact_dupes_collapsed_into_this":0},"version":"v1","category":"testing-qa","import_tag":"skills-sh-top20k-2026-11","description":"Use when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff. Also use when a user asks to write a test for a Go function, even if they don't mention specific patterns like table-driven tests or subtests. Does not cover benchmark performance testing (see go-performance).","allowed-tools":"Bash(bash:*)"}},"renderedAt":1793661622916}

Go Testing Compatibility: Diff examples may use . Resource Routing - - Run when generating a table-driven test scaffold. - - Use as a copyable table-test starting point. - - Read when choosing table tests, subtests, or parallel test patterns. - - Read when writing helpers, fixtures, cleanup, or test doubles. - - Read when structuring packages, black-box tests, or larger test suites. - - Read when choosing , , , or assertion style. - - Read when testing external services, HTTP handlers, databases, or long-running setup. Quick Reference | Pattern | Use When | |---------|----------| | | Default…