gotest-testing

Implement Go tests using the standard testing package and testify.

2|Updated Feb 15, 2026
One-click install
npx skills add https://github.com/nakano1122/dotfiles --skill gotest-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gotest-testing
Source: https://github.com/nakano1122/dotfiles/tree/main/dot_agents/skills/gotest-testing
Command: npx skills add https://github.com/nakano1122/dotfiles --skill gotest-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to writing robust and effective tests for Go applications, ensuring code quality and reliability.

Core Features & Use Cases

  • Test Structure: Learn best practices for organizing test files and naming conventions.
  • Testing Patterns: Implement table-driven tests, subtests, and test helpers for efficient testing.
  • Mocking & HTTP Testing: Understand how to mock dependencies and test HTTP handlers and clients.
  • Use Case: When developing a new API endpoint in Go, use this Skill to implement thorough unit and integration tests, including mocking external services and verifying request/response handling.

Quick Start

Use the gotest-testing skill to write a table-driven test for the Calculate function.

Frequently Asked Questions about gotest-testing

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

FAQPage Schema
How do I write table-driven tests in Go?

Table-driven tests in Go use a slice of structs to define test cases, iterating through them with subtests. This approach cleanly separates test data from test logic, ensuring comprehensive coverage across multiple input scenarios.

What is the best way to mock dependencies for Go unit tests?

Mocking dependencies in Go unit tests is best handled by defining interfaces for external services and substituting them with mock implementations. This isolates the code under test and allows verifying interactions without hitting real APIs.

How do I test HTTP handlers in Go using httptest?

HTTP handler testing in Go uses the `httptest` package to simulate server requests and record responses. You create mock requests and response recorders to verify routing, status codes, and JSON payloads without starting a real server.

Can I measure test coverage and run benchmarks with the Go testing package?

Yes, the standard Go testing package supports benchmarking via `B` structs and coverage analysis through the `go test -cover` command. These features measure execution performance and identify untested code paths.

How should I organize Go test files and use test helpers?

Go test files should sit in the same directory as their source code with a `_test.go` suffix. Test helpers are typically extracted into functions with names prefixed by `Test` or using `t.Helper()` to clarify failure origins.