go-testing

Applies focused Go testing patterns including table-driven tests, Bubbletea teatest flows, and golden files.

Updated May 24, 2026
One-click install
npx skills add https://github.com/etrigan16/v0-cipher-ar --skill go-testing-etrigan16
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/etrigan16/v0-cipher-ar/tree/main/.opencode/skills/go-testing
Command: npx skills add https://github.com/etrigan16/v0-cipher-ar --skill go-testing-etrigan16

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing consistent, maintainable Go tests is hard when teams mix patterns, test implementation details instead of behavior, or mishandle TUI and golden-file scenarios. This Skill provides a decision framework that maps each testing target to the right Go testing pattern. ## Core Features & Use Cases - Pattern Selection via Decision Gates: Maps test targets (pure functions, file operations, TUI state, rendered output, external commands) to the correct pattern such as table-driven tests, t.TempDir(), direct Model.Update() calls, teatest, or golden files. - Bubbletea/TUI Testing Guidance: Distinguishes when to test Model.Update() directly versus when to use teatest.NewTestModel() for full interactive flows. - Golden File Discipline: Enforces deterministic golden files updated only through the repo's -update flag, with verification runs afterward. - Use Case: When adding coverage to a Go CLI with a Bubbletea interface, load this skill to decide whether a screen transition needs a direct Update() test or a full teatest flow, then follow the execution steps to write, run, and verify the tests. ## Quick Start Ask the assistant to write tests for a specific Go function or Bubbletea model using the go-testing patterns and report which scenarios and commands were covered.

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 tests in Go?▼

Define a slice of anonymous structs with name, input, and expected output fields, then loop with t.Run(tt.name, ...) for each case. Assert both error behavior and outputs explicitly, naming cases by scenario rather than input mechanics.

How to test a Bubbletea TUI application in Go?▼

Test Model.Update() directly with tea.Msg values for state transitions, which covers most logic. Use teatest.NewTestModel() only for full interactive flows where you need to send keys and wait for the program to finish.

When should I use teatest vs direct Model.Update testing?▼

Use direct Model.Update() calls for state transition tests since they are fast and deterministic. Reserve teatest for end-to-end interactive flows where you need the full program loop, final model state, or rendered output verification.

How do golden file tests work in Go?▼

Golden tests compare rendered output against a stored file, with an -update flag that rewrites the file when output intentionally changes. Always rerun tests without -update afterward to confirm the new golden file matches.

How do I skip slow integration tests in Go?▼

Guard tests that run external commands or slow flows with testing.Short(), so they are skipped when running go test -short. This keeps the fast unit test suite quick while preserving full integration coverage on demand.

How should Go tests handle filesystem operations?▼

Use t.TempDir() to create isolated temporary directories that Go cleans up automatically after the test. Never rely on a real home directory or shared paths, since that makes tests non-deterministic and environment-dependent.