Golang Ginkgo BeforeSuite没有输出
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?
我有以下 Ginkgo code>
测试文件: p>
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”)
})
code> pre>
当我运行 ginkgo -r -v code>时,测试文件将运行,但是 BeforeSuite code>和 AfterSuite code >不会出现: p>
2016/03/16 09:23:17描述
testing:警告:没有要运行的测试
PASS
code> pre>
行 2016/03/16 09:23:17 Describe code>显示 Describe code>正在运行,但是 BeforeSuite code>和 AfterSuite code>? p>
我并不真正在乎输出,但是在我的实际测试(不是上面的片段)中,数据库 堆积和拆卸都没有执行。 p>
我在做什么错了? p>
div>
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?