Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

206 Commits

Repository files navigation

gotip

Go Test Interactive Picker

About

gotip is a TUI application for interactively selecting and running Go tests.

Key features:

  • Fuzzy filtering of test cases
  • Detection of subtest names defined via table-driven tests (partial support)
  • List discovered tests in text or JSON format
  • Run individual subtests or grouped subtests
  • View and re-run tests from execution history

Installation

go install github.com/lusingander/gotip/cmd/gotip@latest

Usage

Basic usage

In a directory containing a go.mod file, run:

gotip

While a test is selected, press Enter to run it using go test.

To show only tests and histories from a package and its subpackages, use --package:

gotip --package ./internal

You can also use Go-style package patterns:

gotip --package ./internal/...

Passing additional arguments

You can pass extra flags directly to go test by appending them after --:

gotip -- -v -count=1

Running a parent test group

While a test is selected, press Backspace to move up to its parent test group.

This allows you to execute all subtests under that group.
For example, if you have TestFoo/Bar/Baz selected, pressing Backspace will select TestFoo/Bar, and running it will execute all tests under that prefix.

If subtest names could not be automatically discovered, gotip defaults to selecting the nearest available parent test.

Using test history

Press Tab to switch to History view, or launch directly with the --view=history option.

In this view, you can select and run tests from your previous execution history, just like in the regular view.

The history data is stored under ~/.local/state/gotip/history/.

Rerunning the last test

You can rerun the last executed test without showing the UI by using the --rerun option:

gotip --rerun

This will immediately execute the most recent test from your history.

When used with --package, --rerun executes the most recent history entry that matches the package filter:

gotip --rerun --package ./internal/...

Listing discovered tests

You can inspect the statically discovered test tree without opening the UI:

gotip list

Example text output:

# ./foo/foo_test.go
- TestFoo
- case1
- case2
- TestBar

For machine-readable output, use JSON:

gotip list --format=json

To list tests from a package and its subpackages, use --package. internal is treated as ./internal, and ./internal matches packages such as ./internal/parse and ./internal/tip.

gotip list --package ./internal

Go-style package patterns are also supported:

gotip list --package ./internal/...
gotip list --package ./...

Example JSON output:

{
"files": [
{
"path": "./foo/foo_test.go",
"tests": [
{
"name": "TestFoo",
"subtests": [
{ "name": "case1", "resolved": true, "subtests": [] }
]
}
]
}
]
}

The JSON output follows schema/list.schema.json.

The list command uses the same discovery rules as the TUI, including subtest inference and --skip-subtests.

Options

Usage:
gotip [OPTIONS] [list]
Application Options:
-v, --view=[all|history] Default view (default: all)
-f, --filter=[fuzzy|exact] Default filter type (default: fuzzy)
-p, --package=PACKAGE Filter by package path or pattern
-s, --skip-subtests Skip subtest detection
-r, --rerun Rerun the last test without showing the UI
-V, --version Print version
Help Options:
-h, --help Show this help message
Available commands:
list List discovered tests

gotip list --help shows options specific to the non-interactive listing command:

Usage:
gotip [OPTIONS] list [list-OPTIONS]
[list command options]
-p, --package=PACKAGE Filter by package path or pattern
-s, --skip-subtests Skip subtest detection
--format=[text|json] Output format (default: text)

Config

gotip supports both global and project-specific configuration.

  • Global config
    • Place your global config at ~/.config/gotip/gotip.toml. This applies to all projects.
  • Project config
    • Place a gotip.toml file in your current working directory. This applies only to the current project.

If both global and project configs exist, they are merged.
For overlapping keys, the project config takes precedence.

The format is as follows:

# Specifies the command used to run tests.# If omitted, the default command is used.# type: list of stringscommand = []
# Specify file path patterns to exclude from processing using the .gitignore format.# https://git-scm.com/docs/gitignore/en#_pattern_format# type: list of stringsignore = []
[filter]
# Selects the fuzzy matching implementation.# Supported values are "gotip" and "legacy".# type: stringfuzzy_matcher = "gotip"
[history]
# Limits the number of test executions to keep in history.# type: integerlimit = 100# Format used to display timestamps in the history view.# Uses Go's time format syntax.# type: stringdate_format = "2006-01-02 15:04:05"
[keybindings]
# Keys use Bubble Tea's canonical key names.# Each field replaces the corresponding global or default binding.select_previous = ["up", "k"]
select_next = ["down", "j"]
previous_page = ["left", "h", "pgup", "b", "u"]
next_page = ["right", "l", "pgdown", "f", "d"]
go_to_start = ["home", "g"]
go_to_end = ["end", "G"]
run = ["enter"]
parent = ["backspace", "ctrl+h"]
start_filter = ["/"]
clear_filter = ["esc"]
cancel_filter = ["esc"]
confirm_filter = ["enter"]
toggle_filter_type = ["ctrl+x"]
switch_view = ["tab", "shift+tab"]
show_help = ["?"]
close_help = ["?", "backspace", "ctrl+h"]
quit = ["q", "esc"]
force_quit = ["ctrl+c"]
[theme]
# Colors accept #RGB, #RRGGBB, or ANSI color numbers from 0 to 255.# Color values must be strings.# Primary UI text color.# type: stringtext = "#DDDDDD"# Selected target and filter cursor color.# type: stringaccent = "#00ADD8"# Selected list item and help key color.# type: stringhighlight = "#5DC9E2"# Secondary and dimmed text color.# type: stringmuted = "#777777"# Description color for dimmed items.# type: stringdimmed = "#4D4D4D"# Header and footer border color.# type: stringborder = "240"# Filter query match color.# type: stringmatch = "#CE3262"# Test command color.# type: stringcommand = "#00A29C"

filter

The filter.fuzzy_matcher field selects the matcher used when the UI is in fuzzy filtering mode.

ValueBehavior
gotipUses gotip's matcher, which prefers compact, contiguous matches. This is the default.
legacyUses the original sahilm/fuzzy-based matcher.

This setting does not change the initial fuzzy or exact filter mode selected by the --filter option.

keybindings

The keybindings table customizes UI actions. Each field is a list because an action can have multiple keys. When global and project configs both define an action, the project list replaces the global list. Set an optional action to an empty list to disable it:

[keybindings]
run = []

force_quit is the only required action and must contain at least one key.

Key names are case-sensitive and use the strings returned by Bubble Tea's KeyMsg.String:

  • Printable characters are written directly, such as "j", "G", or "?". Use " " for Space.
  • Special keys include "enter", "backspace", "tab", "esc", arrow keys such as "up", paging keys such as "pgdown", and "f1" through "f20".
  • Modifiers use +, as in "ctrl+n", "alt+x", "shift+tab", or "ctrl+shift+up".
  • Use canonical names such as "tab", "enter", and "esc" rather than their control-key aliases.

For canonical special-key names, see Bubble Tea v1.3.10's key name mapping.

The available actions are:

FieldAction
select_previousSelect the previous item, or scroll help up
select_nextSelect the next item, or scroll help down
previous_pageSelect the previous page
next_pageSelect the next page
go_to_startSelect the first item
go_to_endSelect the last item
runRun the selected test
parentSelect the parent test group
start_filterEnter filtering mode
clear_filterClear an applied filter
cancel_filterCancel filter editing
confirm_filterConfirm filter editing
toggle_filter_typeToggle between fuzzy and exact filtering
switch_viewSwitch between All Tests and History
show_helpShow help
close_helpClose help
quitQuit while browsing
force_quitQuit from any screen

Keys may be reused for actions that are active in different contexts, such as run and confirm_filter. Conflicting keys within the same context are rejected when the config is loaded. clear_filter takes precedence over quit when both contain the same key and a filter is applied. The in-app help is generated from the active keybindings and omits disabled actions.

command

The command field allows you to customize how tests are executed.

You can use this to always pass specific flags or use an external test runner instead of the default.

For example, to use gotestsum, you can configure it like this:

command = ["gotestsum", "--format", "testname", "--", "-run", "${name}", "${package}"]

${name} and ${package} are placeholders that will be replaced at runtime with the selected test name pattern and package name, respectively.

If not specified, the following default command is used:

command = ["go", "test", "-run", "${name}", "${package}"]

theme

The theme table controls the colors used by the UI and the displayed test command. You can specify only the colors you want to change; omitted colors keep their global or default values.

FieldUsage
textPrimary UI text
accentSelected target and filter cursor
highlightSelected list items and help keys
mutedSecondary and dimmed text
dimmedDescriptions of dimmed items
borderHeader and footer borders
matchCharacters matching the filter query
commandTest command printed before execution

Keybindings

KeyDescription
Ctrl-cQuit from any screen
qQuit while browsing
EscQuit while browsing without an applied filter
jSelect next item / Scroll help down
kSelect previous item / Scroll help up
lPgDownfdSelect next page
hPgUpbuSelect previous page
gHomeSelect first item
GEndSelect last item
EnterRun the selected test
BackspaceCtrl-hSelect parent test group
/Enter filtering mode
EnterConfirm filter while editing
EscCancel filter editing or clear an applied filter
Ctrl-xToggle filtering type
TabShift-TabSwitch view
?Show help
?BackspaceCtrl-hClose help

License

MIT

About

Go Test Interactive Picker 🧪

Topics

Resources

Stars

33 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages