Comprehensive guide to stretchr/testify for Golang testing. Covers assert, require, mock, and suite packages in depth. Use whenever writing tests with testify, creating mocks, setting up test suites, or choosing between assert and require. Essential for testify assertions, mock expectations, argument matchers, call verification, suite lifecycle, and advanced patterns like Eventually, JSONEq, and custom matchers. Trigger on any Go test file importing testify.
87
89%
Does it follow best practices?
Impact
77%
1.67xAverage score across 3 eval scenarios
Passed
No known issues
Mock setup, matchers, and retry sequences
Mock embeds mock.Mock
0%
100%
m.Called() forwarding
0%
100%
mock.Anything usage
0%
100%
mock.AnythingOfType usage
0%
0%
mock.MatchedBy predicate
0%
100%
Retry: first call fails with .Once()
0%
100%
Retry: second call succeeds with .Once()
0%
100%
AssertExpectations called
0%
100%
Call count verification
30%
100%
Error assertions use NoError/ErrorIs
100%
100%
Test suite lifecycle and launcher
suite.Suite embedded
100%
100%
Launcher function present
100%
100%
SetupTest for per-test init
100%
100%
SetupSuite for one-time setup
100%
100%
TearDown methods present
0%
0%
Test methods on suite receiver
100%
100%
s.Require() for preconditions
100%
100%
s.Equal/s.NoError for verifications
100%
100%
All original tests covered
100%
100%
No standalone test functions
0%
0%
Assert/require naming, async polling, wrapped errors
'is' naming for assert
0%
100%
'must' naming for require
0%
0%
require for error/nil preconditions
80%
70%
assert for value verifications
75%
87%
EventuallyWithT (not Eventually)
0%
0%
CollectT callback parameter
0%
0%
Multiple assertions in callback
0%
0%
ErrorIs for wrapped errors
41%
100%
Pointer-safe struct comparison
100%
100%
Correct argument order
100%
100%
e9761db
Table of Contents
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.