Skip to content

Instantly share code, notes, and snippets.

@rakyll
Last active January 27, 2016 21:47
Show Gist options
  • Save rakyll/48332d772025b1dc12e8 to your computer and use it in GitHub Desktop.
Save rakyll/48332d772025b1dc12e8 to your computer and use it in GitHub Desktop.
You need to run tests with:
go test -tags=test
// +build !test
package a
func Hello() string {
return "hello"
}
package a
import "testing"
func TestHello(t *testing.T) {
if got, expected := Hello(), "hello from tests"; got != expected {
t.Errorf("got = %q; expected = %q", got, expected)
}
}
// +build test
package a
func Hello() string {
return "hello from tests"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment