我有一个 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/