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.
87
86%
Does it follow best practices?
Impact
91%
1.59xAverage score across 3 eval scenarios
Passed
No findings from the security scan
JSON comparison and mock Unset in Go tests
JSONEq for JSON output
100%
100%
No string equal for JSON
100%
100%
Struct pointer not compared by address
100%
100%
EqualExportedValues or dereference
53%
100%
Unset() used
0%
0%
Different return after Unset
50%
0%
mock.AnythingOfType used
100%
100%
AssertExpectations called
100%
100%
is/must naming
0%
100%
Mock side effects and detailed call verification
m.Called() in Record mock
100%
100%
m.Called() in Flush mock
100%
100%
.Run() argument capture
100%
100%
Captured field assertion
66%
100%
AssertNotCalled for Flush
100%
100%
Call count verification
100%
100%
Large-batch Flush verification
100%
100%
AssertExpectations present
0%
100%
mock.Anything for context
0%
100%
Testify assertion method selection
ElementsMatch for tags
0%
100%
InDelta for Mean
33%
100%
InDelta for StdDev
33%
100%
Regexp for JobID
53%
100%
WithinDuration for ComputedAt
33%
100%
ErrorContains for empty input
0%
100%
require for error precondition
50%
100%
4158351
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.