go-testing

Write table-driven Go tests, Bubbletea teatest flows, and golden file assertions.

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/zMynxx/bifrost-with-opencode --skill go-testing-zmynxx
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/zMynxx/bifrost-with-opencode/tree/main/.opencode/skills/go-testing
Command: npx skills add https://github.com/zMynxx/bifrost-with-opencode --skill go-testing-zmynxx

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go projects often accumulate inconsistent test styles, flaky filesystem tests, and untested TUI behavior. This Skill enforces focused Go testing patterns so tests cover behavior and state transitions rather than implementation trivia. ## Core Features & Use Cases - Pattern Selection via Decision Gates: Maps each test target (pure functions, errors, file operations, TUI state, rendered output, external commands) to the correct test pattern. - Bubbletea and Golden File Coverage: Guides direct Model.Update() testing, teatest interactive flows, and deterministic golden file updates through the repo's -update flag. - Use Case: When adding a new screen to a Bubbletea CLI, use this Skill to write a state-transition test with tea.KeyMsg, an interactive teatest flow, and a golden file assertion for the rendered output. ## Quick Start Write table-driven tests with coverage for the parser package and add a golden file test for its rendered output.

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 structs with name, input, want, and wantErr fields, then loop with t.Run(tt.name, ...) for each case. Assert errors and outputs explicitly inside each subtest so failures identify the exact scenario.

How to test Bubbletea TUI applications in Go?▼

Test state transitions by calling Model.Update() directly with a tea.Msg such as tea.KeyMsg and asserting the resulting model state. Use teatest.NewTestModel() only for full interactive flows where you send messages and wait for completion.

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

Use direct Model.Update() calls for state transition tests since they are fast and deterministic. Reserve teatest for full interactive flows that require sending messages and waiting on the finished model with teatest.WithDuration.

How do golden file tests work in Go?▼

Register an -update flag, write output to the golden file only when the flag is set, otherwise read the file and compare against actual output. Always rerun tests without -update after regenerating to confirm the diff is stable.

How do I keep Go integration tests from slowing down the suite?▼

Guard tests that run external commands or slow flows with testing.Short() so they skip under go test -short. Run the narrow package test first, then the broader suite, and use t.TempDir() for any filesystem dependencies.