gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 23:50:58 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com