golang-stretchr-testify
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.
Security Assessment
Detected risks:
About golang-stretchr-testify
The golang-stretchr-testify skill provides comprehensive support for using the stretchr/testify library in Go, enhancing the native testing capabilities of the `testing` package. It addresses common challenges developers face when writing tests, such as creating readable assertions, managing mock objects, and organizing test suites. By offering structured guidance on assert vs require usage, it helps engineers write tests that clearly distinguish between critical preconditions and standard verifications, improving both test reliability and clarity. The skill ensures that users can adopt testify patterns effectively without disrupting existing test workflows.
FAQ
How do I choose between assert and require in testify?
Use `require` for preconditions where a test cannot continue safely, such as setup errors or nil checks. Use `assert` for standard verifications where you want to record failures but continue execution to see all assertion results.
Is this skill compatible with all Go projects?
It is designed for projects that import `github.com/stretchr/testify`. It complements the standard Go `testing` package and is compatible with AI coding agents like Claude Code.
What tools or dependencies are required to use this skill?
The skill requires the Go toolchain and optionally `gotests` for generating test scaffolding. It works best when the codebase follows standard Go testing conventions.
Can I use testify without this skill?
Yes, testify can be used directly. This skill provides structured guidance, best practices, and examples for assert, require, mocks, and test suites to make usage more effective and maintainable.
Does the skill cover all testify features?
The skill covers core and advanced assertions, mocks, suites, and key patterns like Eventually and JSONEq, but it is not exhaustive. Users should refer to the testify library documentation for full coverage.
Install golang-stretchr-testify
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
samber/cc-skills-golang