PowerShellDer PowerShell-Agent stellt mehrere Objekte für PowerShell-Skripte zur Verfügung:
Zum Aufrufen von nunit aus Powershell können Sie einen Befehl nutzen wie:
$output = & $nunitLocation $testDll --test=$testCaseName 2>&1
Um exponierte Objekte zu nutzen, muss das PowerShell-Skript ihre Benutzung deklarieren, indem der folgende Befehl eingegeben wird:
param($variables, $tempDir, $aquaCallback)
Beachten Sie, dass alle genutzten Variablen in einem einzelnen "param"-Befehl deklariert werden müssen. Ein Beispielskript, dass diese Objekte benutzt:
# Beispiel PowerShell Skript, dass .NET Objekte und Testfallvariablen von aqua benutzt
param($variables, $tempDir, $aquaCallback)
$text = new-object System.Text.StringBuilder
$date = [System.DateTime]::Now
$text.AppendLine($date.ToLongDateString())
$text.AppendLine($date.ToLongTimeString())
echo "$text" > script-sample.log
foreach ($var in $variables)
{
$varName = $var.Name
$varValue = $var.Value
echo "Variable: $varName : $varValue" >> script-sample.log
}
# Mögliche Typen von [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]
# SUTError, ScriptExecutionError, PreparationError, ExecutionError, InformationalInfo, InformationalDebug, InformationalWarn, InformationalSuccess
$aquaCallback.SendMessage("hello, I was sent from script", [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]::InformationalWarn, "my category");
$aquaCallback.SendMessageWithScreenshot("and this is Screenshot", "c:\sample.jpg", [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]::InformationalWarn, "my category");
dir $tempDir >> script-sample.log
$aquaCallback.AddExecutionAttachment("script-sample.log");
while ($true)
{
if ($aquaCallback.StopRequest)
{
$aquaCallback.SendMessage("Aborting on StopRequest", [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]::InformationalWarn, "my category");
return "Aborted"
}
Start-Sleep -s 10
aquaCallback.SendMessage("Looping in PowerShell…", [aqua.ProcessEngine.WebServiceProxy.ExecutionLogMessageType]::InformationalWarn, "my category");
}
# Gibt den Status der Skriptausführung zurück. Einen von: Ready, Blocked, Fail, Aborted (Bereit, Blockiert, Gescheitert, Abgebrochen)
return "Ready"
|