go-test

Write Go tests using TDD, table-driven patterns, testify, testcontainers, and gomock.

Updated Dec 31, 2025
One-click install
npx skills add https://github.com/victorzhuk/go-ent --skill go-test-victorzhuk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-test
Source: https://github.com/victorzhuk/go-ent/tree/main/pkg/skills/go/go-test
Command: npx skills add https://github.com/victorzhuk/go-ent --skill go-test-victorzhuk

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write robust, comprehensive, and maintainable tests for their Go applications, ensuring code quality and reliability.

Core Features & Use Cases

  • Test Patterns: Implements table-driven tests, TDD, and parallel test execution.
  • Assertion Libraries: Utilizes testify/require and testify/assert for clear assertions.
  • Integration Testing: Integrates with testcontainers for testing against real dependencies like databases and Redis.
  • Mocking: Provides strategies for mocking dependencies using gomock or testify/mock.
  • Use Case: Automatically generate unit and integration tests for a new Go API endpoint, including mocking external service calls and setting up a test database.

Quick Start

Write table-driven tests for the entity.NewUser() function, covering valid and invalid inputs.

Frequently Asked Questions about go-test

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

FAQPage Schema
How do I write table-driven tests in Go for multiple input scenarios?

Testify provides `require` for failing tests immediately on assertion errors and `assert` for collecting failures. Using `require` stops execution instantly, while `assert` reports multiple failures within a single test run.

How do I test Go integrations against real databases without a live environment?

Testcontainers spins up lightweight, disposable Docker containers for real dependencies like databases and Redis. This approach executes integration tests against actual services, validating application reliability without maintaining external environments.

What is the best way to mock external service calls in Go testing?

Mocking external service calls in Go uses `gomock` or `testify/mock` to generate mock implementations. This isolates dependencies during unit testing, verifying interactions and ensuring application reliability without actual service endpoints.

Can I run benchmark tests in Go to measure function performance?

Benchmark tests in Go measure function execution performance using the `testing` package. They run code repeatedly to collect timing metrics, ensuring application reliability by validating performance alongside standard unit test coverage.