首页 > 解决方案 > 传达简单测试失败

问题描述

我第一次尝试使用 Convey。我的真实测试由于未知原因而失败,所以我创建了这个非常简单的测试,它以同样的方式失败。

   GO Convey
func TestSimple(t *testing.T) {
    Convey("Given Simple Test", t, func() {
        Convey("When Tested", func() {
            Convey("There should be a result", func() {
                i := 1
                So(i, ShouldEqual, i)
            })
        })
    })
}

我可能做错了什么,但是我不知所措

更新:我在另一个有效的应用程序中发现了一个旧的 Convey 测试。我将简单的测试复制到它并运行测试。有用。

有没有可能配置错误的东西?它是同一台服务器并进行设置。

测试截图

标签: gogoconvey

解决方案


它可能与您的 Go 版本以及您的(过时的)Go Convey 版本及其一些依赖项有关。也许您已经有一些依赖项$GOPATH/src,现在您更新到 Go 版本 1.12.*?

这发生在我从 Go 版本 1.10 更新到 Go 版本 1.12.6 时,我已经按照这里的详细信息,这帮助我修复了我的环境:https ://github.com/smartystreets/goconvey/issues/561#issuecomment -505525085

这些是我遵循的步骤:

  • cd $GOPATH/src/github.com/smartystreets/goconvey/ && git checkout master && git pull
    • 这应该相当于:go get github.com/smartystreets/goconvey
  • cd $GOPATH/src/github.com/smartystreets/assertions/ && git checkout master && git pull
    • 这应该相当于:go get github.com/smartystreets/assertions
  • go get -u golang.org/x/tools...
  • cd $GOPATH/src/github.com/jtolds/gls/ && git checkout master && git pull
    • 这应该相当于:go get github.com/jtolds/gls

推荐阅读