go-testing

Provide Go testing patterns for unit, table-driven, and Bubbletea TUI tests.

Updated Jan 24, 2026
One-click install
npx skills add https://github.com/MarcialFantini/saas-template --skill go-testing-marcialfantini
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/MarcialFantini/saas-template/tree/main/.agent/skills/go-testing
Command: npx skills add https://github.com/MarcialFantini/saas-template --skill go-testing-marcialfantini

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill consolidates practical Go testing patterns to reduce brittle tests, accelerate TUI validation, and standardize approaches for unit, integration, and golden-file testing.

Core Features & Use Cases

  • Table-Driven Tests: clear templates and subtest patterns for exercising many input/output cases consistently.
  • Bubbletea & Teatest: guidance to test Model.Update transitions, simulate key events, and run teatest integration flows.
  • Golden File Testing & Organization: practices for managing testdata, updating golden files, and running go test with coverage and short/integration flags.

Quick Start

Run a Bubbletea teatest that sends keystrokes to a TestModel, waits for completion, and asserts the final model state.

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 to cover multiple input cases?

Table-driven tests in Go use a struct slice to define input and expected output cases, then loop through them with subtests to assert results consistently. This pattern ensures comprehensive coverage across many data variations.

What's the best way to test Bubbletea TUI components and Model.Update transitions?

Testing Bubbletea TUI components involves asserting Model.Update transitions and simulating key events using teatest integration flows. This validates view rendering and model state changes after specific interactions.

How do I manage golden file testing and update testdata in Go projects?

Golden file testing in Go stores expected output in a testdata directory, comparing actual results against these files. You manage updates by running go test with specific update flags to regenerate golden files.

Can I run Go tests with coverage and filter integration tests using short flags?

Yes, you can run go test with coverage flags to generate reports and use the short flag to skip or include integration tests. This organizes test execution by controlling which test suites run.

Why does my Bubbletea teatest fail to assert the final model state?

Bubbletea teatest failures often occur when the test does not properly wait for the TestModel to finish processing simulated keystrokes. You must wait for completion before asserting the final model state.

Does teatest support sending complex keystroke sequences to a TUI program?

Teatest supports simulating key events by sending keystrokes to a TestModel during integration flows. This allows you to replicate complex user interactions and validate the resulting state.