Skip to content

Releases: pester/Pester

5.5.0-rc1

16 Jun 12:24
Compare
Choose a tag to compare
5.5.0-rc1 Pre-release
Pre-release

What's Changed

  • Add support for NUnit3 XML-reports by @fflaten in #2208
  • Add -InParameterSet in Should -HaveParameter by @fflaten in #2273
  • CI Treat Errors As Warnings - ref #2295 by @erikgraa in #2296
  • Avoid nested array when using Should -ActualValue by @fflaten in #2315
  • Add missing container-parameters to Data before BeforeDiscovery by @fflaten in #2361
  • Fix ANSI sequence shown in Azure DevOps summary by @fflaten in #2352
  • Support Should -HaveParameter -DefaultValue for AliasInfo and scripts by @fflaten in #2353
  • Update error messages in Should -Throw by @fflaten in #2354
  • Fix parameter default values leaking to Data in user-provided Container by @fflaten in #2362
  • Rename TestCases parameter to ForEach by @nohwnd in #2311

Pester in Pester

  • Do not cleanup previous mocks in inner Invoke-Pester by @fflaten in #2337
  • Reattach TestDrive and TestRegistry after running inner Invoke-Pester by @fflaten in #2341

Perf

Internal fixes

  • Support building assembly with Debug configuration by @fflaten in #2339
  • Address analyzer suggestions for csharp-project by @fflaten in #2307
  • Add Run.Exit option clarification by @nohwnd in #2346
  • Fix false errors and broken CI-logs from P-tests by @fflaten in #2345
  • Upgrade to action/checkout v3 in PSSA workflow by @fflaten in #2351
  • Change sponsoring in readme by @nohwnd in #2363
  • Refactor Invoke-Pester and validate configuration early by @fflaten in #2317
  • Reorganize TestResuls-code into format-specific files by @fflaten in #2348

New Contributors

Full Changelog: 5.4.1...5.5.0-rc1

5.4.1

05 Apr 12:17
36b3164
Compare
Choose a tag to compare

What's Changed

Fixes

  • Fix Format-Collection for ICollection by @fflaten in #2265
  • Improve error when -HaveParameter is used with mock or alias for local function by @fflaten in #2233
  • HaveParameter is not dependent on format of param block by @brianwest in #2288
  • Fix script parameter leaking to another container with same Data by @fflaten in #2302
  • Include expected type in exceptions when type is not resolvable by @fflaten in #2271
  • Measure AfterAll and AfterEach as UserDuration by @fflaten in #2313
  • Update New-MockObject help by @fflaten in #2323
  • Fix docs typos by @martincostello in #2326
  • Replace ErrorAction SilentlyContinue with Ignore by @fflaten in #2318
  • Quote input string in BeNullOrEmpty error by @fflaten in #2329
  • Remove parameter attributes in reverse in Mock by @fflaten in #2334
  • Support profiling Pester with CC using Profiler v3.1 or v4 by @fflaten in #2321

Performance

  • Make initial Mock cleanup more performant by @nohwnd in #2332

Internal fixes

New Contributors

Full Changelog: 5.4.0...5.4.1

5.4.0

10 Jan 17:03
Compare
Choose a tag to compare

In this release there are many fixes and improvements thanks @fflaten to providing most of them!

ANSI colors for output

Output is now printed with colors in AzureDevOps:

image

To achieve that, Pester detects if the host supports ANSI codes and uses them to output the string. You can control this by this new option:

[PesterConfiguration]::Default.Output.RenderMode

Default Description                                                                                 Value
------- -----------                                                                                 -----
Auto    The mode used to render console output, options are Auto, Ansi, ConsoleColor and Plaintext. Auto

And optionally switch back to classical ConsoleColor, or a new PlainText mode that outputs just text without any embedded formatting.

Check Multiple aliases for Should -HaveParameter

Should -HaveParameter can now ensure that there are multiple aliases set for a parameter.

function f { 
    param( [Alias('UserName')] $Name ) 

    $Name     
}


Get-Command f | Should -HaveParameter Name -Alias 'n', 'UserName'

InvalidResult:
Line |
   1 | Get-Command f | Should -HaveParameter Name -Alias 'n', 'UserName'
     | Expected command f to have a parameter Name, with aliases 'n' and 'UserName', 
     | but it didn't have an alias 'n'.
  • Add support for multiple aliases (-Alias) to Should -HaveParameter by @dtewinkel in #2247

Always return to the original path

Pester captures the current path in which Invoke-Pester is invoked, and returns to this path after the execution of the test, even if the tests change it:

PS C:\projects\myModule> Invoke-Pester -Container (
    New-PesterContainer -ScriptBlock {
        Describe "d" {
            It "i" {
                Set-Location C:\Windows
            } 
        } 
    })

This will return back to C:\projects\myModule after your tests finish running.

  • Always return to original CWD after running Pester by @fflaten in #2189

Mocking in Manifest Modules

Mock, Should -Invoke and InModuleScope are now allowed for manifest modules.

  • Support mocking and execution in manifest modules by @fflaten in #2234

Additional changes and improvements

  • Add Should-example for exception-assertion by @fflaten in #2171

  • Updates to comment help and examples by @fflaten in #2196

  • Fix mocks with enum-parameters and ValidateRange by @fflaten in #2191

  • Don't run Get-CimInstance on Nanoserver by @irishismyname in #2192

  • Exit invoked testfile after interactive execution by @fflaten in #2218

  • Add ANSI support for output by @fflaten in #2199

  • Fix hang in New-TestRegistry when access is denied by @fflaten in #2236

  • Add support for assigning lists to StringArrayOption by @fflaten in #2232

  • Throw in Add-ShouldOperator when max number of operators is reached by @fflaten in #2231

  • Validate Should -Invoke is invoked in specified -Scope blocktype by @fflaten in #2230

  • Add -Because to Should -Invoke and -InvokeVerifiable by @fflaten in #2229

  • Fix NRE when assigning null to arrayoption in hashtable by @fflaten in #2219

  • Fix module installation in PowerShell 3 and 4 by @fflaten in #2214

  • Add help for dynamic operator parameters by @fflaten in #2170

  • Fix broken assertions link in help by @fflaten in #2205

  • Support int and double values when merging decimaloption by @fflaten in #2186

  • Update ExpandedPath before executing tests and blocks by @fflaten in #2254

Internal fixes and improvements

  • Bump Ubuntu 18.04 to 22.04 in CI test stage by @fflaten in #2252
  • Bump macOS 10.15 to 12 in CI test stage by @fflaten in #2253
  • Reorg Add-ShouldOperator P-tests to avoid 32 operator limit by @fflaten in #2248
  • Update CI build image and PesterTests to .NET 6 by @fflaten in #2249
  • Cache nugets in CI by @nohwnd in #2204
  • Use latest C# language version by @nohwnd in #2250
  • Cleanup remaining testcase param-blocks in tests by @fflaten in #2226
  • Use Start plugin-step for TestDrive and TestRegistry PSDrive cleanup by @fflaten in #2237
  • Fix support for PowerShell 6.0.4 by @fflaten in #2215
  • Sign format files by @nohwnd in #2212
  • Replace IsOriginalValue() with IsModified and fix merging and casting of default option values by @fflaten in #2201
  • Start interactive execution from BeforeDiscovery by @fflaten in #2217
  • Add GitHub Action to run PSScriptAnalyzer on PR and commit by @fflaten in #2221
  • Replace alias and positional parameter usage in Coverage.ps1 by @fflaten in #2225
  • Add -NoBuild for P-tests by @fflaten in #2200
  • Update issue templates to forms syntax by @fflaten in #2176
  • Update issue form templates by @fflaten in #2180
  • Exclude docs and support files from triggering CI by @fflaten in #2184
  • Minor improvements to build script by @fflaten in #2183
  • Remove v4 param-blocks from HaveParameter tests by @fflaten in #2224

New Contributors

Full Changelog: 5.3.3...5.4.0

5.4.0-rc1

06 Nov 10:50
Compare
Choose a tag to compare
5.4.0-rc1 Pre-release
Pre-release

In this release there are many fixes and improvements thanks @fflaten to providing most of them!

ANSI colors for output

Output is now printed with colors in AzureDevOps:

image

To achieve that, Pester detects if the host supports ANSI codes and uses them to output the string. You can control this by this new option:

[PesterConfiguration]::Default.Output.RenderMode

Default Description                                                                                 Value
------- -----------                                                                                 -----
Auto    The mode used to render console output, options are Auto, Ansi, ConsoleColor and Plaintext. Auto

And optionally switch back to classical ConsoleColor, or a new PlainText mode that outputs just text without any embedded formatting.

Check Multiple aliases for Should -HaveParameter

Should -HaveParameter can now ensure that there are multiple aliases set for a parameter.

function f { 
    param( [Alias('UserName')] $Name ) 

    $Name     
}


Get-Command f | Should -HaveParameter Name -Alias 'n', 'UserName'

InvalidResult:
Line |
   1 | Get-Command f | Should -HaveParameter Name -Alias 'n', 'UserName'
     | Expected command f to have a parameter Name, with aliases 'n' and 'UserName', 
     | but it didn't have an alias 'n'.
  • Add support for multiple aliases (-Alias) to Should -HaveParameter by @dtewinkel in #2247

Always return to the original path

Pester captures the current path in which Invoke-Pester is invoked, and returns to this path after the execution of the test, even if the tests change it:

PS C:\projects\myModule> Invoke-Pester -Container (
    New-PesterContainer -ScriptBlock {
        Describe "d" {
            It "i" {
                Set-Location C:\Windows
            } 
        } 
    })

This will return back to C:\projects\myModule after your tests finish running.

  • Always return to original CWD after running Pester by @fflaten in #2189

Mocking in Manifest Modules

Mock, Should -Invoke and InModuleScope are now allowed for manifest modules.

  • Support mocking and execution in manifest modules by @fflaten in #2234

Additional changes and improvements

  • Add Should-example for exception-assertion by @fflaten in #2171

  • Updates to comment help and examples by @fflaten in #2196

  • Fix mocks with enum-parameters and ValidateRange by @fflaten in #2191

  • Don't run Get-CimInstance on Nanoserver by @irishismyname in #2192

  • Exit invoked testfile after interactive execution by @fflaten in #2218

  • Add ANSI support for output by @fflaten in #2199

  • Fix hang in New-TestRegistry when access is denied by @fflaten in #2236

  • Add support for assigning lists to StringArrayOption by @fflaten in #2232

  • Throw in Add-ShouldOperator when max number of operators is reached by @fflaten in #2231

  • Validate Should -Invoke is invoked in specified -Scope blocktype by @fflaten in #2230

  • Add -Because to Should -Invoke and -InvokeVerifiable by @fflaten in #2229

  • Fix NRE when assigning null to arrayoption in hashtable by @fflaten in #2219

  • Fix module installation in PowerShell 3 and 4 by @fflaten in #2214

  • Add help for dynamic operator parameters by @fflaten in #2170

  • Fix broken assertions link in help by @fflaten in #2205

  • Support int and double values when merging decimaloption by @fflaten in #2186

  • Update ExpandedPath before executing tests and blocks by @fflaten in #2254

Internal fixes and improvements

  • Bump Ubuntu 18.04 to 22.04 in CI test stage by @fflaten in #2252
  • Bump macOS 10.15 to 12 in CI test stage by @fflaten in #2253
  • Reorg Add-ShouldOperator P-tests to avoid 32 operator limit by @fflaten in #2248
  • Update CI build image and PesterTests to .NET 6 by @fflaten in #2249
  • Cache nugets in CI by @nohwnd in #2204
  • Use latest C# language version by @nohwnd in #2250
  • Cleanup remaining testcase param-blocks in tests by @fflaten in #2226
  • Use Start plugin-step for TestDrive and TestRegistry PSDrive cleanup by @fflaten in #2237
  • Fix support for PowerShell 6.0.4 by @fflaten in #2215
  • Sign format files by @nohwnd in #2212
  • Replace IsOriginalValue() with IsModified and fix merging and casting of default option values by @fflaten in #2201
  • Start interactive execution from BeforeDiscovery by @fflaten in #2217
  • Add GitHub Action to run PSScriptAnalyzer on PR and commit by @fflaten in #2221
  • Replace alias and positional parameter usage in Coverage.ps1 by @fflaten in #2225
  • Add -NoBuild for P-tests by @fflaten in #2200
  • Update issue templates to forms syntax by @fflaten in #2176
  • Update issue form templates by @fflaten in #2180
  • Exclude docs and support files from triggering CI by @fflaten in #2184
  • Minor improvements to build script by @fflaten in #2183
  • Remove v4 param-blocks from HaveParameter tests by @fflaten in #2224

New Contributors

Full Changelog: 5.3.3...5.4.0-rc1

5.3.3

29 Apr 09:46
c79a6fa
Compare
Choose a tag to compare

Issues Fixed

  • Fix container failure output #2167

  • Test on less legacy systems #2164
  • Fix discord link in readme #2165

5.3.2

22 Apr 21:41
Compare
Choose a tag to compare

Issues Fixed

  • fix ForEach casing in Context #2111
  • Fix duplicate key exception in Should-InvokeInternal debug logging #2130
  • Adds default parameter set to New-MockObject #2160
  • Update help for New-Fixture #2097

  • Add discord-link and cleanup README #2102
  • Update devcontainer to NET 6.0 SDK and Powershell 7.2 #2116
  • Use newer images in our pipeline #2141

5.3.1

21 Sep 09:57
Compare
Choose a tag to compare

5.3.1

Issues Fixed

  • Bump 5.3.1
  • Fix Profiler code coverage in all loops #2081
  • fix accidental path input in interactive execution #2078
  • Fix mock object with 2 and more methods #2068

See full log here

5.3.0

17 Aug 08:36
Compare
Choose a tag to compare

Thanks @ArmaanMcleod, @fflaten and @johlju for all your contributions and support!

New Code Coverage mode

New way of measuring code coverage was added. It uses the core of Profiler to measure code coverage, instead of using breakpoints. This makes code coverage much much faster for bigger solutions. To enable it use UseBreakpoints option, and set it to $false:

$configuration.CodeCoverage.UseBreakpoints = $false

The option is marked as experimental, but from our tests it looks like the new approach is as accurate as the breakpoint based approach. The new approach does not yet work on PS3.

  • Add Profiler based code coverage #1937

Configure output for failed tests

New option for controlling the verbosity of failed tests was added:

$configurationOutput.StackTraceVerbosity

With the folloing levels:

None - All Stack trace is hidden
FirstLine - First line of stack trace is shown
Filtered - Filtered lines that belong to Pester. This is default.
Full - All stack trace is shown

None

More info and more screenshots are in the PR.

  • Limit output information for failed tests #1975

Shorter Detailed output

Output for discovery and filter was reduced in the Detailed and Diagnostic output, by moving discovery messages per file into the Diagnostic output, and hiding the Filter messages from the default Diagnostic output. All messages are still available via custom filter in $configuration.Debug.WriteDebugMessagesFrom.

More info and more screenshots are in the PR.
reduced output
diagnostic output

  • Update output for Discovery and Filter #1969

Automatic CI detection

Pester automatically detects if it is running in AzureDevOps or GitHub Actions and augments the output to report errors correctly.

Github actions output
Github actions log

The default is to autodetect CI but it can be disabled by:

$configuration.Output.CIFormat = 'None'

More info and more screenshots are in the PR.

  • Azure Devops & Github Actions error logging #1996

Override properties and methods via New-MockObject

New-MockObject can now override properties and methods on the created object. It counts the number of executions of a method and collects parameters provided to methods. It can also take an object as input and add properties and methods to it.

# Create an empty process object
$o = New-Object -TypeName 'System.Diagnostics.Process'
# Override Kill method to just return "killed"
$mockObject = New-MockObject -InputObject $o -Methods @{ Kill = { param($entireProcessTree) "killed" } }

$mockObject.Kill()
$mockObject.Kill($true)

# Inspect the history of invocations in `_<methodName>` 
$mockObject._kill

# Output:
# Call Arguments
# ---- ---------
#    1 {}
#    2 {True}

More examples are in the tests: https://github.com/pester/Pester/blob/main/tst/functions/New-MockObject.Tests.ps1
Real life-examples here: https://youtu.be/8GWqkGvV3H4?t=2517

  • Add Ability to Override Properties on New-MockObject #1838

Skip remaining tests when any fails

A new option was added, that allows skipping the rest of the execution when any test fails. It can skip tests in the current block and all child blocks, as well as skip all remaining tests in the file, or in the whole run.

$configuration.Run.SkipRemainingOnFailure = 'Block'

The following scopes are supported:

Block - Skip all remaining tests in current bloc k(including child blocks and tests) after a failed test.
Container - Skip all remainng tests in the container (file or scriptblock) after a failed test.
Run - Skip all tests across all containers in a run after a failed test.
None - Default, keep original behaviour.

Run

We used Skipped test result to skip those tests, but there was a lively discussion about how this should be achieved. Share your feedback if you have any.

More info and more screenshots are in the PR.

  • Added Run.SkipRemainingOnFailure option #2023

Log conflicting varibles in Mocks

Mocks pick up all variables from your tests. When your variable names are the same as parameter names of a mocked command this can lead to unexpected results in ParameterFilter. We added a new message in the Diagnostic log that warns you that a variable is in conflict with a parameter name.

It 'filter should not pass due to test-variable' {
    $SamAccountName = 'abc'
    # Mock parameter filter below does not pass because SamAccountName is 'def'
    Get-Stuff -SamAccountName 'def'
    # Mock parameter filter below does "incorrectly" passes because SamAccountName is not specified here
    # but is set to 'abc' by the variable above
    Get-Stuff

    # This assertion fails because there was 1 call, and not 0 calls, because we had naming conflict betwween 
    # parameters and our variables.
    Should -Invoke Get-Stuff -Times 0 -Exactly -ParameterFilter { $SamAccountName -eq 'abc' }
}

log

  • Log conflicting variables in Should -Invoke -ParameterFilter #1973

Better TestDrive performance

TestDrive internals were improved to save the location of test drive directory, instead of querying it every time. This greatly improved performance of any run.

When you don't need TestDrive or TestRegistry, you can disable both TestDrive and TestRegistry entirely, to get more performance gains:

$configuration.TestDrive.Enabled = $false
$configuration.TestRegistry.Enabled = $false

Disabling TestRegistry is also useful on restricted systems when access to Windows Registry is disabled by group policy.

  • Use profiler to improve perf of test drive, name expanding and add-member #1955
  • Add option to disable TestDrive and TestRegistry #2008

Additional fixes in documentation, output, and other bugs squashed:

  • Fixed formatting for null elements in an array #1961
  • Make InModuleScope-parameters available as variables in scriptblock #1957
  • Improve operator-help returned from Get-ShouldOperator #1988
  • Added Pester version message to detailed and diagnostic output #1962
  • Removed StartMessage from output #1968
  • Add formatdata to ensure list view for all sections in PesterConfiguration #1964
  • Update reporttheme output to remove hard coded colour names #1934
  • Set name in xml element testsuite #2034
  • Added FileContentMatchMultilineExactly should assertion #2030
  • Added Filter.ExcludeLine option #2016
  • Add PSObject boxing support in PesterConfiguration #1978
  • Add missing container-parameters to Data #1986
  • Update InvokeVerifiable error message and add negate support #1976
  • Adds support for Register-ArgumentCompleter #1979
  • Fix throwing on missing folders #2012
  • make Value-property setter private in options #1994
  • Add analyzerrule for object-commands #1753
  • Update New-PesterConfiguration help #1946
  • Fix session state in Should -Invoke to use the correct session state #1954
  • Update Pester.RSpec.ps1 #1951
  • Save all files with UTF8BOM #1950
  • Fix formatting in all files #1949
  • Allow positional parameter in get-shouldoperator #1947
  • Remove about links they break website MDX #1948
  • Added missing format tests #1935

See full log here

5.3.0-rc1

03 Aug 08:22
Compare
Choose a tag to compare
5.3.0-rc1 Pre-release
Pre-release

5.3.0-rc1

Issues Fixed

  • Add more logging to BP CC and fix case sensitive new CC #2042

See full log here

(Full release notes will come in RC2)

5.3.0-beta1

23 Jul 08:14
Compare
Choose a tag to compare
5.3.0-beta1 Pre-release
Pre-release

5.3.0-beta1

Issues Fixed

  • Add Ability to Override Properties on New-MockObject #1838
  • Added Run.SkipRemainingOnFailure option #2023
  • Added FileContentMatchMultilineExactly should assertion #2030
  • Added Filter.ExcludeLine option #2016

  • Fix broken link to pester.dev assertions page #2024
  • Enable additional plugins to be added via $additionalPlugins internally #2020

See full log here