gpt4 book ai didi

go - Golang Ginkgo BeforeSuite 没有输出

转载 作者:IT王子 更新时间:2023-10-29 01:55:02 24 4
gpt4 key购买 nike

我有以下 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 时,测试文件运行,但 BeforeSuiteAfterSuite 似乎没有:

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

2016/03/16 09:23:17 Describe 显示 Describe 正在运行,但是 BeforeSuite 的输出在哪里> 和 AfterSuite

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

我做错了什么?

最佳答案

您没有调用 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 文件中运行您的实际测试?

关于go - Golang Ginkgo BeforeSuite 没有输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36037244/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com