-
-
Notifications
You must be signed in to change notification settings - Fork 473
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
Code coverage fails in some circumstances when UseBreakpoints is $false
#2306
Comments
Forgot to add the actual error.
|
$false
$false
Thanks for the report. This is a weird one. Can reproduce, but have no idea what's going on. Will probably need to debug pwsh, so leaving it to our CC-wizard 🧙♂️ |
This is also a PowerShell-bug. The invoked code isn't modified by us at all. Our injected code gets triggered right after this actually. Repro: class MyClass {
# Any method has to exist, regardless of scriptblock, parameters or static/non-static
MyMethod() { }
}
Set-PSDebug -Trace 1
[MyClass]::new() Found this issue when I went to report it: PowerShell/PowerShell#16874 |
@johlju: I found a workaround for now. Add a constructor to the class, ex. |
Thank you for putting the work in, and also finding a workaround for this! It seems to work perfectly. I have re-enabled Pester's new code coverage method in the pipeline for SqlServerDsc. |
- SqlServerDsc - Add empty constructor to classes to be able to use Pester's new code coverage method. See more information can be found in [pester/Pester#2306]
Checklist
What is the issue?
I started seening this issue when I started doing class-based resource ~1 year ago, and since it has been troublesome to make a repro case so I just switched to using breakpoints for code coverage instead. But now I managed to repro it with simpler code and simpler tests.
This test works when
CodeCoverage.UseBreakpoints = $true
but fails whenCodeCoverage.UseBreakpoints = $false
.There seems to be a problem somewhere inside Pester when using this new code coverage method.
Expected Behavior
The tests to pass regardless if
UseBreakpoints
is set to$true
or$false
.Steps To Reproduce
File
SqlServerDsc.psm1
File
SqlServerDsc.Tests.ps1
File
debug.ps1
Switch
UseBreakpoints
to$true
to verify that the tests passes using breakpoints for code coverage.Describe your environment
Possible Solution?
Sorry, unknown.
The text was updated successfully, but these errors were encountered: