我的 DotNetCoreCLI@2 任务有一个奇怪的问题。我试图在参数中添加过滤器,因此只能运行特定的测试。我正在使用 xUnit 和 Trait 属性来实现目标。
[Trait("Category", "UnitTest")]
任务:
task: DotNetCoreCLI@2
displayName: Run unit tests
inputs:
command: test
projects: '**/*.Tests.csproj'
publishTestResults: true
arguments: >-
-c $(buildConfiguration)
--collect:"XPlat Code Coverage"
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
--filter Category=UnitTest
但是当我更改/重命名属性名称时,它仍然会找到并运行测试。 示例:
[Trait("Category", "NotUnitTest")]
当我在本地运行 dotnet test 命令时,过滤起作用。当我更改/重命名属性时,不会运行任何测试(如预期)。
dotnet test --filter Category=UnitTest
有什么想法吗?
尝试使用引号。
--filter "Category=UnitTest"