go-testing

Implement Go testing strategies for unit, Bubble Tea UI, and integration tests using table-driven, teatest, and golden-file approaches.

Updated Jun 22, 2024
One-click install
npx skills add https://github.com/KilloconQ/dotfiles --skill go-testing-killoconq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/KilloconQ/dotfiles/tree/main/opencode/.config/opencode/skills/go-testing
Command: npx skills add https://github.com/KilloconQ/dotfiles --skill go-testing-killoconq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go developers often struggle to create reliable, maintainable tests for both core logic and Bubbletea UI components. This skill provides structured testing patterns to improve coverage and confidence.

Core Features & Use Cases

  • Table-driven tests: Efficiently cover multiple scenarios with compact, reusable test tables.
  • Bubbletea UI testing: Validate state transitions and user interactions in TUI components.
  • Teatest & golden-file testing: Enable deterministic flows and visual comparisons for complex interactions.
  • Use Case: A Go project with a Bubbletea UI can adopt these patterns to verify model updates, key handling, and end-to-end flows.

Quick Start

Run go test ./... to apply these patterns across your project and verify test coverage.

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 scenarios?

Table-driven tests in Go use compact, reusable test tables to efficiently cover multiple input scenarios and edge cases. This approach structures assertions structurally to ensure maintainable and deterministic test suites across your project.

What is the best way to test Bubble Tea UI components in Go?

Testing Bubble Tea UI components involves validating state transitions and user interactions within TUI models. You can apply model testing patterns to verify key handling and update logic for robust interface behavior.

How does teatest enable deterministic integration testing for TUI apps?

Teatest enables deterministic integration testing by validating end-to-end interaction flows in TUI applications. It works with golden-file approaches to provide visual comparisons and ensure complex user interactions produce expected results.

Can I use golden-file testing to verify complex Go terminal interactions?

Golden-file testing captures expected output to enable deterministic visual comparisons for complex terminal interactions. This approach verifies end-to-end flows and visual state changes against saved golden files.

How do I structure Go unit tests for maintainable and reliable coverage?

Structuring Go unit tests requires applying table-driven patterns, clear assertions, and edge-case handling to achieve reliable coverage. This ensures deterministic results and maintainable test suites across core logic.