Testsuite über PowerShell ausführen

    Verwenden Sie das folgende PowerShell-Skript, um eine Testsuite auszuführen und ein Resultat zurück zu erhalten.

    Wichtig:
    Wenn Sie das PowerShell-Skript auf dem BiG EVAL Server selbst ausführen möchten, müssen Sie ggf. folgenden KB-Artikel von Microsoft beachten. Ansonsten könnte es sein, dass sie einen 401 Fehler erhalten: https://support.microsoft.com/en-ca/help/896861/you-receive-error-401-1-when-you-browse-a-web-site-that-uses-integrate

     

    # Defines the base-url of the BiG EVAL API and instance
    $baseUrl = "http://localhost:1710/api/v1/default/"

    # The ID of the suite to execute
    $suiteId = 3

    # The ID of the test to check later
    $testId = 12

    # Execute the suite. This creates a new run
    $executeResult = Invoke-RestMethod -Uri ($baseUrl + "suites/" + $suiteId + "/execute") -UseDefaultCredentials

    # Poll the status of the run until it finishes
    $currentStatus.status = "RUNNING"
    while($currentStatus.status -ne "FINISHED")
    {
    # Wait a specific amount of time until polling
    Start-Sleep -Milliseconds 5000

    # Fetch the status and testresults
    $testResultStructure = Invoke-RestMethod -Uri ($baseUrl + "statistics/testresultsscoped?runScope=3&runScopeIdentifier=3&skip=0&take=1") -UseDefaultCredentials
    $currentStatus = $testResultStructure.items[0]

    # Write the run-status to the console
    # Write-Host $currentStatus
    }

    # Write some statistics to the console
    Write-Host ("Run-ID: " + $currentStatus.runId)
    Write-Host ("Tests run: " + $currentStatus.totalCount)
    Write-Host ("Tests succeeded: " + $currentStatus.succeededCount)
    Write-Host ("Tests failed: " + $currentStatus.failedCount)
    Write-Host ("Tests excepted: " + $currentStatus.exceptionsCount)
    Write-Host ("Success-Rate: " + ($currentStatus.succeededCount / $currentStatus.totalCount * 100) + "%")


    # Get testresults of a specific test
    $runId = $currentStatus.runId
    $runResults = Invoke-RestMethod -Uri ($baseUrl + "runs/" + $runId + "?includeDetails=true") -UseDefaultCredentials
    $testResult = $runResults.testResults | where {$_.testId -eq $testId}
    Write-Host
    Write-Host ("Test-ID: " + $testResult.testId)
    Write-Host ("Test-Name: " + $testResult.testName)
    Write-Host ("Test-Status: " + $testResult.status)

    # Return exit-code depending on the test-result
    if($testResult.status -eq "SUCCESS")
    {
    exit 0
    }
    else
    {
    exit -1
    }
    War dieser Beitrag hilfreich?
    0 von 0 fanden dies hilfreich

    Kommentare