-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest.ps1
33 lines (24 loc) · 1.17 KB
/
test.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#---------------------------------#
# Header #
#---------------------------------#
Write-Host "Testing:" -ForegroundColor Yellow
Write-Host "Current working directory: $pwd"
#---------------------------------#
# Run Pester Tests #
#---------------------------------#
$files = Get-ChildItem ".\psPAS" -Include *.ps1 -Recurse
$res = Invoke-Pester -Path ".\Tests" -OutputFormat NUnitXml -OutputFile TestsResults.xml -CodeCoverage $files -PassThru
Write-Host 'Uploading Test Results'
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.xml))
Write-Host 'Formating Code Coverage'
$coverage = Format-Coverage -PesterResults $res -CoverallsApiToken $($env:coveralls_key) -BranchName $($env:APPVEYOR_REPO_BRANCH)
Write-Host 'Publishing Code Coverage'
Publish-Coverage -Coverage $coverage
#---------------------------------#
# Validate #
#---------------------------------#
if (($res.FailedCount -gt 0) -or ($res.PassedCount -eq 0)) {
throw "$($res.FailedCount) tests failed."
} else {
Write-Host 'All tests passed.' -ForegroundColor Green
}