SonarQube 忽略 AbstractValidator 测试 类

SonarQube ignoring AbstractValidator test classes

SonarQube 忽略对 AbstractValidators 的测试(FluentValidation.AspNetCore nuget 包)。在覆盖部分,所有 RuleFor 行都标记为未覆盖。 我需要做什么才能将测试包含在 SonarQube 的覆盖范围内? ReSharper 显示验证器被测试完全覆盖。

验证者:

public class UserValidator : AbstractValidator<User>
{
    public UserValidator()
    {
        RuleFor(a => a.Name).NotEmpty();
        RuleFor(a => a.FirstName).NotEmpty();
    }
}

测试class:

public class UserValidatorTests
{
    [Test, TestCaseSource(nameof(User_InvalidData))]
    public async Task ValidationShouldFail(UserAndErrors testData)
    {
        var result = await new UserValidator().TestValidateAsync(testData.User!);

        Assert.IsFalse(result.IsValid);
        Assert.AreEqual(result.Errors.Count, testData.ErrorsCount);
    }

    [Test]
    public async Task ValidationShouldPass()
    {
        var request = new User
        {
            FirstName = "John",
            Name= "Doe"
        };
        var result = await new UserValidator().TestValidateAsync(request);

        Assert.IsTrue(result.IsValid);
        result.ShouldNotHaveAnyValidationErrors();
    }
            
    private static IEnumerable<TestCaseData> User_InvalidData()
    {
        yield return new TestCaseData(new User
        {
            User = new User(),
            ErrorsCount = 2
        });
        yield return new TestCaseData(new User
        {
            User = new User
            {
                Name = "Doe"
            },
            ErrorsCount = 1
        });
        yield return new TestCaseData(new User
        {
            User = new User
            {
                FirstName = "John"
            },
            ErrorsCount = 1
        });
    }       

    public class UserAndErrors
    {
        public User? User { get; set; }
        public int ErrorsCount { get; set; } = 0;
    }
}

用户class:

public class User
{
    public string Name { get; set; } = string.Empty;
    public string FirstName { get; set; } = string.Empty;
}

问题是测试项目没有引用 coverlet.msbuild nuget 包。没有它,SonarQube 无法 运行 正确测试并且无法更新代码覆盖率。