go - 没有发现银杏测试?

标签 go ginkgo gomega

我不明白为什么'go'找不到我的Ginkgo测试文件

这是我的结构:

events
├── button_not_shown_event.go
├── events_test
│   └── button_not_shown_event_test.go

这里是我的 button_not_shown_event_test.go 的样子

package events_test

import (
    "fmt"
    . "github.com/onsi/ginkgo"
    . "github.com/onsi/gomega"
)

var _ = Describe("ButtonNotShownEvent", func() {
  BeforeEach(func() {
    Expect(false).To(BeTrue())
  })
  
  Context("ButtonNotShownEvent.GET()", func() {
        It("should not return a JSONify string", func() {
           Expect(true).To(BeFalse())
        })
    })
})

请注意,我专门编写了一个测试,因此它会失败。

但是每次运行 Ginkgo 测试时都会出现以下错误

go test ./app/events/events_test/button_not_shown_event_test.go  -v

testing: warning: no tests to run
PASS
ok      command-line-arguments  1.027s

很明显我在这里遗漏了一些东西。

有什么线索吗?

最佳答案

进入 events_test 目录并运行:

ginkgo bootstrap

这来自银杏的writing your first test docs :

To write Ginkgo tests for a package you must first bootstrap a Ginkgo test suite. Say you have a package named books:

$ cd path/to/books
$ ginkgo bootstrap

ahillman3 的建议对正常测试有效,但如果您使用 Ginkgo 进行测试,则该建议不适用。

关于go - 没有发现银杏测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44782807/

相关文章:

multithreading - 所有goroutines死锁

go - Gomega ghttp返回500状态代码

go - 银杏包装检测

go - 使用 go 和 ginkgo 测试标准输出

go - 测试函数是否被调用

thread-safety - Go闭包捕获变量和共享数据?

go - Golang 中的未定义错误

go - 无法中止()上下文 - Gin