vendredi 17 janvier 2020

Test in main package is not picked up by golang test runner

I am using:

cd project && go test *.go

I have:

project/
   main.go
   pkg_test.go

in pkg_test.go I have:

package main

import "testing"

func TestMain(t *testing.T) {
    t.Fail()
    main()
}

but my test script at the cmd line doesn't fail, it passes, so it's not picking up the TestMain func. Any idea why?

Aucun commentaire:

Enregistrer un commentaire