The screenshot is showing the SonarQube Cloud report.
Due to this behavior of SonarQube Cloud, I cannot get 100% code coverage. Not usually a big deal, but depending on the size of the Pull Request it varies the precision of code coverage percentage can vary a bit. More importantly, I need to feel the joy of having the pipeline report 100% coverage
// Application Code
public record RemoveSystemUserInput
{
public required Guid UserId { get; init; }
}
public Task<bool> RemoveSystemUserAsync(
RemoveSystemUserInput input,
CancellationToken cancellationToken)
{
/* code here */
return true;
}
// Test code
// Arrange
var systemUser = fixture.GetSystemUser();
// Act
await repository.RemoveSystemUserAsync(
new RemoveSystemUserInput
{
UserId = systemUser.Id
},
cancellationToken);
// Assert
await verify(result);
So it’s interesting to see code coverage shows that the property inside the record is covered, but not the top level of the record? Is it because there’s no constructor? I’m still using the new operator. ¯\(ツ)/¯
- ALM used: GitHub
- CI system used: GitHub/ GitHub Actions?
- Languages of the repository: C#
- Steps to reproduce:
- Use a record class type in C# and utilize it in the test project
- cover all properties of the record
- The record reports as not covered on the top level.
- Potential workaround: use a class instead of record? Use records with constructors?