feat: only run on Pester 5.3.3 (#32)

* feat: only run on Pester 5.3.3

* fix: skip publisher check when installing Pester

This is a legitimate skip, as the publisher between major Pester versions may
change.

* feat: ignore coverage results
This commit is contained in:
Andrea Spadaccini 2022-07-04 15:46:52 +02:00 коммит произвёл GitHub
Родитель e08908d5a0
Коммит 5f8fa49420
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 10 добавлений и 5 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -136,6 +136,9 @@ _TeamCity*
*.coverage *.coverage
*.coveragexml *.coveragexml
# Pester coverage
coverage.xml
# NCrunch # NCrunch
_NCrunch_* _NCrunch_*
.*crunch*.local.xml .*crunch*.local.xml

Просмотреть файл

@ -10,20 +10,22 @@ $testDir = Join-Path $parentDir -ChildPath "test"
# Debug info. # Debug info.
$PSVersionTable | Out-String $PSVersionTable | Out-String
$RequiredPesterVersion = "5.3.3"
# List Pester versions. $pesterVersions = Get-Module -ListAvailable | Where-Object {$_.Name -eq "Pester" -and $_.Version -eq $RequiredPesterVersion}
$pesterVersions = Get-Module -ListAvailable | Where-Object {$_.Name -eq "Pester" }
$pesterVersions | % { Write-Host $_.Name $_.Version }
if ($pesterVersions.Count -eq 0) { 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 $InstallPester = $true
} }
if ($InstallPester) { 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" $FailedTests = Invoke-Pester $testDir -EnableExit -OutputFile "test/results.xml" -OutputFormat "NUnitXML" -CodeCoverage "$parentDir/FeatureFlags.psm1"
if ($FailedTests -gt 0) { if ($FailedTests -gt 0) {
Write-Error "Error: $FailedTests Pester tests failed." Write-Error "Error: $FailedTests Pester tests failed."