golang-stretchr-testify

Guide Go test creation with testify assertions, mocks, and suites.

1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Jylhis/claude-marketplace --skill golang-stretchr-testify-jylhis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-stretchr-testify
Source: https://github.com/Jylhis/claude-marketplace/tree/main/plugins/golang-dev/skills/golang-stretchr-testify
Command: npx skills add https://github.com/Jylhis/claude-marketplace --skill golang-stretchr-testify-jylhis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Writing Go tests with testify can be error‑prone: developers often mix assert and require, misuse mock expectations, and mishandle suite lifecycles, leading to flaky or unsafe tests.

Core Features & Use Cases

  • Assert vs Require guidance – when to use each for preconditions versus verifications.
  • Comprehensive assertion library – correct argument order, deep equality, JSON comparison, async polling.
  • Mock utilities – embed mock.Mock, verify expectations, and use advanced matchers.
  • Testify suite support – lifecycle methods, launcher function, and require syntax inside suites.
  • Linting recommendation – integrate testifylint to catch common mistakes.

Quick Start

Ask the assistant to generate a Go test for a function that parses a config file, using require for error handling and assert for value checks.

Frequently Asked Questions about golang-stretchr-testify

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

FAQPage Schema
When should I use assert versus require in Go testify tests?

Use require for preconditions that must halt the test on failure, and assert for non-critical verifications that allow the test to continue collecting failures. This distinction prevents flaky tests and ensures safe execution paths.

How do I write a Go test using testify mocks and expectations?

To write a Go test with testify mocks, embed mock.Mock in your struct, set up expected calls and return values, execute the code, and verify expectations to ensure the interface was used correctly.

Can I organize Go tests into suites using testify?

Yes, you can organize Go tests using testify suites. They provide lifecycle methods for setup and teardown, along with a launcher function, ensuring structured and manageable test execution without manual boilerplate.

What is the best way to prevent common testify testing mistakes in Go?

The best way to prevent common testify testing mistakes is to integrate the testifylint linter. It automatically catches frequent errors like mixing assert and require or misusing mock expectations during development.

Does testify support comparing JSON payloads in Go tests?

Yes, testify supports comparing JSON payloads in Go tests. The assertion library provides deep equality checks and specific JSON comparison utilities to accurately validate complex data structures.

How do I handle asynchronous polling in Go testify assertions?

Handle asynchronous polling in Go testify by using the assertion library's built-in async capabilities. This allows you to poll for expected state changes over time without writing manual retry loops.