Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# sonarqube.Net中的代码覆盖率差异_C#_.net_Sonarqube_Code Coverage_Sonarqube5.3 - Fatal编程技术网

C# sonarqube.Net中的代码覆盖率差异

C# sonarqube.Net中的代码覆盖率差异,c#,.net,sonarqube,code-coverage,sonarqube5.3,C#,.net,Sonarqube,Code Coverage,Sonarqube5.3,我在SonarQube 5.3中发现了一个场景,其中在VisualStudio代码覆盖率分析的代码覆盖率中报告了不同的值 这是一个使用MSTest框架的小复制 我无法确定我们正在做的事情是否有问题,或者某个应用程序是否有问题 被测物体 [Serializable] public class Document : IEquatable<Document> { public long Id { get; set; } public string Name { get; s

我在SonarQube 5.3中发现了一个场景,其中在VisualStudio代码覆盖率分析的代码覆盖率中报告了不同的值

这是一个使用MSTest框架的小复制

我无法确定我们正在做的事情是否有问题,或者某个应用程序是否有问题

被测物体

[Serializable]
public class Document : IEquatable<Document>
{
    public long Id { get; set; }
    public string Name { get; set; }
    public long DocumentHandle { get; set; }
    public long BatchId { get; set; }
    public string BatchName { get; set; }
    public string RepositoryName { get; set; }
    public long DocumentTypeId { get; set; }
    public string DocumentTypeName { get; set; }
    public int SequenceNumber { get; set; }
    public string LoanNumber { get; set; }
    public bool IsJunked { get; set; }
    public DateTime ArrivalDate { get; set; }

    public bool Equals(Document other)
    {
        if (ReferenceEquals(other, null))
        {
            return false;
        }

        if (Id != other.Id)
        {
            return false;
        }

        if (!string.Equals(Name, other.Name))
        {
            return false;
        }

        if (DocumentHandle != other.DocumentHandle)
        {
            return false;
        }

        if (BatchId != other.BatchId)
        {
            return false;
        }

        if (!string.Equals(BatchName, other.BatchName))
        {
            return false;
        }

        if (!string.Equals(RepositoryName, other.RepositoryName))
        {
            return false;
        }

        if (DocumentTypeId != other.DocumentTypeId)
        {
            return false;
        }

        if (!string.Equals(DocumentTypeName, other.DocumentTypeName))
        {
            return false;
        }

        if (SequenceNumber != other.SequenceNumber)
        {
            return false;
        }

        if (!string.Equals(LoanNumber, other.LoanNumber))
        {
            return false;
        }

        if (IsJunked != other.IsJunked)
        {
            return false;
        }

        if (ArrivalDate != other.ArrivalDate)
        {
            return false;
        }

        return true;
    }

    public override bool Equals(object obj)
    {
        if (ReferenceEquals(null, obj))
        {
            return false;
        }

        if (ReferenceEquals(this, obj))
        {
            return true;
        }

        return Equals((Document) obj);
    }

    public static bool operator == (Document document1, Document document2)
    {
        return ReferenceEquals(document1, null) ? ReferenceEquals(document2, null) : document1.Equals(document2);
    }

    public static bool operator != (Document document1, Document document2)
    {
        return !(document1 == document2);
    }

    public override int GetHashCode()
    {
        // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode
        // This was done to suppress the messages about needing to override GetHashCode
        // Because this class has no ReadOnly properties there is no way to provide a better hashcode
        return base.GetHashCode();
    }
}

Visual Studio将百分比显示为:90.10%

SonarQube显示的百分比为:40.00%


声纳似乎不考虑

后的早期返回语句。
if (ReferenceEquals(other, null))
{
  return false;
}
方法说明:
public bool Equals(文档其他)


我已调试测试,以验证线路是否命中。

线路/分支覆盖率之间可能存在差异:

。。。或白色间距/换行

您可以在此处找到SonarQube度量描述页面的公式:

覆盖率=(CT+CF+LC)/(2*B+EL)

在哪里

CT-至少一次评估为“真”的分支 CF-至少一次评估为“false”的分支 LC-覆盖线路(线路至线路覆盖-未覆盖线路)

B-分支机构总数(2*B=条件到覆盖范围)
EL-可执行行的总数(行到行覆盖范围)

行/分支覆盖范围之间可能存在差异:

。。。或白色间距/换行

您可以在此处找到SonarQube度量描述页面的公式:

覆盖率=(CT+CF+LC)/(2*B+EL)

在哪里

CT-至少一次评估为“真”的分支 CF-至少一次评估为“false”的分支 LC-覆盖线路(线路至线路覆盖-未覆盖线路)

B-分支机构总数(2*B=条件到覆盖范围)
EL—可执行行的总数(行到行覆盖)

实际上可能像其他人说的那样,您必须在调试模式下构建。但我的同事发现了一件奇怪的事:

如果将()添加到
[TestClass]
[TestMethod]
装饰器中
[TestClass()]
[TestMethod()]
它工作正常

问题是告诉所有的开发者Sonar需要它,而微软的文档不需要


这适用于Sonarqube DE。在社区版中,如果没有(),效果很好。

实际上可能像其他人说的那样,您必须在调试模式下构建。但我的同事发现了一件奇怪的事:

如果将()添加到
[TestClass]
[TestMethod]
装饰器中
[TestClass()]
[TestMethod()]
它工作正常

问题是告诉所有的开发者Sonar需要它,而微软的文档不需要


这适用于Sonarqube DE。在社区版中工作正常,没有()

设置虚拟机在我自己的环境中,在工作之外重新编程,我无法重新编程。我将把它带回给他们,我怀疑它是部署中的环境或配置。设置虚拟机以便在我自己的环境中,在工作之外重新编程,但我无法重新编程。我将把它带回给他们,我怀疑它是部署中的环境或配置。
if (ReferenceEquals(other, null))
{
  return false;
}