diff --git a/CI/Invoke-Test.ps1 b/CI/Invoke-Test.ps1 index 3027a7a..27e1334 100644 --- a/CI/Invoke-Test.ps1 +++ b/CI/Invoke-Test.ps1 @@ -13,24 +13,30 @@ param( ) $srcPath=Resolve-Path -Path "$PSScriptRoot\..\Src" $outputFile=[System.IO.Path]::GetTempFileName()+".xml" -$splat=@{ - Script=$srcPath - PassThru=$true - OutputFormat="NUnitXml" - OutputFile=$outputFile - ExcludeTag=$ExcludeTag - Tag=$Tag -} + +# https://pester-docs.netlify.app/docs/commands/New-PesterConfiguration +$pesterConfiguration=New-PesterConfiguration +$pesterConfiguration.Run.Path=$srcPath +$pesterConfiguration.Run.PassThru=$true +$pesterConfiguration.Run.Path=$srcPath +$pesterConfiguration.Filter.Tag=$Tag +$pesterConfiguration.Filter.ExcludeTag=$ExcludeTag + +$pesterConfiguration.TestResult.Enabled=$true +$pesterConfiguration.TestResult.OutputFormat="NUnitXml" +$pesterConfiguration.TestResult.OutputPath=$outputFile + +$pesterConfiguration.Output.Verbosity="Detailed" +#$pesterConfiguration.Output.Verbosity="Diagnostic" + if($CodeCoverage) { - $codeCoveragePath=$outputFile.Replace(".xml",".codecoverage.xml") - $splat+=@{ - CodeCoverage=Get-ChildItem -Path $srcPath -Exclude @("*.Tests.ps1","*.NotReady.ps1","Src\Tests\**") -Filter "*.ps1" -Recurse|Select-Object -ExpandProperty FullName - CodeCoverageOutputFile=$codeCoveragePath - } + $pesterConfiguration.CodeCoverage.Enabled=$true +# $pesterConfiguration.CodeCoverage.OutputFormat="JaCoCo" + $pesterConfiguration.CodeCoverage.OutputPath=$outputFile.Replace(".xml",".codecoverage.xml") } -$pesterResult=Invoke-Pester @splat +$pesterResult=Invoke-Pester -Configuration $pesterConfiguration if($CodeCoverage) { $pesterResult|Select-Object @{ @@ -51,11 +57,11 @@ if($CodeCoverage) switch($PSCmdlet.ParameterSetName) { 'AppVeyor' { (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $outputFile) + if ($pesterResult.FailedCount -gt 0) { + throw "$($pesterResult.FailedCount) tests failed." + } } 'Console' { } -} -if ($pesterResult.FailedCount -gt 0) { - throw "$($pesterResult.FailedCount) tests failed." } \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 41ba691..4f62618 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,10 @@ version: 1.0.{build} image: Ubuntu1804 init: -- pwsh: Get-ChildItem ENV:\ +- pwsh: >- + $PSVersionTable + + Get-ChildItem ENV:\ install: - pwsh: >- $modules=@( @@ -13,8 +16,9 @@ install: Get-Module -Name $modules -ListAvailable|Format-Table Name,Version,Path build: off -test_script: -- pwsh: '& .\CI\Invoke-Test.ps1 -AppVeyor' +# There are no tests and Pester v5 throws error +# test_script: +# - pwsh: '& .\CI\Invoke-Test.ps1 -AppVeyor' for: - @@ -24,11 +28,11 @@ for: environment: NuGetAPIKey: - secure: aU9vw9DIzXNRjmiS8ZtYvFZij4RUvdpeqoR1XaaemfKUjdc3y2Qw+qzCNSHsLXxY + secure: dQfAg96Oa5m/lEerqsiYFi87FsxKxtVWG4ejbQBLDyxxymuNuf2xvh8Lkf5dTqBc deploy_script: - pwsh: >- & .\CI\Publish-Module.ps1 -NuGetAPIKey $env:NuGetAPIKey notifications: - provider: GitHubPullRequest - template: "{{#passed}}:white_check_mark:{{/passed}}{{#failed}}:x:{{/failed}} [Build {{&projectName}} {{buildVersion}} {{status}}]({{buildUrl}}) (commit {{commitUrl}} by @{{&commitAuthorUsername}})" \ No newline at end of file + template: "{{#passed}}:white_check_mark:{{/passed}}{{#failed}}:x:{{/failed}} [Build {{&projectName}} {{buildVersion}} {{status}}]({{buildUrl}}) (commit {{commitUrl}} by @{{&commitAuthorUsername}})"