.net-core - 如何仅使用 dotnet vstest 运行以前失败的测试

标签 .net-core vstest vstest.console.exe

我有一个包含 10,000 多个测试的测试套件,有时只想使用 dotnet vstest 重新运行上次运行失败的测试。命令行界面。

最佳答案

我最终使用了以下 PowerShell 命令,根据最新的 trx 再次仅运行以前失败的测试。文件在 .\TestResults\ :
dotnet vstest '.\bin\Debug\netcoreapp3.0\MyTests.dll' /Logger:trx /Tests:"$((Select-Xml -Path (gci '.\TestResults\' | sort LastWriteTime | select -last 1).FullName -XPath "//ns:UnitTestResult[@outcome='Failed']/@testName" -Namespace @{"ns"="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"}).Node.Value | % {$_ -replace '^My\.Long\.And\.Tedious\.Namespace\.', ''} | % {$_ -replace '^(.*?)\(.*$','$1'} | Join-String -Separator ','))"
请注意,最大命令行长度有一个字符限制,当许多测试以前失败时很容易被击中。
使用 % {$_ -replace '^My\.Long\.And\.Tedious\.Namespace\.', ''}部分,如果可以的话,摆脱命名空间前缀。

关于.net-core - 如何仅使用 dotnet vstest 运行以前失败的测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57980972/

相关文章:

Docker - 如何连接到 SSL 上的 host.docker.internal?

entity-framework - 如何在 EF.Core 中构建动态 where 过滤器来处理等于、LIKE、gt、lt 等

testing - 在Azure Pipelines上执行Visual Studio测试任务: Updating DontShowUI to 1 failed due to exception

asp.net - 在 Azure 管道上使用 VSTest 和报告生成器工具生成测试覆盖率时如何忽略某些文件

jenkins - 为什么 vstest.console.exe 突然给我一个关于隔离模式的警告?

c++ - VSTest.console 按属性筛选 native c++ 单元测试

c# - vstest.console.exe 只为 Moq.dll 生成封面

c# - 检查目录是否挂载了 .NET

c# - .NET Core 将本地 API 表单数据发布请求转发到远程 API

MsTest 的 SonarQube 测试覆盖率