
Golang Stretchr Testify
Write Go tests with stretchr/testify using require for preconditions and assert for checks without panics or reversed Equal argument order.
Overview
Golang Stretchr Testify is an agent skill for the Ship phase that teaches correct assert versus require usage and naming patterns in Go testify tests.
Install
npx skills add https://github.com/samber/cc-skills-golang --skill golang-stretchr-testifyWhat is this skill?
- require for preconditions (NoError, NotNil) to avoid nil-pointer panics on follow-up asserts
- assert for value verifications after preconditions pass
- Naming convention: is from assert.New(t) and must from require.New(t) for readability
- Equal and similar helpers with (expected, actual) argument order called out explicitly
- Eval scenarios include 5+ assertion criteria per testify precondition case
- Covers both assert.New(is) and require.New(must) naming convention
Adoption & trust: 3.6k installs on skills.sh; 2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Go tests use assert on parse errors and nil configs, so failures panic instead of failing cleanly, or Equal compares arguments in the wrong order.
Who is it for?
Solo Go developers who rely on testify and want agents to stop producing brittle tests that panic on setup failures.
Skip if: Projects using only the standard library testing package without testify, or teams that want pure property-based testing without assertion libraries.
When should I use this skill?
Writing or fixing Go tests that use stretchr/testify, especially when setup must fail fast with require before value asserts.
What do I get? / Deliverables
Generated tests follow testify preconditions with require, verifications with assert, and readable is or must helpers with correct expected or actual ordering.
- Testify-idiomatic Go test functions
- Correct require or assert split for setup versus verification
Recommended Skills
Journey fit
Testify conventions are applied when you are shipping quality gates through unit and integration tests in Go services or CLIs. Assert versus require discipline and naming helpers are testing-phase craft, not feature implementation in Build.
How it compares
Opinionated testify style guide—not a test runner, coverage tool, or CI pipeline skill.
Common Questions / FAQ
Who is golang-stretchr-testify for?
Go builders writing unit tests with stretchr/testify who want safer precondition checks and consistent assertion style from coding agents.
When should I use golang-stretchr-testify?
In Ship (testing) when authoring or reviewing Go tests that parse JSON, load config, or chain multiple Equal assertions after setup.
Is golang-stretchr-testify safe to install?
It is test-pattern guidance without network calls; review the Security Audits panel on this Prism page before adding the skill repo to your agent.
SKILL.md
READMESKILL.md - Golang Stretchr Testify
[ { "id": 1, "name": "assert-vs-require-precondition", "description": "Tests whether the model uses require for preconditions and assert for verifications, not mixing them randomly", "prompt": "Write a Go test using testify that parses a JSON config file, checks it has no error, verifies the config is not nil, then checks that config.Port equals 8080, config.Host equals 'localhost', and config.Debug is false.", "trap": "Model may use assert for the error check and nil check (preconditions), which would cause a nil pointer panic on subsequent assertions if parsing fails", "assertions": [ {"id": "1.1", "text": "Uses require (not assert) for the NoError check on parsing"}, {"id": "1.2", "text": "Uses require (not assert) for the NotNil check on config"}, {"id": "1.3", "text": "Uses assert for the subsequent value checks (Port, Host, Debug)"}, {"id": "1.4", "text": "Does NOT use require for all assertions indiscriminately"}, {"id": "1.5", "text": "Argument order is (expected, actual) not (actual, expected) for Equal calls"} ] }, { "id": 2, "name": "assert-new-naming-convention", "description": "Tests the skill's specific naming convention: 'is' for assert.New(t) and 'must' for require.New(t)", "prompt": "I'm writing Go tests with testify and I find the repeated 't' parameter verbose. How can I make my assertions more readable? Show me an example with both assert and require.", "trap": "Model may use generic variable names like 'a' and 'r', or 'assertions' and 'requirements' instead of the skill's recommended 'is' and 'must' convention", "assertions": [ {"id": "2.1", "text": "Uses assert.New(t) to create a reusable assertion object"}, {"id": "2.2", "text": "Uses require.New(t) to create a reusable require object"}, {"id": "2.3", "text": "Names the assert.New(t) variable 'is'"}, {"id": "2.4", "text": "Names the require.New(t) variable 'must'"}, {"id": "2.5", "text": "Shows the 'is' and 'must' variables being used for different purposes (preconditions vs verifications)"} ] }, { "id": 3, "name": "error-chain-assertion", "description": "Tests knowledge that is.Equal(ErrNotFound, err) fails on wrapped errors and ErrorIs should be used instead", "prompt": "I have a Go function that returns wrapped errors using fmt.Errorf with %w. Write a test that checks whether the returned error is ErrNotFound. The function signature is: func FindUser(id string) (*User, error)", "trap": "Model may use assert.Equal(ErrNotFound, err) which fails on wrapped errors instead of assert.ErrorIs", "assertions": [ {"id": "3.1", "text": "Uses ErrorIs (not Equal) to check the error against ErrNotFound"}, {"id": "3.2", "text": "Does NOT use assert.Equal or is.Equal to compare errors directly"}, {"id": "3.3", "text": "Uses require for the initial error existence check if subsequent assertions depend on it"}, {"id": "3.4", "text": "Argument order for ErrorIs is (err, target) not (target, err)"} ] }, { "id": 4, "name": "mock-assert-expectations", "description": "Tests whether AssertExpectations is called — without it, mock expectations silently pass", "prompt": "Create a Go test using testify/mock for a NotificationService that calls a Sender.Send method. The test should verify that Send is called exactly once with the right email address.", "trap": "Model may set up On().Return() expectations but forget to call AssertExpectations(t), making the test pass even if Send is never called", "assertions": [ {"id": "4.1", "text": "Mock embeds mock.Mock"}, {"id": "4.2", "text": "Mock method uses m.Called() to forward arguments"}, {"id": "4.3", "text": "Test calls m.AssertExpectations(t) to verify all expectations were met"}, {"id": "4.4", "text": "Uses .Once() or equivalent call modifier to enforce exactly one call"}, {"id": "4.5", "text": "Use