-
Notifications
You must be signed in to change notification settings - Fork 2
/
help.txt
98 lines (78 loc) · 3.63 KB
/
help.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Gott is a alternative to 'go test' command, it can help you to choose a specific test to run
with UI.
Also, it has some useful features, such as:
-find the closest test func by byte pos
-find all tests in a go test file
If you want to use it as a command line tool, just try 'gott [go test args]' in your terminal,
for example:
gott -v ==> go test -v
gott -race ==> go test -race
gott -v -race ==> go test -v -race
If you want to use it as a binary tool to help get a test name, just try
'gott -p [other flags]' in your terminal, for example:
gott -p --pos=/Users/sshelll/go/src/xx_test.go:235 ==> print the closest
test to the 235(byte pos) in the file xx_test.go
gott -p --runFile=/Users/sshelll/go/src/xx_test.go ==> print all tests
in the file xx_test.go
TIPS: the result of 'gott -p' is a regexp test name, you can use it with
'go test' or 'dlv' command, for example:
go test -v -test.run $(gott -p --pos=/Users/sshelll/go/src/xx_test.go:235)
dlv test --build-flags=-test.run $(gott -p --pos=/Users/sshelll/go/src/xx_test.go:235)
WARN: The work dir of gott should be a go package dir, otherwise it will not work.
Also, although gott is a alternative command to 'go test', 'go' is still required.
For more detail please visit 'https://github.com/sshelll/gott'. Have fun with gott!
----------------------------------------------------------------------------------------------
Usage of Gott:
-listAll
print all tests of a file, this flag shoule be used with '-runFile'
NOTE: the difference between '-listAll' and '-p' is that '-p' will not print 'testify test methods'
For Example, if you got a test file like this:
// package test
//
// import (
// "testing"
// "github.com/stretchr/testify/suite"
// )
//
// func TestXxx(t *testing.T) {
// println("hello world")
// }
//
// type FooTestSuite struct {
// suite.Suite
// }
//
// func TestFoo(t *testing.T) {
// testifySuite.Run(t, &FooTestSuite{})
// }
//
// func (*FooTestSuite) TestCase() {
//
// }
The -p flag will only print 'TestXXX' and 'TestFoo' for you,
while -listAll will print both of them and 'TestFoo/TestCase'.
-p print the test name instead of exec it
[EXAMPLE 1]:
'gott -p --pos=/Users/sshelll/go/src/xx_test.go:104'
this will print the test name instead of exec it
[EXAMPLE 2]:
'gott -p --runFile=/Users/sshelll/go/src/xx_test.go'
this will print name of all tests in the file instead of exec them
-pos string
the uri with absolute filepath to exec the closest test
[EXAMPLE 1]:
'gott --pos=/Users/sshelll/go/src/xx_test.go:104'
this will exec the closest test to the 104(byte pos) in the file xx_test.go
[EXAMPLE 2]:
'gott --pos=/Users/sshelll/go/src/xx_test.go:235 -v -race'
this will exec the closest test to the 235(byte pos) in the file xx_test.go with -v -race flags
-runFile string
the uri with absolute filepath to exec all test in the file
[EXAMPLE 1]:
'gott --runFile=/Users/sshelll/go/src/xx_test.go'
this will exec all tests in 'xx_test.go'
[EXAMPLE 2]:
'gott --runFile=/Users/sshelll/go/src/xx_test.go -v -race'
this will exec all tests in 'xx_test.go' with -v -race flags
-version
print version of gott