diff --git a/.gitignore b/.gitignore index dea0e1b..58c8909 100644 --- a/.gitignore +++ b/.gitignore @@ -136,6 +136,9 @@ _TeamCity* *.coverage *.coveragexml +# Pester coverage +coverage.xml + # NCrunch _NCrunch_* .*crunch*.local.xml diff --git a/tools/run-tests.ps1 b/tools/run-tests.ps1 index 7d063ba..7f3f5d2 100644 --- a/tools/run-tests.ps1 +++ b/tools/run-tests.ps1 @@ -10,20 +10,22 @@ $testDir = Join-Path $parentDir -ChildPath "test" # Debug info. $PSVersionTable | Out-String +$RequiredPesterVersion = "5.3.3" -# List Pester versions. -$pesterVersions = Get-Module -ListAvailable | Where-Object {$_.Name -eq "Pester" } -$pesterVersions | % { Write-Host $_.Name $_.Version } +$pesterVersions = Get-Module -ListAvailable | Where-Object {$_.Name -eq "Pester" -and $_.Version -eq $RequiredPesterVersion} if ($pesterVersions.Count -eq 0) { - Write-Warning "No Pester found, will install Pester 5.1.0" + Write-Warning "Pester $RequiredPesterVersion not found, installing it." $InstallPester = $true } if ($InstallPester) { - Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 5.1.0 + Install-Module Pester -Force -Scope CurrentUser -RequiredVersion $RequiredPesterVersion -SkipPublisherCheck } +Get-Module -Name Pester | Remove-Module +Import-Module Pester -RequiredVersion $RequiredPesterVersion + $FailedTests = Invoke-Pester $testDir -EnableExit -OutputFile "test/results.xml" -OutputFormat "NUnitXML" -CodeCoverage "$parentDir/FeatureFlags.psm1" if ($FailedTests -gt 0) { Write-Error "Error: $FailedTests Pester tests failed."