Skip to content
Agentmart
Submit a tool

go-table-tests

Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.

Skill by UnicoLab

IndexedMIT★ 1
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/unicolab-go-table-tests

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.

Use cases: writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/go-table-tests

What's inside

Skill name
go-table-tests
Description
Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.
License
MIT
Instructions
64 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Table-driven tests in Go

The shape the standard library uses. Deviating from it makes a reviewer slower,
not the test better.

```go
func TestParse(t *testing.T) {
	tests := []struct {
		name    string
		in      string
		want    Config
		wantErr string // substring; "" means no error
	}{
		{name: "empty", in: "", wantErr: "empty input"},
		{name: "ok", in: "a=1", want: Config{A: 1}},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, err := Parse(tt.in)
			if tt.wantErr != "" {
				if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
					t.Fatalf("err = %v, want containing %q", err, tt.wantErr)
				}
				return
			}
			if err != nil {
				t.Fatalf("Parse(%q): %v", tt.in, err)
			}
			if got != tt.want {
				t.Errorf("Parse(%q) = %+v, want %+v", tt.in, got, tt.want)
			}
		})
	}
}
```

## Rules that matter

- **Name every case.** `t.Run(tt.name, …)` makes `go test -run TestParse/ok`
  work and puts the case name in the failure line.
- **`t.Fatalf` when the test cannot continue** (setup failed, err when none was
  wanted); **`t.Errorf` when it can** — an Errorf keeps checking the rest of the
  case and reports more per run.
- **Failure messages state input, got and want**, in that order:
  `t.Errorf("Sum(%v) = %d, want %d", in, got, want)`. "test failed" tells the
  next reader nothing.
- **`t.Helper()`** as the first line of any assertion helper, or failures point
  at the helper instead of the caller.
- **`t.Cleanup(fn)`** over `defer` in helpers — it runs after subtests finish.
- **`t.TempDir()`** for files; it is removed automatically. Never write into the
  repo from a test.
- **`t.Parallel()`** goes in BOTH the parent and each subtest, and the loop
  variable must not be captured across it in Go < 1.22.
- **Compare with `==` for comparable structs**, `slices.Equal`/`maps.Equal` for
  slices and maps, `cmp.Diff` when the project already uses go-cmp.
  `reflect.DeepEqual` treats a nil slice and an empty slice as different and
  gives a useless diff.
- **Errors:** compare with `errors.Is(err, ErrClosed)` for sentinels and
  `errors.As(err, &target)` for typed errors. String matching on an error
  message is a test of the message, not of the behaviour.
- A test with no assertion is not a test. Neither is one that only checks that
  a function did not panic, unless not panicking is the documented contract.

From UnicoLab/smlcode, MIT.

More from UnicoLab/smlcode

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
Aug 23, 2026 (2 months ago)
Last release
Oct 20, 2026 (8 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from UnicoLab

Cite this page

go-table-tests skill. Agent Mart. https://agentmart.dev/skills/unicolab-go-table-tests (last updated 2026-10-24)