Skip to content

Code Coverage Incorrect for Parameter Default When Using New Profiler #2119

Open
@wethreetrees

Description

@wethreetrees

General summary of the issue

When using the new code coverage profiler ($PesterPreference.CodeCoverage.UseBreakpoints = $false), Pester is reporting missing commands for parameter default value expressions.

ex:

[Int]$Temperature = (Get-Random -Maximum 100 -Minimum 0)

This is working, as expected, when using breakpoints ($PesterPreference.CodeCoverage.UseBreakpoints = $true)

Describe your environment

Pester version : 5.3.1 C:\Client\PowerShell\Modules\Pester\5.3.1\Pester.psm1
PowerShell version : 7.2.1
OS version : Microsoft Windows NT 10.0.19042.0

Steps to reproduce

  1. Download and extract the PesterCCProfilerIssue.zip
  2. From the target directory, run:
.\Invoke-Tests.ps1

Expected Behavior

Should return no missing commands with 100% code coverage.

Current Behavior

Returns:

Covered 75% / 75%. 4 analyzed Commands in 1 File.
 Missed command:
 
File            Class Function        Line Command
----            ----- --------        ---- -------
TestModule.psm1       Get-Temperature    6 Get-Random -Maximum 100 -Minimum 0

Possible Solution? (optional)

😕

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions