Skip to content

Instantly share code, notes, and snippets.

@cespare
Created January 22, 2015 22:37
Show Gist options
  • Save cespare/20d9de5acc93572b0c3a to your computer and use it in GitHub Desktop.
Save cespare/20d9de5acc93572b0c3a to your computer and use it in GitHub Desktop.
Example of excluding tests with build tags
package foo
import "testing"
func TestFoo(t *testing.T) {
t.Log("A")
}
// +build integration
package foo
import "testing"
func TestIntegration(t *testing.T) {
t.Log("B")
}
$ 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