mardi 21 avril 2020

How to test without _test

I have a package and many test files within.

web
 |- client.go
 |- client_test.go
 |- server.go
 |- server_test.go
 |- ...

If I want to run go test client_test.go, it report an error for me.

package web  // not the package name web_test

func TestHost(t *testing.T) {
      hostPort, hostNoPort := hostPortNoPort()
}

// error: undefined hostPortNoPort
// But this function actually defined in the client.go

Aucun commentaire:

Enregistrer un commentaire