Created
January 22, 2015 22:37
-
-
Save cespare/20d9de5acc93572b0c3a to your computer and use it in GitHub Desktop.
Example of excluding tests with build tags
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 foo | |
import "testing" | |
func TestFoo(t *testing.T) { | |
t.Log("A") | |
} |
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
// +build integration | |
package foo | |
import "testing" | |
func TestIntegration(t *testing.T) { | |
t.Log("B") | |
} |
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 -v | |
=== RUN TestFoo | |
--- PASS: TestFoo (0.00s) | |
foo_test.go:6: A | |
PASS | |
ok _/home/caleb/test/gotest 0.001s | |
$ go test -v -tags=integration | |
=== RUN TestFoo | |
--- PASS: TestFoo (0.00s) | |
foo_test.go:6: A | |
=== RUN TestIntegration | |
--- PASS: TestIntegration (0.00s) | |
integration_test.go:8: B | |
PASS | |
ok _/home/caleb/test/gotest 0.003s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment