Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Pester 5 #9

Open
Clijsters opened this issue Jul 8, 2020 · 0 comments
Open

Migrate to Pester 5 #9

Clijsters opened this issue Jul 8, 2020 · 0 comments
Labels
help wanted up-for-grabs This issue is a good fit for new contributors

Comments

@Clijsters
Copy link
Owner

Clijsters commented Jul 8, 2020

Current behaviour:

Build fails, because the whole testing setup is made for Pester <4.9.x, and the Install-Script for AppVeyor installs the latest Pester-version (5.0.x)

Error:

----               
C:\projects\pstoggl
. .\AppVeyor\Test.ps1
Current working directory: C:\projects\pstoggl
You are using Legacy parameter set that adapts Pester 5 syntax to Pester 4 syntax. This parameter set is deprecated, and does not work 100%. The -Strict and -PesterOption parameters are ignored, and providing advanced configuration to -Path (-Script), and -CodeCoverage via a hash table does not work. Please refer to https://github.com/pester/Pester/releases/tag/5.0.1#legacy-parameter-set for more information.
Starting discovery in 20 files.
Discovery finished in 4.64s.
[-] General code style compliance.Module 'C:\projects\pstoggl\.codecovio\CodeCovIo.psm1'.passes the PSScriptAnalyzer Rule PSAlignAssignmentStatement 247ms (110ms|137ms)
 ValidationMetadataException: The argument is null. Provide a valid value for the argument, and then try running the command again.
 ParameterBindingValidationException: Cannot validate argument on parameter 'Path'. The argument is null. Provide a valid value for the argument, and then try running the command again.
 at <ScriptBlock>, C:\projects\pstoggl\PSToggl\PSToggl.Tests.ps1:15
[-] General code style compliance.Module 'C:\projects\pstoggl\.codecovio\CodeCovIo.psm1'.passes the PSScriptAnalyzer Rule PSAvoidUsingCmdletAliases 12ms (9ms|3ms)
 ValidationMetadataException: The argument is null. Provide a valid value for the argument, and then try running the command again.
 ParameterBindingValidationException: Cannot validate argument on parameter 'Path'. The argument is null. Provide a valid value for the argument, and then try running the command again.
 at <ScriptBlock>, C:\projects\pstoggl\PSToggl\PSToggl.Tests.ps1:15

And

Should : Legacy Should syntax (without dashes) is not supported in Pester 5. Please refer to migration guide at: https://pester.dev/docs/migrations/v3-to-v4
At C:\projects\pstoggl\Tests\PSToggl\Private\ConvertTo-TogglTask.Tests.ps1:40 char:37
+                 {$out.ToString()} | Should Not Throw
+                                     ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Should

Solution

Migrate to Pester 5.x

This basically involves:

  • Changing invocation in AppVeyor/Test.ps1
  • Remove version parameter from Install-Module in AppVeyor/Install.ps1
  • Assert-MockCalled should be replaced with Should -Invoke
  • You might want to take a look at the migration guide.

Quickfix until then:
Fix version to <=4.9.9 in AppVeyor/Install.ps1


Possible improvements:

While the coverage is overall quite ok, there is room for improvement for test structure in general.

Clijsters added a commit that referenced this issue Jul 8, 2020
Clijsters added a commit that referenced this issue Jul 8, 2020
In order to get Pester 5 running, several changes are required.
Variables have to be passed by -TestCases, `Should` Verbs are parameters
and so on

Relates to #9
Clijsters added a commit that referenced this issue Jul 8, 2020
…ning, several changes are required.Variables have to be passed by -TestCases, `Should` Verbs are parametersand so onRelates to #9
@Clijsters Clijsters added help wanted up-for-grabs This issue is a good fit for new contributors labels Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted up-for-grabs This issue is a good fit for new contributors
Projects
None yet
Development

No branches or pull requests

1 participant