如何解决没有测试匹配给定测试用例筛选器Azure Pipeline的问题?

how to resolve no test matches the given testcase filter azure pipeline?

提问人:Shahin ahammed 提问时间:10/14/2023 最后编辑:Daniel MannShahin ahammed 更新时间:10/16/2023 访问量:77

问:

enter image description here在交换之前,这些单元测试在 Azure 管道中执行。每次执行后,它都会向我显示这一点。

/TestAdapterPath:“F:\agents04_agent04\r2\a” 2023-10-12T20:10:01.1725408Z 开始测试执行,请稍候... 2023-10-12T20:10:04.1812614Z 共有 3 个测试文件与指定的模式匹配。 2023-10-12T20:10:04.2215572Z 责备:将故障转储实用程序附加到处理 testhost.net472.x86 (19376)。 2023-10-12T20:10:05.5133837Z 没有测试与 F:\agents04_agent04\r2\a\tests\DashboardApp.Deployment.Tests\DashboardApp.Deployment.Tests.dll F:\agents04_agent04\r2\a\tests\FtpLibrary.Tests\FtpLibrary.Tests.dll F:\agents04_agent04\r2\a\tests\Webservices.Deployment.Tests\Deployment.Tests.dll 中的给定测试用例筛选器匹配 2023-10-12T20:10:05.8662311Z 结果文件:F:\agents04_agent04_temp\TestResults\ga-build-vm$_ga-build-vm_2023-10-12_20_10_05.trx 2023-10-12T20:10:05.8907689Z Vstest.console.exe 退出,代码为 0。 2023-10-12T20:10:05.8908174Z **************** 已完成测试执行********************* 2023-10-12T20:10:05.8970097Z 测试结果文件:F:\agents04_agent04_temp\TestResults\ga-build-vm$_ga-build-vm_2023-10-12_20_10_05.trx 2023-10-12T20:10:05.9203010Z 未找到发布“F:\agents04_agent04_temp\TestResults\ga-build-vm$_ga-build-vm_2023-10-12_20_10_05.trx”的结果。 2023-10-12T20:10:06.1745166Z 创建测试运行:1240217 2023-10-12T20:10:06.1747100Z 发布测试结果:0TestCategory=BeforeSwap&TestCategory=prod&TestCategory=WebServices

我尝试更新 MSTest 框架并添加 MSTestAdapter。

azure-devops azure-pipelines mstest

评论

0赞 Daniel Mann 10/14/2023
这些测试类别值是枚举吗?如果是这样,实际的枚举值是多少?

答:

0赞 Kevin Lu-MSFT 10/16/2023 #1

没有与给定测试用例筛选器匹配的测试 TestCategory=BeforeSwap&TestCategory=prod&TestCategory=WebServices

根据错误消息,它指示测试类或测试方法中的测试类别不符合在管道任务中设置的测试用例筛选器。

测试用例过滤器中设置的测试类别需要同时满足 BeforeSwap、prod 和 webservice。

从单元测试代码的屏幕截图来看,类别为 BeforeSwap、prod 和 Web API。

您可以尝试将测试用例筛选器更改为以下值:TestCategory=BeforeSwap&TestCategory=prod&TestCategory=WebApi

例如:

- task: VSTest@2
  displayName: 'Test Assemblies'
  inputs:
    testAssemblyVer2: |
     **\$(BuildConfiguration)\*test*.dll
     !**\obj\**
    testFiltercriteria: 'TestCategory=BeforeSwap&TestCategory=prod&TestCategory=WebApi'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

或者,还可以检查测试类别定义中是否存在 WebServices 测试类别,并将其应用于实际的测试类。

评论

0赞 Shahin ahammed 10/16/2023
变量: TestCategory.Environment: 'prod' TestCategory.Component: 'WebServices' 步骤: - 任务: VSTest@2 displayName: '运行交换前测试' inputs: testAssemblyVer2: |**tests.dll !**\obj* testFiltercriteria: 'TestCategory=BeforeSwap&TestCategory=$(TestCategory.Environment)&TestCategory=$(TestCategory.Component)' diagnosticsEnabled: True 条件: and(succeeded(), ne(variables['DisableTests'], 'true'))
0赞 Shahin ahammed 10/16/2023
我确实像这样设置了我的 YAML。但它不起作用。
0赞 Kevin Lu-MSFT 10/16/2023
变量 TestCategory.Component 的值为 WebServices。但该值与测试项目中的测试类别不匹配(基于屏幕截图)。您可以将变量值更改为 WebApi 并检查它是否可以工作吗?TestCategory.Component: 'WebApi'