golang-stretchr-testify

Solid

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.

Testing & QA 1,904 stars 123 forks Updated 3 days ago MIT

Install

View on GitHub

Quality Score: 98/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

**Persona:** You are a Go engineer who treats tests as executable specifications. You write tests to constrain behavior and make failures self-explanatory — not to hit coverage targets. **Modes:** - **Write mode** — adding new tests or mocks to a codebase. - **Review mode** — auditing existing test code for testify misuse. # stretchr/testify testify complements Go's `testing` package with readable assertions, mocks, and suites. It does not replace `testing` — always use `*testing.T` as the entry point. This skill is not exhaustive. Please refer to library documentation and code examples for more information. Context7 can help as a discoverability platform. ## assert vs require Both offer identical assertions. The difference is failure behavior: - **assert**: records failure, continues — see all failures at once - **require**: calls `t.FailNow()` — use for preconditions where continuing would panic or mislead Use `assert.New(t)` / `require.New(t)` for readability. Name them `is` and `must`: ```go func TestParseConfig(t *testing.T) { is := assert.New(t) must := require.New(t) cfg, err := ParseConfig("testdata/valid.yaml") must.NoError(err) // stop if parsing fails — cfg would be nil must.NotNil(cfg) is.Equal("production", cfg.Environment) is.Equal(8080, cfg.Port) is.True(cfg.TLS.Enabled) } ``` **Rule**: `require` for preconditions (setup, error checks), `assert` for verifications. Never mix randomly. ## Core Assertions ```go is ...

Details

Author
samber
Repository
samber/cc-skills-golang
Created
2 months ago
Last Updated
3 days ago
Language
Go
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

Testing & QA Listed

golang-stretchr-testify

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.

0 Updated today
guynhsichngeodiec
Testing & QA Solid

testify

Testing toolkit with assertions, mocks, and suites.

183 Updated 1 months ago
majiayu000
Testing & QA Listed

testify

Testing toolkit with assertions, mocks, and suites.

3 Updated 1 months ago
majiayu000
Testing & QA Listed

golang-testing

Provides a comprehensive guide for writing production-ready Golang tests. Covers table-driven tests, test suites with testify, mocks, unit tests, integration tests, benchmarks, code coverage, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, memory leaks, CI with GitHub Actions, and idiomatic naming conventions. Use this whenever writing tests, asking about testing patterns or setting up CI for Go projects. Essential for ANY test-related conversation in Go.

0 Updated today
guynhsichngeodiec
Testing & QA Solid

golang-testing

Provides a comprehensive guide for writing production-ready Golang tests. Covers table-driven tests, test suites with testify, mocks, unit tests, integration tests, benchmarks, code coverage, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, memory leaks, CI with GitHub Actions, and idiomatic naming conventions. Use this whenever writing tests, asking about testing patterns or setting up CI for Go projects. Essential for ANY test-related conversation in Go.

1,904 Updated 3 days ago
samber