4.0.7
There is a guide for migrating from Pester 3 to Pester 4 to help you understand how the changes from Pester 3 to Pester 4 might affect your tests.
What's new since 3.4.6:
- Nested
Describe{}
andContext{}
. Now you can group tests using as manyContexts{}
andDescribe{}
blocks in any order. The use of mocks inDescribe{}
andContext{}
blocks nested deeper than one of each is still unexplored territory, so proceed with an appropriate amount of caution. The same goes for-Tag
, it only works on the top-levelDescribe/Context
. - Improved and color-coded summaries output by
Invoke-Pester
. No more misreading that all your tests are failed! Invoke-Pester
now includes the name of the script it is currently executing. No more guessing which file a failed test is in!- New assertion syntax with assertions as parameters to
Should
, that allows richer assertion vocabulary. Instead ofShould Not Be 10
you should writeShould -Not -Be 10
. - Custom
Should
operators. UseAdd-AssertionOperator
to write your own assertions. You could write an operator that allows you to write the working assertion$person | Should -BeAwesome
. - Array assertions.
Should
now inspects array contents. For example,1,2,3 | Should -Be 1,2,4
produces a user-friendly failure message. It even works recursively, so assertions like1,@(2,3) | Should -Be 1,@(2,4)
work. - Code coverage output in JaCoCo format. Use
Invoke-Pester
's-CodeCoverage
and-CodeCoverageOutputFile
parameters to produce code coverage reports that integrate with many CI tools. - Support for Gherkin.
- Smaller distribution package. Files not necessary for end-users are now omitted from Pester packages.
Breaking changes:
Contain*
assertions were renamed toFileContentMatch*
to avoid confusing its behavior with-contains
operator.Assert-VerifiableMocks
was renamed toAssert-VerifiableMock
Get-MockDynamicParameters
was renamed toGet-MockDynamicParameter
- Implementation of
Mock
changed significantly. That means you might observe some subtle differences in behavior. See the migration guide for more details.
Deprecated starting with 4.0.0:
- The
New-TestDriveItem
command has been deprecated. - The
-Quiet
parameter of theInvoke-Pester
command has been deprecated. Use-Show None
instead.
Removed starting with 4.0.0:
- The
-OutputXml
parameter of theInvoke-Pester
command was deprecated already, now it has been removed. Use-OutputFormat
and-OutputFile
instead.