mockery-suite-tests

Featured

Use when writing Go tests that need mocks or cover multiple cases - generate mocks with Mockery v3 (never hand-written), and structure tests as table-driven testify suites

Testing & QA 91 stars 13 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 89/100

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

Skill Content

# Mockery v3 & Suite Tests (Go) ## Overview Go tests here follow three non-negotiables: mocks are **generated by Mockery v3** (never hand-written), multi-case tests are **table-driven**, and grouped tests use a **testify suite**. Hand-rolled mocks drift from the interface, table tests keep cases honest, and suites share setup without copy-paste. **Core principle:** You never hand-write a mock. If you typed `type mockFoo struct` in a test, delete it and generate it with Mockery v3. ## Mockery v3 — generate, don't hand-write - Mocks come from the port interfaces in `internal/port`, generated by Mockery v3. Configure once in `.mockery.yaml`; regenerate with `mockery` when an interface changes. - **Never** hand-write a mock struct, and **never** add test-only methods to a production type to make it mockable — depend on the port interface instead. - v3 generates an `expecter` API — use the typed `EXPECT()` methods, not raw `On("MethodName", ...)` string calls, so a renamed method breaks compilation instead of silently passing. ```go repo := mocks.NewTaskRepository(t) // generated constructor, auto-asserts on cleanup repo.EXPECT().Create(mock.Anything, task).Return(nil).Once() svc := NewTaskService(repo) ``` If the interface changes and you forgot to regenerate, the test won't compile — that is the point. ## Table-driven tests Every function with more than one case is a table. One row = one behavior with a descriptive name. ```go func (s *TaskServiceSuite) Test...

Details

Author
makifbaysal
Repository
makifbaysal/tasktrooper
Created
1 weeks ago
Last Updated
today
Language
Go
License
Apache-2.0

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.

12 Updated today
yzfly
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 yesterday
guynhsichngeodiec
Testing & QA Listed

golang-testing

Production-ready Golang tests — table-driven tests, testify suites and mocks, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, code coverage, integration tests, idiomatic test naming. Use when writing or reviewing Go tests, choosing a testing approach, setting up Go test CI, or debugging flaky/slow tests. For testify-specific APIs see `samber/cc-skills-golang@golang-stretchr-testify`; for measurement methodology see `samber/cc-skills-golang@golang-benchmark`.

2 Updated today
marcioaltoe