确定NUnit测试是否已在PowerShell中完成运行
我似乎找不到回调或确定NUnit测试是否在PowerShell脚本中完成运行的好方法。我已经提出了下面的解决方案,但它并不可靠。有谁知道我该怎么做吗? 或者,也许努尼特有一些我不知道的黑魔法?确定NUnit测试是否已在PowerShell中完成运行,powershell,nunit,nunit-console,Powershell,Nunit,Nunit Console,我似乎找不到回调或确定NUnit测试是否在PowerShell脚本中完成运行的好方法。我已经提出了下面的解决方案,但它并不可靠。有谁知道我该怎么做吗? 或者,也许努尼特有一些我不知道的黑魔法?提前谢谢 #SLN1: Could check TestResults.xml file length and loop until we're sure tests have ran #- Then Send command to write to file in S3 Bucket. Then have
提前谢谢
#SLN1: Could check TestResults.xml file length and loop until we're sure tests have ran
#- Then Send command to write to file in S3 Bucket. Then have server script check for a change to that bucket.
$NUNIT_EXE = "C:\Program Files (x86)\NUnit\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe\"
$TESTING_DLL = "C:\CITestFramework\bin\Debug\CITESTS.dll"
#NUnit3 places test results where tests are ran from, so go local
$TESTING_RESULT_FILE = "TestResult.xml"
Write-Host "Removing old test results."
If (Test-Path $TESTING_RESULT_FILE){
Remove-Item $TESTING_RESULT_FILE
}
Write-Host "Starting Tests..."
$PROCESS = Start-Process $NUNIT_EXE $TESTING_DLL
$count = 0
$prev_size = 0
$wait = 5
Do{
If (Test-Path $TESTING_RESULT_FILE){
$file = Get-Item $TESTING_RESULT_FILE
Write-Host "Size:",$file.Length
Write-Host "Prev Size:", $prev_size
if($file.Length -gt $prev_size){
$prev_size = $file.Length
$wait = 5
$count = 0
} else {
if($file.Length -eq $prev_size){
$count += 1
$wait = 15
}
}
}Else{
Write-Host "File Does Not Exist Yet..."
}
Start-Sleep -s $wait
}Until($count -eq 7)
Write-Host "Tests completed."
#//Write to S3 bucket
啊。。。在这里找到我的答案:需要等待进程并检查退出代码。这很有效。啊。。。在这里找到我的答案:
需要等待进程并检查退出代码。这很好。**并且在启动过程中添加-Wait不起作用。
和$NUNIT\u EXE$TESTING\u DLL;如果($LastExitCode-eq 0){…}
?**并将-Wait添加到启动进程中不起作用。和$NUNIT\u EXE$TESTING\u DLL;如果($LastExitCode-eq 0){…}
?