golang-stretchr-testify

golang stretchr testify

samber ↓ 33k
Claude Code
View source ↗

What it does

  • Write mode — adding new tests or mocks to a codebase.
  • Review mode — auditing existing test code for testify misuse.
  • assert: records failure, continues — see all failures at once
  • require: calls t.FailNow() — use for preconditions where continuing would panic or mislead
  • Forgetting AssertExpectations(t) — mock expectations silently pass without verification
  • is.Equal(ErrNotFound, err) — fails on wrapped errors. Use is.ErrorIs to walk the chain
  • Swapped argument order — testify assumes (expected, actual). Swapping produces backwards diffs

Requirements & configuration

  • assert vs require
  • require: calls t.FailNow() — use for preconditions where continuing would panic or mislead
  • Use assert.New(t) / require.New(t) for readability. Name them is and must:
  • must := require.New(t)
  • Rule: require for preconditions (setup, error checks), assert for verifications. Never mix randomly.

Derived from the skill's own SKILL.md documentation · extracted 2026-07-23

golang stretchr testify

Source

Repository: https://github.com/samber/cc-skills-golang

golang-stretchr-testify FAQ

What does the golang-stretchr-testify skill do?

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. Write mode — adding new tests or mocks to a codebase. Review mode — auditing existing test code for testify misuse.

What does golang-stretchr-testify require?

assert vs require require: calls t.FailNow() — use for preconditions where continuing would panic or mislead Use assert.New(t) / require.New(t) for readability. Name them is and must: must := require.New(t) Rule: require for preconditions (setup, error checks), assert for verifications. Never mix randomly.

How do I install golang-stretchr-testify?

Run: npx -y skills add https://github.com/samber/cc-skills-golang --skill golang-stretchr-testify --agent claude-code — the source lives at github.com/samber/cc-skills-golang.

Maintain golang-stretchr-testify?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

golang-stretchr-testify on getagentictools
[![golang-stretchr-testify on getagentictools](https://getagentictools.com/badge/skills/samber-cc-skills-golang-golang-stretchr-testify.svg)](https://getagentictools.com/skills/samber-cc-skills-golang-golang-stretchr-testify?ref=badge)
npx agentictools info skills/samber-cc-skills-golang-golang-stretchr-testify

The second line is the CLI lookup for this page — handy in READMEs and docs.