I am new to go lang, and i have a question regarding the structure of the project. let says i have a the following project structure.
myproject
package1
mycode.go
mycode_test.go
package2
morecode.go
morecode_test.go
each one of the *_test.go has the following code:
func TestMyCode(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "MyCode Test Suite")
}
var _ = BeforeSuite(func() {
//some inits
}
And when i run the test with ginkgo -r, all is fine and the tests are running fast.
Now due to some cyclic dependencies i had to restructure the project. I created another package called tests and move the *_test.go files there. And created one initialization file called init_test.go which has the following code:
func TestInit(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "init Test Suite")
}
var _ = BeforeSuite(func() {
//some inits
}
so the new structure is something like that
myproject
package1
mycode.go
package2
morecode.go
tests
init_test.go
mycode_test.go
morecode_test.go
The cyclic dependencies issue was solved, but the problem now is that the tests take much more longer to run several minutes instead of several seconds, and i don't know why. What have i done wrong?