Reputation: 32264
I have the following Ginkgo
test file:
package foo
import (
"log"
. "github.com/onsi/ginkgo"
)
var _ = BeforeSuite(func() {
log.Print("BeforeSuite")
})
var _ = AfterSuite(func() {
log.Print("AfterSuite")
})
var _ = Describe("Foo", func() {
log.Print("Describe")
})
When I run ginkgo -r -v
, the test file runs, but the BeforeSuite
and AfterSuite
do not appear to:
2016/03/16 09:23:17 Describe
testing: warning: no tests to run
PASS
The line 2016/03/16 09:23:17 Describe
shows that the Describe
is running, but where is the output for BeforeSuite
and AfterSuite
?
I do not really care about the output, but in my real test (not the fragment above), database build up and tear down are not getting executed.
What am I doing wrong?
Upvotes: 1
Views: 3755
Reputation: 131968
You are not invoking RunSpecs
func TestSo(t *testing.T) {
RunSpecs(t, "My Test Suite")
}
Output then appears similar to
2016/03/16 07:16:05 Describe
Running Suite: So Suite
=======================
Random Seed: 1458137764
Will run 0 of 0 specs
2016/03/16 07:16:05 BeforeSuite
2016/03/16 07:16:05 AfterSuite
Ran 0 of 0 Specs in 0.000 seconds
SUCCESS! -- 0 Passed | 0 Failed | 0 Pending | 0 Skipped PASS
Ginkgo ran 1 suite in 1.211144437s
Test Suite Passed
Are you trying to run your actual tests in the _suite_test.go
file?
Upvotes: 4