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.
88
89%
Does it follow best practices?
Impact
84%
1.37xAverage score across 3 eval scenarios
Passed
No known issues
Testify suite lifecycle and require syntax
Suite embeds suite.Suite
100%
100%
Launcher function present
100%
100%
SetupSuite for one-time init
100%
100%
SetupTest for per-test mocks
100%
100%
s.Require() for preconditions
100%
100%
Suite method naming
100%
100%
All three test cases present
100%
100%
is/must naming convention
100%
100%
AssertExpectations called
80%
80%
No assert for guards
100%
100%
suite.Run receives new(Suite)
100%
100%
Package compiles
100%
100%
Mock patterns: MatchedBy, retry .Once() chaining, AssertExpectations
Mock embeds mock.Mock
0%
100%
m.Called() in methods
0%
100%
AssertExpectations called
0%
100%
mock.MatchedBy for AuditEntry
0%
100%
Predicate checks Amount
37%
100%
Predicate checks Status
37%
100%
Chained .Once() for retry
0%
100%
Retry call count verified
80%
100%
mock.Anything for context
0%
100%
No exact AuditEntry equality
100%
100%
.Once() or .Times() used
0%
100%
Advanced assertions: JSONEq, ElementsMatch, InDelta, ErrorIs, EventuallyWithT
JSONEq for JSON comparison
100%
100%
No string equal for JSON
100%
100%
ElementsMatch for unordered slice
0%
0%
InDelta for float tolerance
100%
100%
ErrorIs for wrapped error
100%
100%
No Equal for error check
100%
100%
Pointer not compared with Equal
50%
0%
EventuallyWithT for async
0%
0%
Multiple assertions in callback
0%
0%
No Eventually without T
100%
0%
require for preconditions
100%
100%
is/must naming
100%
100%
8c7e016
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.