我有一个 Azure DevOps 发布管道设置来根据此设置运行我的测试:
我的类文件包含一个单元测试,其中包含 4 个测试用例,方式如下:
[TestCase("test1", "arg1", "arg2")]
[TestCase("test2", "arg1", "arg2")]
[TestCase("test3", "arg1", "arg2")]
[TestCase("test4", "arg1", "arg2")]
public void Test(string name, string arg1, string arg2)
{
TestStuff();
}
当我运行测试时,会创建一个新版本并成功运行测试,但是仅找到 4 个测试中的 3 个。test2
由于某种原因找不到,只会被跳过。从日志中我可以看到总共发现了 146 个测试,这是准确的,但只有 3 个被“发现”
2020-08-19T23:41:28.3146168Z Number of testcases discovered : 146
2020-08-19T23:41:28.3166614Z ##[debug]PERF: DiscoverTests:AddTestCases: took 0.005 ms
2020-08-19T23:41:28.3290518Z Discovered tests 146 from sources
2020-08-19T23:41:28.3291189Z
=================================================================
2020-08-19T23:41:28.3291959Z ##[debug]DiscoverTests.PerformDiscovery : Test Discovery completed.
2020-08-19T23:41:28.3295732Z ##[debug]PERF WARNING: DiscoverTests.PerformDiscovery: took 11963.8108 ms
2020-08-19T23:41:28.3607538Z [RunStatistics]This execution slice with id '3', received '4' testcases to execute out of which '3' is discovered.
只有3个是什么意思discovered
?
如果我尝试自己运行该测试,那么整个事情都会失败
Microsoft.VisualStudio.TestService.VstestAdapter.TestsNotFoundException:在测试机器上未找到与源筛选条件匹配的测试程序集,或未发现与测试筛选条件匹配的测试。验证机器上是否存在测试组件并且测试过滤器标准是否正确。
我已经通过 VS (2019) 验证了测试已正确关联到测试用例,并且其他 3 个测试运行良好,它只是 1 个由于某种原因找不到的测试。