没有找到银杏测试?

Vir*_*ren 5 go ginkgo gomega

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

\n

我的结构如下:

\n
events\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 button_not_shown_event.go\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 events_test\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 button_not_shown_event_test.go\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的button_not_shown_event_test.go样子

\n
package events_test\n\nimport (\n    "fmt"\n    . "github.com/onsi/ginkgo"\n    . "github.com/onsi/gomega"\n)\n\nvar _ = Describe("ButtonNotShownEvent", func() {\n  BeforeEach(func() {\n    Expect(false).To(BeTrue())\n  })\n  \n  Context("ButtonNotShownEvent.GET()", func() {\n        It("should not return a JSONify string", func() {\n           Expect(true).To(BeFalse())\n        })\n    })\n})\n
Run Code Online (Sandbox Code Playgroud)\n

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

\n

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

\n
go test ./app/events/events_test/button_not_shown_event_test.go  -v\n\ntesting: warning: no tests to run\nPASS\nok      command-line-arguments  1.027s\n
Run Code Online (Sandbox Code Playgroud)\n

很明显我在这里缺少一些东西。

\n

有什么线索吗?

\n

ahi*_*an3 1

你有几个问题。

  1. 您没有导入测试包。这应该位于 Ginkgo 生成的引导文件中。
  2. 引导程序文件还应包含testing.T 函数作为参数。例如(t *testing.T)
  3. 看起来您在 Ginkgo 过程中跳过了一两个步骤,导致先前的依赖项不存在。例如引导程序/存根。

此外,经过几个人的大量评论。您可能需要阅读 Ginkgo 文档,以确保您正确遵循他们的流程以正确设置测试。