golang-stretchr-testify

Teaches stretchr/testify usage for assertions, mocking interfaces, and test suites in Go projects.

Updated Mar 29, 2026
One-click install
npx skills add https://github.com/osmanozen/go-commerce --skill golang-stretchr-testify-osmanozen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-stretchr-testify
Source: https://github.com/osmanozen/go-commerce/tree/main/.agents/skills/golang-stretchr-testify
Command: npx skills add https://github.com/osmanozen/go-commerce --skill golang-stretchr-testify-osmanozen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps Go developers write clear, maintainable tests by teaching how to use stretchr/testify for assertions, mocks, and suites.

Core Features & Use Cases

  • Assertions with assert/require for readable test failures
  • Mocking interfaces with testify/mock and verifying expectations
  • Test suites with testify/suite for shared setup and teardown
  • Best practices, argument order conventions, and error handling guidance
  • Practical examples across common testing scenarios in Go

Quick Start

Start by importing testify in your tests and follow the guide to choose assert vs require, create mocks, and organize suites.

Frequently Asked Questions about golang-stretchr-testify

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write clear and reliable tests in Go using testify?

To write clear Go tests with testify, use the assert and require packages for readable failure messages, mock for interface verification, and suite for shared setup and teardown. It integrates directly with the standard testing framework.

What is the difference between assert and require in Go testify?

In testify, assert allows a test to continue running after a failure, while require stops execution immediately. Choose require for critical preconditions and assert for collecting multiple non-fatal failures in your Go testing suite.

How do I mock interfaces in Golang with testify/mock?

Mock interfaces in Golang using testify/mock by creating a struct embedding mock.Mock, setting expected calls and arguments, and verifying expectations at the end of the test to ensure your code interacts correctly with dependencies.

Can I use testify test suites for shared setup and teardown in Go?

Yes, testify/suite lets you group Go tests into suites with shared setup and teardown logic. By embedding suite.Suite in your struct, you isolate common initialization and cleanup tasks across multiple test cases for improved maintainability.

What are the argument order conventions when using testify assertions?

Testify assertion argument order convention places the testing.T object first, followed by the expected value, then the actual value. Following this pattern ensures standard error output and integrates smoothly with related Go testing tooling.

Does testify work with the standard Go testing framework?

Yes, testify integrates directly with the standard Go testing framework. You import testify packages like assert and mock into standard test functions, leveraging its components without replacing the core testing.T structure.