【问题标题】:Running test using Terratest but it throws "no test files" error使用 Terratest 运行测试,但会引发“无测试文件”错误
【发布时间】:2021-08-16 09:25:00
【问题描述】:

我正在为 Azure 中的 terraform 进行 terratest。目前正在使用以下链接中给出的示例代码-https://docs.microsoft.com/en-us/azure/developer/terraform/best-practices-end-to-end-testing。

当我尝试运行 go test -v 时,它给出了 [no test files],不知道为什么。

谁能帮忙?

【问题讨论】:

    标签: azure terraform terraform-provider-azure terratest


    【解决方案1】:

    您需要确保当您在go test 时位于test 目录中。 cd 进入测试目录,然后运行命令

    【讨论】:

    • 我已将目录更改为 .go 文件所在的目录..我仍然收到相同的错误
    【解决方案2】:

    包含测试的文件应称为 name_test,并带有 _test 后缀。他们应该在他们正在测试的代码旁边。

    使用例如初始化 golang 模块去 mod init azure

    要运行测试调用 go test -v ./ -timeout 10m

    来自如何编写 Go 代码:https://golang.org/doc/code#Testing

    注意:VS Code Go 扩展可以帮助您更好地解决语法问题。

    此外,MS Docs 中提供的代码已过时,因此您可能必须在验证阶段工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 2011-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多