简体   繁体   English

使用 Terratest 运行测试,但会引发“无测试文件”错误

[英]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.

相关问题 运行管道测试时出现 Invalid on demand test run run id 0 错误 - Invalid on demand test run run id 0 error when running pipeline test VSTS测试代理未作为X64位进程运行测试版本,显示“不存在匹配测试”错误 - VSTS test agent is not running test build as X64 bit process, “no matching test is present” error is being displayed Azure terratest - 构建约束排除所有 Go 文件 - Azure terratest - Build constraints exclude all Go files Azure 管道 - terratest - 错误:请运行“az login”来设置帐户 - Azure pipeline - terratest - ERROR: Please run 'az login' to setup account 使用Self Provisioned测试装置运行负载测试时出现套接字异常 - Socket Exception while running load test with Self Provisioned test rig 使用 Azure 管道和 Docker 运行 mocha 测试 - Running mocha test with Azure pipelines and Docker 使用 BY TIMESTAMP 的带有滚动窗口的 Azure 流分析查询在测试中运行良好,但在运行作业结果时关闭 - Azure Stream Analytics query with tumbling window using BY TIMESTAMP works fine on test but is off in running job results 保护在Azure中运行的测试/测试版站点 - Protect test/beta site running in azure Maven 测试在本地运行,但在 Azure Pipeline 中使用 Azure DevOpz Maven POM.xml 失败所有测试给出时间 Elapsed 错误 - Maven test run locally but fail in Azure Pipeline using Azure DevOpz Maven POM.xml All test giving time Elapsed error 缺少部署在测试控制器上的文件(TFS 2013) - Missing files deployed on Test Controller (TFS 2013)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM