带有Gallio和Opencover的声纳,代码覆盖率:0% [英] sonar with gallio and opencover, code coverage: 0%

查看:120
本文介绍了带有Gallio和Opencover的声纳,代码覆盖率:0%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用声纳检查我的C#项目.我想测量代码覆盖率,这就是为什么我安装了gallio和opencover的原因.当我运行soner-runner时,一切正常,我的单元测试已执行,但是在声纳Web UI上代码覆盖率为0%.

I'm using sonar to check my c# project. I would like to measure code coverage that's why i installed gallio and opencover. When I run soner-runner everything works fine, my unit test is performed, ... but the code coverage is 0% on the sonar web UI.

您知道代码覆盖率为0%的原因吗?

do you know the reason why the code coverage is 0%?

我的解决方案,项目和课程: (S)SonarTestSolution (P)ClassLibrary1 (C)Class1.cs (P)ClassLibrary1NUnitTest (C)Class1NUnitTest.cs

My solution, project and classes: (S) SonarTestSolution (P) ClassLibrary1 (C) Class1.cs (P) ClassLibrary1NUnitTest (C) Class1NUnitTest.cs

Class1.cs的内容:

content of Class1.cs:

public class Class1  {
    public String getTestString() {  return "abc";}
}

Class1NUnitTest.cs的内容:

content of Class1NUnitTest.cs:

   [TestFixture]
    public class Class1NUnitTest    {
        [Test]
        public void createServiceFromFactoryTest()  {
            Class1 c = new Class1();
            Assert.That(c.getTestString(), Is.EqualTo("abc"));
    }}

sonar-project.properties:

sonar-project.properties:

  sonar.projectKey=cs_sonar_test
  sonar.projectVersion=1.0-SNAPSHOT
  sonar.projectName=C# Sonar Test Project
  sonar.sourceEncoding=UTF-8
  sources=.
  sonar.language=cs
  sonar.donet.visualstudio.testProjectPattern=*NUnitTest*

如果需要,我可以包括日志og sonar-runner以及生成的coverage-report.xml和gallio-report.xml文件

If you want I can include the log og sonar-runner, and the generated coverage-report.xml and gallio-report.xml files

推荐答案

已解决-该项目是在另一台计算机上构建的,这就是问题所在.在同一文件夹中构建解决方案可以解决问题.

solved - the project was build another machine, this was the problem. Building the solution in the same folder solves the proble.

这篇关于带有Gallio和Opencover的声纳,代码覆盖率:0%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆