While writing test cases I found 2 problems:
There are 3 test files out of which
one_test.go
andtwo_test.go
can be added toserver_suites_test.go
and it runs fine. But the functions ofthree_point_one_test.go
cannot be added intoserver_suites_test.go
because_test.go
cannot be imported.one_test.go
andtwo_test.go
use gRPC client object which is created byserver_test.go
. Actually,server_test.go
creates a gRPC server and a client and this client is used by the other test cases. Currentlythree_point_one_test.go
cannot access this client. So to solve this issue I'm creating client every time this test is run.
Project Structure(incomplete BTW!)
> tree /f
Folder PATH listing for volume Windows
Volume serial number is 1C92-17A5
C:.
└───data
│ one.go
│ one_test.go
│ two.go
│ two_test.go
│ server.go
│ server_suites_test.go
│ server_test.go
│
└───three
three_point_one.go
three_point_one_test.go
server_suites_test.go
package data
import (
"testing"
"someproj/three"
)
func TesOne(t *testing.T) {
t.Run("One", testOne) //from one_test.go
}
func TestTwo(t *testing.T) {
t.Run("Two", testTwo) //from two_test.go
}
// Below code cannot be compiled -START
func TestThreePointOne(t *testing.T) {
t.Run("ThreePointOne", three.TestThreePointOne) //cannot import this function
}
// Below code cannot be compiled -END
Is there any way to add other tests present in children packages into the test suite?