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

查看:116
本文介绍了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管道仅报告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天全站免登陆