Skip to content

Commit 642f69c

Browse files
committed
Upload Pester test results to AppVeyor if needed
1 parent 9ff62ce commit 642f69c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

appveyor.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,4 @@ build: false
1616

1717
#Kick off the CI/CD pipeline
1818
test_script:
19-
- ps: |
20-
. .\build.ps1 -Task Test
21-
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path '.\TestsResults-Mod.xml'))
22-
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path '.\TestsResults-Meta.xml'))
19+
- ps: . .\build.ps1 -Task Test

psake.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ task Pester-Meta -Depends Init {
4242

4343
$testResultsFile = "$projectRoot\TestResults-Meta.xml"
4444
$testResults = Invoke-Pester -Path $metaTests -PassThru -OutputFormat NUnitXml -OutputFile $testResultsFile
45+
# If in AppVeyor, upload test results
46+
if ($env:BHBuildSystem -eq 'AppVeyor') {
47+
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", "$ProjectRoot\$testResultsFile")
48+
}
4549
if ($testResults.FailedCount -gt 0) {
4650
$testResults | Format-List
4751
Write-Error -Message 'One or more Pester tests failed. Build cannot continue!'
@@ -57,6 +61,10 @@ task Pester-Module -depends Init {
5761

5862
$testResultsFile = "$projectRoot\TestResults-Module.xml"
5963
$testResults = Invoke-Pester -Path $unitTests -PassThru -OutputFormat NUnitXml -OutputFile $testResultsFile
64+
# If in AppVeyor, upload test results
65+
if ($env:BHBuildSystem -eq 'AppVeyor') {
66+
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", "$ProjectRoot\$testResultsFile")
67+
}
6068
if ($testResults.FailedCount -gt 0) {
6169
$testResults | Format-List
6270
Write-Error -Message 'One or more Pester tests failed. Build cannot continue!'

0 commit comments

Comments
 (0)