Golang Ginkgo BeforeSuite 没有输出

No output from Golang Ginkgo BeforeSuite

我有以下 Ginkgo 测试文件:

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")
})

当我运行ginkgo -r -v时,测试文件运行s,但是BeforeSuiteAfterSuite没有出现:

2016/03/16 09:23:17 Describe
testing: warning: no tests to run
PASS

2016/03/16 09:23:17 Describe显示Describe是运行ning,但是BeforeSuiteAfterSuite的输出在哪里?

我不太关心输出,但在我的实际测试中(不是上面的片段),数据库建立和拆除没有得到执行。

我做错了什么?

您没有调用 RunSpecs

func TestSo(t *testing.T) {
    RunSpecs(t, "My Test Suite")
}

然后输出类似于

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

您是否尝试 运行 在 _suite_test.go 文件中进行实际测试?