Last active
August 29, 2015 14:09
-
-
Save axw/2fa39577d3f09358e55a to your computer and use it in GitHub Desktop.
Coverage testing of "main" program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "flag" | |
var b = flag.Bool("myflag", false, "description") | |
func main() { | |
flag.Parse() | |
if *b { | |
println("true") | |
} else { | |
println("false") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "testing" | |
func TestMain(t *testing.T) { | |
main() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go test -coverprofile=test.true.prof -myflag=true | |
$ gocov convert test.true.prof > test.true.gocov | |
$ gocov annotate test.true.gocov | |
7 func main() { | |
8 flag.Parse() | |
9 if *b { | |
10 println("true") | |
11 } else { | |
12 MISS println("false") | |
13 } | |
14 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment