This integration launches testing whenever there’s a new code push to the Visual Studio Online (VSO) repository.
Steps to integrate Visual Studio Online:
Push the script “UsetraceRun.ps1” (find example below) to your version control in VSO.
Login to Visual Studio Online
Add new build definition BUILD->[+]->Empty (start with empty definition)
Add Build Step…->Utility->PowerShell (run a powershell script)
Build->Powershell: Script filename -> “UsetraceRun.ps1”
Triggers->Check Continuous integration (build each check-in)
Save “Usetrace Run”
If any of the traces fail, the build will fail in VSO.
Example for “UsetraceRun.ps1” script
Copy & paste the script to your version control and replace YOUR-PROJECT-ID with the ID from Settings->Project.
$projectId = "YOUR-PROJECT-ID"
$pollTimeoutMinutes = 20
$startBatchResource = "http://api.usetrace.com/api/project/$projectId/execute_all"
$startBatchRequest = @"
{
"requiredCapabilities":[
{"browserName":"chrome"},
{"browserName":"firefox"}
],
"tags":["smoke"]
}
"@$batchId = Invoke-RestMethod -ContentType "application/json" -Method Post -Uri $startBatchResource -Body $startBatchRequest
Write-Output "Batch ID: $batchId"$timeout = new-timespan -Minutes $pollTimeoutMinutes
$sw = [diagnostics.stopwatch]::StartNew()while ($sw.elapsed -lt $timeout){
$batchStatusResource = "http://api.usetrace.com/api/results/$batchId/xunit"
$batchStatus = Invoke-RestMethod -ContentType "application/json" -Method Get -Uri $batchStatusResource
$ts = Get-Date -Format HH:mm.ss
Write-Output "$ts Batch is running..."
if ($batchStatus.statusCode -ne 404){
$ts = Get-Date -Format HH:mm.ss
Write-Output "$ts Batch completed."
$batchReport = $batchStatus
$batchReport.Save("$PSScriptRoot\BatchResult.xml")
[int]$errorCount = [convert]::ToInt32($batchReport.testSuite.errors, 10)
[int]$failureCount = [convert]::ToInt32($batchReport.testSuite.failures, 10)
Write-Output $batchReport.testSuite
if($errorCount -gt 0 -or $failureCount -gt 0){
throw "Batch failed!"
}
exit 0
}
start-sleep -seconds 5
}
throw "Batch timed out!"