我有一个 Azure DevOps 管道,其中 40% 的测试处于非事件状态。该报告显示 60% 的通过率,而在我看来,它应该显示 100%,因为通常通过率是根据执行的测试而不是编写的测试范围来定义的。
我搜索了 Microsoft 文档,其中唯一的答案是检查 stackoverflow,但我没有看到此问题的报告。
有人可以告诉我如何从报告中过滤掉不活动的测试吗?谢谢!
最佳答案
The report shows 60% pass rate when it should (in my opinion) show 100%, because usually the pass rate is defined against tests executed not the universe of tests that were written.
场景:
我有五个测试方法,其中 3 个会成功,其中 1 个会失败,第五个测试方法标记有 Ignore
属性。
重现相同问题:
对于 VSTest 任务的测试报告,忽略的测试将被标记为other
。总测试是 Passed+Failed+Others
而不是 Passed+Failed
的摘要,因此您得到的是 60%,而不是 100%。
这是one discussion关于类似的问题,据我所知,团队已经进一步调查是否在汇总计算中使用忽略的测试来积压。您可以在那里发表评论以请求更新。
Would someone please tell me how I can filter the inactive tests out of the report? Thanks!
我的工作方法是使用 TestCategory
而不是 Ignore
属性。从 Ignore
更改为 TestCategory
:
来自:
[Ignore]
[TestMethod]
public void TestMethod5()
{
bool value = true;
if (value.Equals(true))
{
Console.WriteLine("True");
}
}
致:
[TestCategory("TestsToBeIgnored")]
[TestMethod]
public void TestMethod5()
{
bool value = true;
if (value.Equals(true))
{
Console.WriteLine("True");
}
}
配置 VSTest 测试过滤器,添加过滤器 TestCategory!=TestsToBeIgnored
。
这样总测试确实排除了我需要忽略的测试,并且百分比可以准确。 (测试过滤器
选项适用于 Azure Devops 管道、本地 vstest 命令行和 VS 测试管理器)
关于azure-devops 管道测试通过报告使用了错误的数学,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63347385/