samber avatar

Golang Stretchr Testify

A comprehensive reference for writing tests with stretchr/testify in Go. Covers the assert versus require distinction (when to stop on failure versus collect all errors), the full assertion API including Eventually and JSONEq, mock setup with argument matchers and call verification, and the suite lifecycle for shared test fixtures. Written as executable specifications rather than coverage chasing. The skill includes gotests integration for scaffolding and warns about common pitfalls like forgetting AssertExpectations or using assert where require would prevent nil panics. Useful anytime you're writing Go tests that import testify, setting up mocks, or deciding between assertion styles. Pairs well with testifylint to catch argument order mistakes.

skills.sh installs
40.9K
GitHub stars
3.8K
last updated
Aug 21, 2026

Install

$ npx -y skills add samber/cc-skills-golang --skill golang-stretchr-testify --agent claude-code

Installs into .claude/skills of the current project.

Files

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.

Modes:

  • Write mode — adding new tests or mocks to a codebase.
  • Review mode — auditing existing test code for testify misuse.

stretchr/testify

testify complements Go's testing package with readable assertions, mocks, and suites. It does not replace testing — always use *testing.T as the entry point.

This skill is not exhaustive — refer to library documentation and code examples for more information:

  • 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.
  • To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See samber/cc-skills-golang@golang-gopls skill (gopls).
  • Context7 remains a fallback for docs not indexed on pkg.go.dev.

assert vs require

Both offer identical assertions. The difference is failure behavior:

Sponsors

Details

Repository
github.com/samber/cc-skills-golang
Categories
Testing & QA, Git & Pull Requests, Documentation, Go
First seen
Apr 16, 2026

More from samber/cc-skills-golang

All 47
1samber avatargolang-continuous-integrationsamber/cc-skills-golangCI/CD pipeline configuration using GitHub Actions for Golang projects — testing, linting, SAST, security scanning, code coverage, Dependabot, Renovate, GoReleas40.9Kskills.sh installs
2shadcn avatarimproveshadcn/improveSurvey any codebase as a senior advisor and produce prioritized, self-contained implementation plans for OTHER models/agents to execute. Strictly read-only on s40Kskills.sh installs
3neondatabase avatarneon-postgres-branchesneondatabase/agent-skillsChoose and create the right Neon branch type for testing and development. Use when users ask about Neon branching, migration testing with real data, isolated te37.3Kskills.sh installs
4clerk avatarclerk-cliclerk/skillsOperate the Clerk CLI (`clerk` binary) for authentication, user/org/session management, impersonation, local webhook testing, deploy verification, instance conf35.8Kskills.sh installs
5vercel avatarnext-cache-components-optimizervercel/next.jsDrive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navig20.6Kskills.sh installs
6citrolabs avatarego-browsercitrolabs/ego-liteego-browser (ego-lite) is a Chromium-based browser designed from the ground up to be friendly to both human users and AI Agents. AI Agents work in their own iso16.3Kskills.sh installs