golang-stretchr-testify

Write Go tests using stretchr/testify assertions, mocks, and suites.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Tests in Go can become verbose and hard to maintain. This skill provides a comprehensive guide to using stretchr/testify to write readable assertions, mocks, and test suites.

Core Features & Use Cases

  • Assert vs require for preconditions and verifications in tests.
  • Mock creation, expectation setting, and verification with mock.Mock.
  • Suite-based organization with Setup/Teardown and shared state, including advanced patterns like Eventually, JSONEq, and custom matchers.
  • Clear guidance on structuring tests across unit and integration scenarios using testify.

Quick Start

Install the library in your Go module and start by importing assert and require to validate tests with mocks and 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 readable assertions in Go testing using testify?

Testify assertions in Go testing allow you to validate test conditions with readable method chains. You import the assert and require packages to check values, reducing verbose manual if-statement checks in your test files.

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

Assert and require differ in test execution halting behavior in testify. Assert logs a failure and continues execution, while require immediately stops test execution, making it ideal for verifying preconditions before proceeding.

How do I create and verify mocks in a Go test suite with testify?

Testify mocks in a Go test suite are created using the mock.Mock struct. You set expected calls and arguments, execute your logic, and verify expectations were met, ensuring accurate interface testing.

Can I organize Go testing with Setup and Teardown hooks using testify suites?

Testify suites support organizing Go testing with Setup and Teardown lifecycle hooks. You group related tests into a struct, initialize shared state in Setup, and clean resources in Tearown for structured testing.

Does testify support advanced Go testing patterns like Eventually and JSONEq?

Testify supports advanced Go testing patterns including Eventually and JSONEq. Eventually polls for asynchronous conditions, while JSONEq compares JSON payloads semantically, expanding test validation capabilities.

What is the best way to structure unit and integration tests in Go using testify?

The best way to structure Go unit and integration tests with testify involves using suites for lifecycle management and mocks for external dependencies. This pattern isolates units and manages shared state across complex integration scenarios.