-
Notifications
You must be signed in to change notification settings - Fork 385
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
[BUG] Records show no coverage #1633
Comments
Thanks for reporting and providing a repro. I see if I can get the discussion in #1576 started. I think we then would have less issues with records. |
Our SonarQube would not allow my PR since coverage was subpar. |
Hello ! Latest SonarQube expects all the lines to be covered |
A hopefully useful additional data point
I have an internal record: internal record Foo
{
public string Bar() => "baz";
} And an associated test project with a test: [TestFixture]
internal class FooTests
{
[Test]
public void FooBarShouldReturnBaz()
{
var foo = new Foo();
Assert.That(foo.Bar(), Is.EqualTo("baz"));
}
} After running the test, the method call shows that it was covered, but the record itself does not: If I modify the record declaration to include the redundant primary constructor parentheses: internal record Foo()
{
public string Bar() => "baz";
} and repeat the test, this time I get green all around: |
I confirm |
OK I see. It looks like SonarQube is expecting the |
@Steve-OH, @Rast1234 I think I now found one of the issues here. Starting from the sample code @Steve-OH provided. If I add the primary constructor parentheses, the generated report contains the constructor. This is an issue we need to tackle. If it doesn't contain the parentheses the constructor is not part of the coverage report. Which should be the expected report in both cases because we want generated constructors to be completely excluded. But in your sample, the record declaration seems to be expected to be covered also without the parentheses. This is different to what I'm currently observing. I wonder if this is part of the report? Are you able to provide me your coverage reports for both cases? |
Here are the reports, with and without parentheses. |
Describe the bug
With .Net 8, records show no coverage
Tested with the nightly build too
I read #1561 #1607 #1576
To Reproduce
Expected behavior
FolderInfoDto
,CreateFolderDto
,DeleteFolderDto
,BasicFolderDto
are marked as covered.Actual behavior
They are marked as not covered.
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Which coverlet package and version was used? 6.0.1 and nightly
* Which version of .NET is the code running on? 8.0.2
* What OS and version, and what distro if applicable? Windows 11
* What is the architecture (x64, x86, ARM, ARM64)? x64
* Do you know whether it is specific to that configuration? No
Additional context
<TargetFramework>net8.0</TargetFramework>
or<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
abstract
orsealed
makes no differencetest.runsettings:
The text was updated successfully, but these errors were encountered: