gotcha

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 1 Imported by: 0

README ΒΆ

🐹 gotcha

gotcha is a test automation tool for Go developers. It watches for file changes and automatically runs go test, supporting TDD and fast feedback.


✨ Features

  • βœ… Automatically detects changes in .go files and runs go test
  • βœ… Define target/excluded paths and test flags in .gotcha.yaml
  • βœ… gotcha run for one-shot test execution
  • βœ… gotcha watch for continuous test running on save
  • βœ… Colored output for test success/failure
  • βœ… Easy initialization with gotcha init

πŸ” Comparison to Other Tools

Tool Language Purpose How gotcha differs
spring rspec Ruby Fast RSpec runs via preload gotcha is CLI-based and watch-driven, optimized for Go
watchexec Any Run any command on file change gotcha is Go-native, built specifically for go test
gotestsum Go Pretty test output formatting gotcha supports live watching and reruns with test summary
entr Any Minimal file-change trigger gotcha provides YAML config, input control (r, q), and output handling

Unlike generic file watchers, gotcha is purpose-built for Go developers who want fast, automatic test feedback without extra setup or dependencies.

βœ… Lightweight CLI
βœ… Integrated go test runner
βœ… .gotcha.yaml for fine-grained test control
βœ… Supports --summary for clean test result overview
βœ… watch mode with keyboard control (r to rerun, q to quit)


πŸ“¦ Install

# go >= v1.24
go get -tool github.com/mickamy/gotcha@latest
# go < v1.24
go install github.com/mickamy/gotcha@latest

or

git clone https://github.com/mickamy/gotcha.git
cd gotcha
make install

πŸš€ Usage

1. Initialize
gotcha init

This generates .gotcha.yaml:

include:
  - "./..."
exclude:
  - "vendor/"
  - "mocks/"
args:
  - "-v"
2. Run once
gotcha run
3. Watch for changes
gotcha watch

This reruns tests automatically whenever .go files change.


βš™οΈ Configuration (.gotcha.yaml)

Field Description
include Target packages (passed to go list)
exclude Directories or paths to ignore
args Arguments passed to go test (e.g. -v, -race)

πŸ’‘ Why gotcha?

Compared to similar tools like gotestsum, richgo, ginkgo watch, and entr, gotcha provides:

  • 🧠 Zero-config default behavior: just run gotcha watch in any Go project
  • 🧹 YAML-based filtering: simple includes/excludes for packages and paths
  • πŸ“¦ Lightweight: single-purpose CLI with no dependencies on external runners or frameworks
  • 🎯 TDD-first design: optimized for fast, repeated test execution during development
  • 🌈 Clean, colored terminal UX: highlights pass/fail status clearlyz

πŸ›£ Roadmap

  • --fast flag to test only changed packages
  • .gotcha.yaml watch-specific settings (e.g. debounce)

πŸ“„ License

MIT

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
cmd
run
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL