[英]Running test using Terratest but it throws “no test files” error
I am working on terratest for terraform in Azure.我正在为 Azure 中的 terraform 进行 terratest。 Currently making use of an example code as given in the following link- https://docs.microsoft.com/en-us/azure/developer/terraform/best-practices-end-to-end-testing .
目前正在使用以下链接中给出的示例代码- https://docs.microsoft.com/en-us/azure/developer/terraform/best-practices-end-to-end-testing 。
When I try to run go test -v
it gives out [no test files], not sure why.当我尝试运行
go test -v
它给出[无测试文件],不知道为什么。
Can anyone help?任何人都可以帮忙吗?
You need to make sure that when you are go test
to be inside the test
directory.您需要确保当您在
test
目录中进行go test
时。 cd
into test directory and than run the command cd
进入测试目录,然后运行命令
Files containing tests should be called name_test, with the _test suffix.包含测试的文件应称为 name_test,并带有 _test 后缀。 They should be alongside the code that they are testing.
他们应该在他们正在测试的代码旁边。
Initialize golang modules with eg go mod init azure使用例如 go mod init azure 初始化 golang 模块
To run the tests call go test -v./ -timeout 10m要运行测试,请调用 go test -v./ -timeout 10m
From How to Write Go Code: https://golang.org/doc/code#Testing从如何编写 Go 代码: https://golang.org/doc/code#Testing
Note: The VS Code Go extension can help you better in troubleshooting syntactical issues.注意:VS Code Go 扩展可以帮助您更好地解决语法问题。
Additionaly the code provided in the MS Docs is outdated, so you might have to work on validation phase.此外,MS Docs 中提供的代码已过时,因此您可能必须在验证阶段工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.