Azure Devops - [DataTestMethod] 类型的单元测试方法未在 YAML 构建中执行

Azure Devops - Unit test methods of type [DataTestMethod] not executed in YAML builds

同时 运行 单元测试作为 Azure CI 管道 (YAML) 的一部分

测试方法 [DataTestMethod] 未执行。 但是 [TestMethod] 工作正常。

以下 yaml 在最新版本的 Azure Devops(云)上运行良好。

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: path/to/.csproj
    arguments: '--configuration $(BuildConfiguration)'

确保它在您的本地机器上也能正常工作,以避免代码出现任何问题。

回答你的奖励问题

” 那么你可以添加一个测试类别并在类别上过滤它,或者如果你有多个测试项目则在测试项目上过滤它。

我可能会用测试类别来做

[Category("MainTest")] 
[Test] 
  public void TestMethod1() 
  { 
    Assert.True(true); 
  } 

然后在你的 yaml 中你应该可以做类似

的事情

testFiltercriteria: 'TestCategory=MainTest'