问题描述
-
我想通过使用 PowerShell 脚本的命令执行测试用例。
-
我想要执行这些测试的次数取决于
$HowManyTimes
变量。 -
我有可能在
$HowManyTimes
之前获得成功结果 例如,目前我将其设置为 3,但如果我在第二次尝试中获得成功结果会怎样。 -
我想忽略通过的特定测试用例并继续执行新的测试用例。 我已将命令的输出复制到
$OutPut
变量中,如下所示非展示信息
错误、失败和警告
失败:UnitTestProject1.TestClass.Addtest()
预期:30
但是是:45
非展示信息
试运行总结
总体结果:失败
非展示信息
下面是我写的脚本。
$XMLfile = 'Results.xml'
[XML]$Results = Get-Content $XMLfile
$HowManyTimes = 3 # How many time the script should run.
$TestCasetoExecute
$OutPut # Storing the result of command
$StopOperation = 0
for ($i=1; $i -le $HowManyTimes; $i++)
{
#I am reading the xml file which can have n test cases.
#For each loop on all the test case which are Failed.
foreach($Result in $Results.'test-run'.'test-suite'.'test-suite'.'test-suite'.'test-suite'.'test-case' | Where-Object {$_.result -eq "Failed"})
{
Write-Host "Failed Test Case -- fullname :" ($Result).fullname
$TestCasetoExecute = ($Result).fullname
Write-Host " Executing ====>" $TestCasetoExecute
Write-Host "-----------------------------------------"
$OutPut = nunit3-console.exe UnitTestProject1\bin\Debug\UnitTestProject1.dll --test=$TestCasetoExecute | Out-String
if($OutPut -Like "*Overall result: Failed*"){
Write-Host "If Block"
continue
}else{
Write-Host "else block Stop : "
break
}
}
}
请让我知道我需要做出哪些改变才能实现这一目标。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)