go-testing

Implements Go testing patterns including table-driven tests, Bubbletea TUI testing, and golden file comparison.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/Balthael/ciberbal-ai --skill go-testing-balthael
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/Balthael/ciberbal-ai/tree/main/internal/assets/skills/go-testing
Command: npx skills add https://github.com/Balthael/ciberbal-ai --skill go-testing-balthael

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing tests for Go applications, especially interactive Bubbletea TUI components, requires knowing specific patterns like teatest simulation and golden file comparison that are not obvious to developers new to the ecosystem. ## Core Features & Use Cases - Table-Driven Test Patterns: Standard Go idioms for testing multiple input/output cases with error handling. - Bubbletea TUI Testing: Direct Model.Update() state transition tests plus teatest integration tests that simulate key presses and full interactive flows. - Golden File Testing: Compare rendered TUI output against saved snapshot files with an update flag for regeneration. - Use Case: When adding a new screen to a Bubbletea installer, use this Skill to write a screen transition test, a cursor navigation test, and a golden file test for the rendered view. ## Quick Start Write Go tests for my Bubbletea model covering key navigation, screen transitions, and golden file output using teatest.

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, expected output, and wantErr fields, then loop over them calling t.Run for each case. Check error presence against wantErr and compare results with the expected values.

How to test Bubbletea TUI components in Go?

Test Model.Update() directly by passing tea.KeyMsg values and asserting on the returned model state. For full interactive flows, use teatest.NewTestModel, send key messages with tm.Send, and inspect the final model with tm.FinalModel.

What is golden file testing in Go?

Golden file testing compares rendered output against a saved snapshot file in a testdata directory. An -update flag regenerates the golden files when output intentionally changes, and tests fail when output diverges from the snapshot.

Does teatest support simulating keyboard input?

Yes, teatest supports sending tea.KeyMsg values through tm.Send to simulate key presses like Enter, Escape, and rune keys. You can wait for completion with tm.WaitFinished and a duration timeout.

How do I mock system dependencies in Go tests?

Inject mock structs through interfaces or fields, such as setting a SystemInfo struct with controlled OS, architecture, and a t.TempDir() home directory. This lets tests run deterministically without touching the real system.