Tooluck logoTooluck
SKILL.md

golang-stretchr-testify

Agent skill fromsamber/cc-skills-golang

Comprehensive guide to stretchr/testify for Golang testing. Covers assert, require, mock, and suite packages in depth. Use when writing tests with testify, creating mocks, setting up test suites, or choosing between assert and require. Covers testify assertions, mock expectations, argument matchers, call verification, suite lifecycle, and advanced patterns like Eventually, JSONEq, and custom matchers. Apply when the codebase imports github.com/stretchr/testify.

How to install golang-stretchr-testify

install golang-stretchr-testify
# install the cc-skills-golang pack with the skills CLI
npx skills add samber/cc-skills-golang

# or add only this skill to Claude Code: copy the folder

skills/golang-stretchr-testify/

# into

~/.claude/skills/golang-stretchr-testify/ (all projects)

.claude/skills/golang-stretchr-testify/ (one project)

skills/golang-stretchr-testify/SKILL.md

MITFull file
1**Persona:** You are a Go engineer who treats tests as executable specifications. You write tests to constrain behavior and make failures self-explanatory — not to hit coverage targets.
2
3**Modes:**
4
5- **Write mode** — adding new tests or mocks to a codebase.
6- **Review mode** — auditing existing test code for testify misuse.
7
8# stretchr/testify
9
10testify complements Go's `testing` package with readable assertions, mocks, and suites. It does not replace `testing` — always use `*testing.T` as the entry point.
11
12This skill is not exhaustive — refer to library documentation and code examples for more information:
13
14- For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `samber/cc-skills-golang@golang-pkg-go-dev` skill (`godig`), preferred over Context7 for Go package facts.
15- To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `samber/cc-skills-golang@golang-gopls` skill (`gopls`).
16- Context7 remains a fallback for docs not indexed on pkg.go.dev.
17
18## assert vs require
19
20Both offer identical assertions. The difference is failure behavior:
21
22- **assert**: records failure, continues — see all failures at once
23- **require**: calls `t.FailNow()` — use for preconditions where continuing would panic or mislead
24
25Use `assert.New(t)` / `require.New(t)` for readability. Name them `is` and `must`:
26
27```go
28func TestParseConfig(t *testing.T) {
29 is := assert.New(t)
30 must := require.New(t)
31…

Excerpt shown under the repository's MIT license.

More skills in cc-skills-golang

Keep exploring

Similar skill repositories

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates