azure-pipelines - 使用某些特征运行 xunit 测试

标签 azure-pipelines

我有一个 VSTS 构建,它在“Visual Studio 测试”任务中运行 Xunit 测试。当我运行所有测试时,这工作正常。

但是,我只想运行具有特定特征的测试。

我尝试在任务的“测试过滤条件”字段中输入值“Category=UnitTest”,但这样做会产生构建错误:

    Error: [xUnit.net 00:00:12.9299360] N1.Common.Testing: Exception discovering tests: No tests matched the filter because it contains one or more properties that are not valid (Category). Specify filter expression containing valid properties (DisplayName, FullyQualifiedName) and try again.

最佳答案

我现在可以让它工作了。

我已将“Category=CI”作为过滤器添加到 TFS“Visual Studio Test”任务中。 我必须向每个 xUnit 项目添加一个“Dummy”类别和一个 Dummy 类。

虚拟类只是:

    /// <summary>
    /// Do not delete. At least one "different" attribute is required that the Test Runner properly filters by attribute.
    /// See https://github.com/xunit/xunit/issues/610 for details
    /// </summary>

    [Dummy]
    public class DummyTest
    {
        [Fact]
        public void DummyForTFSTestRunner()
        { }
    }

这使得测试运行者能够正确发现我的 CI 测试。 请参阅GitHub issue了解详情

关于azure-pipelines - 使用某些特征运行 xunit 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38614025/

相关文章:

azure-devops - Azure DevOps : how to disable CI trigger on a YAML template pipeline?

azure-devops - 在 Azure DevOps 构建管道期间创建 json 文件

azure-devops - 从引用的管道资源中获取最新的构建 ID

ios - FaSTLane 使用 azure Pipeline 在运行脚本 '[CP] Embed Pods Frameworks' 时卡住

azure-devops - yaml 文件问题 "mapping values are not allowed in this context"

continuous-integration - Azure Pipeline Nuget软件包版本控制方案,如何获取“1.0。$(Rev:r)”

azure - 如何使用 Azure DevOps 在 YAML 管道中输出替换 token ?

docker - 在 Azure Pipeline 作业中安装 docker run

entity-framework - VSTS 构建如何为 EF Core 添加更新数据库命令 Code First

Azure YAML-Pipeline 跳过作业,我不知道为什么