go-testing

Generate and improve Go test code using the standard testing framework.

7|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/chenziyang110/spec-kit-plus --skill go-testing-chenziyang110
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/chenziyang110/spec-kit-plus/tree/main/templates/passive-skills/go-testing
Command: npx skills add https://github.com/chenziyang110/spec-kit-plus --skill go-testing-chenziyang110

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you write and fix Go test code so your project gains dependable regression protection, clear failure diagnosis, and higher confidence in behavior.

Core Features & Use Cases

  • TDD test workflow: Drives a red → green → refactor loop to ensure tests reflect the desired behavior.
  • Idiomatic Go test generation: Produces table-driven tests with t.Run, subtests, and optional t.Parallel where safe.
  • Real-world coverage scenarios: Supports unit tests, HTTP handler tests via httptest, and mocking approaches using testify patterns when needed.

Quick Start

Ask your agent: "Write Go tests for the HTTP handlers in this package, using table-driven cases and failing fast with clear assertions."

Frequently Asked Questions about go-testing

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

FAQPage Schema
How do I write table-driven Go tests with subtests and parallel execution?

Table-driven Go tests organize multiple test cases into a struct slice, iterating with t.Run to create subtests. You can add t.Parallel where safe to execute cases concurrently, ensuring clear failure isolation and broad coverage.

What is the best way to test Go HTTP handlers using httptest?

Testing Go HTTP handlers with httptest involves creating a simulated request using httptest.NewRequest and a response recorder with httptest.NewRecorder. This validates handler logic and status codes without starting a real server.

How do I fix flaky Go tests and prevent intermittent test failures?

Fixing flaky Go tests requires diagnosing timing issues, hidden state dependencies, or non-deterministic outputs. Applying flake-avoidance guardrails and clear assertions helps stabilize test outcomes and ensure reliable regression protection.

Should I use testify for mocking in Go unit tests or stick to the standard library?

Use testify for mocking when you need expressive assertions and mock generation, while the standard testing framework handles core validation. Choosing depends on whether you prioritize external dependency simulation or minimal stdlib reliance.

Can I follow a TDD workflow to generate Go tests for existing utilities?

Yes, you can drive a red, green, refactor TDD loop to generate Go tests for existing utilities. This ensures tests reflect desired behavior, validate edge cases, and provide clear failure diagnosis for your codebase.

Why are my Go test coverage reports missing edge cases and how do I add them?

Go test coverage reports miss edge cases when tests only validate standard inputs. Adding targeted unit tests and error coverage scenarios ensures comprehensive validation across utilities and HTTP handlers, improving your project's behavior confidence.