Last active
May 10, 2018 17:57
-
-
Save soutarm/4ebafc4951811e68e1bbe00f172a53d4 to your computer and use it in GitHub Desktop.
AppVeyor PS function for running tests against Ghost Inspector. e.g. RunTest -suiteId '123xyz' -testName 'My Tests' -apiKey 'abc123'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function RunTest { | |
Param ([string]$suiteId, [string]$testName, [string]$apiKey) | |
Process { | |
Write-Host -backgroundcolor White -foregroundcolor Black ' - Running'$testName' - ' | |
$uri = 'https://api.ghostinspector.com/v1/suites/' + $suiteId + '/execute/?apiKey=' + $apiKey | |
$resp = Invoke-RestMethod -Method Get -Uri $uri | |
$resultUri = 'https://app.ghostinspector.com/suite-results/' + $resp.data.suiteResult[0] | |
if ($resp.data.passing.Contains($false)) { | |
# display each failed test | |
for($i=0; $i -lt $resp.data.passing.length; $i++) { | |
if (!$resp.data.passing[$i]) { | |
Add-AppveyorTest -Name $resp.data.testName[$i] -Framework 'Ghost Inspector' -FileName 'app.js' -Outcome Failed -Duration $resp.data.executionTime[$i] | |
} | |
} | |
throw ' - ' + $testName + ' FAILED - ' + $resultUri + ' - ' | |
} else { | |
$duration = ($resp.data.executionTime | measure -Maximum).maximum | |
Add-AppveyorTest -Name $testName -Framework 'Ghost Inspector' -FileName 'app.js' -Outcome Passed -Duration $duration | |
Write-Host -foregroundcolor Green ' -'$testName' PASSED - '$resultUri' - ' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment