-
Notifications
You must be signed in to change notification settings - Fork 16
/
go_test_cover.cli.txt
76 lines (54 loc) · 4.86 KB
/
go_test_cover.cli.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
GO_TEST_COVER
VERSION ==> #See Go language
RELATED DOCUMENTATION ==> #See Go language
TESTING ==> #See go_test documentation
/=+===============================+=\
/ : : \
)==: FORMAT :==(
\ :_______________________________: /
\=+===============================+=/
PATH.out #First line is:
# mode: set|count|atomic
#Then each line describes a block|FUNC branch:
# MODULE_PATH/FILENAME.go:START_LINE.START_COL,END_LINE.END_COL NUM NUM2
# NUM is number of statements
# NUM2 is number of hits (max 1 if mode "set")
/=+===============================+=\
/ : : \
)==: CORE :==(
\ :_______________________________: /
\=+===============================+=/
go test
-cover #Enables test coverage
#Instrument source code to add counting statements to do it.
#Only instruments in-between lines, i.e. does not separate single-line statements like FUNC() && FUNC2()
#Show summary test coverage percentage in output.
-coverpkg IMPORT_PATHS #Limit test coverage to those PACKAGEs (def: all)
-covermode STR #How lines are counted in test coverage:
# - "set" (def): only keeps track on wheter line was hit
# - "count": also keeps track of how many times line was hit
# - "atomic" (def if -race): like "count" but works in parallel tests. Slower
#Implies -cover
-coverprofile PATH.out #Write test coverage file
testing.CoverMode()->STR #Returns "" if -cover not set
testing.Coverage()->FLOAT64 #Current coverage percentage. 0 if -cover not set
/=+===============================+=\
/ : : \
)==: REPORT :==(
\ :_______________________________: /
\=+===============================+=/
go tool cover #Report detailed test coverage from PATH.out
-func PATH.out #Report as text
-html PATH.out #Report as HTML
-o PATH #Def: stdout with -func, opening browser with -html
/=+===============================+=\
/ : : \
)==: INSTRUMENT :==(
\ :_______________________________: /
\=+===============================+=/
go tool cover -mode=STR FILE.go #Instruments source code
#Used by go test -cover, i.e. useful for debugging
#STR is -covermode
-var VAR #Instrumentation variable name (def: "GoCover")