Skip to content
/ gott Public

Alternatives to ‘go test’, this is an amazing tool to run / search go test.

License

Notifications You must be signed in to change notification settings

sshelll/gott

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gott

996.icu LICENSE

Go test tool with terminal UI.

NEWS

Gott v2 is published!

Now You can use gott to parse go test files and get the test name from the gott output instead of exec it!

For example:

go test -v -test.run $(gott -print -file=/aa/bb/xx_test.go)

Please check v2/help.txt for more information.

Use go install github.com/sshelll/gott/v2@latest to get it!


Demo

demo

1.Install

go version >= 1.17, clone this repo and exec go build . should be ok,or you can exec the command below:

go install github.com/sshelll/gott@latest

go version <= 1.16, go to Release page and download the executable file(MacOS Only, I'm lazy...)

2.Usage

Use gott instead of go test

Or you can exec gott -p to get the test name, in this way you won't run go test

For example:

go test -v => gott -v

go test -v -race => gott -v -race

go test -gcflags="all=-l -N" => gott -gcflags=\"all=-l -N\"

go test -gcflags=all=-l -race -coverprofile=coverage.out => gott \"all=-l -N\" -race -coverprofile=coverage.out

gott -p => you will get a go test func name

Use the script below to debug a test with dlv:

#!/bin/zsh

fn=$(gott -p)

if [ ! $fn ]; then exit 0; fi

dlv test --build-flags=-test.run $fn

Use gott -h to get more details

3.QA

  • Q1:Does this program recognize github.com/stretchr/testify/suite

    A1:Yes,but the entry func of 'suite' is limited, you can see how it works in the examples below:

    type FooTestSuite struct {
      suite.Suite
    }
    
    // OK, allow 'new'
    func TestFoo1(t *testing.T) {
      suite.Run(t, new(FooTestSuite))
    }
    
    // OK, allow '&'
    func TestFoo2(t *testing.T) {
      suite.Run(t, &FooTestSuite{})
    }
    
    // not OK
    func TestFoo3(t *testing.T) {
      foo := new(FooTestSuite)
      suite.Run(t, foo)
    }
    
    // not OK
    func TestFoo4(t *testing.T) {
      m := make(map[int]interface{})
      m[1] = &FooTestSuite{}
      suite.Run(t, m[1])
    }
  • Q2:What are the key mappings?

    A2: to move cursor,/ to search (fzf-like, but only supports lowercase chars),esc to quit。

About

Alternatives to ‘go test’, this is an amazing tool to run / search go test.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages