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
*.coveragexml
# Pester coverage
coverage.xml
# NCrunch
_NCrunch_*
.*crunch*.local.xml

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

@ -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."