I installed go and tried the first part on How to write go code
And after a while of not seeing the desired result I notice go test always passes, always!
What am I missing?
$ go version
go version go1
$ mkdir -p src/example/math
$ cat >src/example/math/sum_test.go <<.
> package math
>
> import "testing"
>
> func SumTest( t *testing.T ) {
> t.Errorf("ssss %d", 1 )
> }
> .
$ go test example/math
ok example/math 0.044s
I'm using windows x64 and I'm using git-bash as shell
From the go command man page:
A test function is one named TestXXX
(where XXX
is any alphanumeric string not starting with a lower case letter) and should have the signature,
func TestXXX(t *testing.T) { ... }
Your SumTest()
function doesn't follow that pattern, and is likely to be ignored.
This should work better:
func TestSum( t *testing.T )