英文:
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
时,测试文件会运行,但是BeforeSuite
和AfterSuite
似乎没有出现:
2016/03/16 09:23:17 Describe
testing: warning: no tests to run
PASS
2016/03/16 09:23:17 Describe
这一行显示Describe
正在运行,但是BeforeSuite
和AfterSuite
的输出在哪里?
我并不真的关心输出,但是在我的真实测试中(不是上面的片段),数据库的构建和拆除没有被执行。
我做错了什么?
英文:
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?
答案1
得分: 4
您没有调用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
文件中运行实际的测试?
英文:
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?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论