Azure Pipelines 将 xUnit InlineData 算作一项测试而不是多项测试 [英] Azure Pipelines counts xUnit InlineData as one test instead of many

查看:17
本文介绍了Azure Pipelines 将 xUnit InlineData 算作一项测试而不是多项测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的 Azure Pipelines 管道中,我们有采用 InlineData 参数的 .NET Core xUnit 测试方法.测试运行器运行所有测试方法,并在其控制台输出中正确报告每个 InlineData 实例作为测试运行.但是,Azure Pipelines 报告的测试计数较低,因为它将 [Theory] ​​测试计为一个测试(而不是对 InlineData 的每个实例进行一个测试).

In our Azure Pipelines pipeline we have .NET Core xUnit test methods that take an InlineData parameter. The test runner runs all test methods and correctly reports in its console output each InlineData instance as a test run. However, Azure Pipelines reports a lower test count because it counts the [Theory] tests as one test (instead of one test for every instance of InlineData).

如何让 Azure Pipelines 将所有 InlineData 实例报告为测试?

How can I make Azure Pipelines report all instances of InlineData as tests?

例如,这是一个作业输出.

As an example, here's a job output.

测试作业报告了 9 个测试.9 个测试包括两个 [Theory] ​​方法,每个方法有两个 InlineData:

The test job reports 9 tests. 9 tests include two [Theory] methods each with two InlineData:

Azure Pipelines 只报告 7 个而不是预期的 9 个测试:

Azure Pipelines only reports 7 instead of the expected 9 tests:

推荐答案

我用最新版本的 dotnet core sdk ie 重现了同样的问题.SDK 版本:3.1.402.

I reproduced the same issue with the latest version dotnet core sdk ie. SDK Version: 3.1.402.

当我使用 3.1.101 版本的 dotnet core sdk 时.测试摘要显示了正确的测试计数.

When i used 3.1.101 version dotnet core sdk. The Test summary showed the correct test counts.

您可以尝试添加 在管道顶部使用 .NET Core 任务,并将 .NET Core SDK 的 version 指定为 3.1.101.见下文:

You can try adding Use .NET Core task at the top of your pipeline and specify version of .NET Core SDK to be 3.1.101. See below:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 3.1.101'
  inputs:
    version: 3.1.101

这篇关于Azure Pipelines 将 xUnit InlineData 算作一项测试而不是多项测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆