sonar with gallio and opencover, code coverage: 0%

2019-08-20 14:47发布

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.

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

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

content of Class1.cs:

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

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.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*

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

1条回答
Ridiculous、
2楼-- · 2019-08-20 15:12

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

查看更多
登录 后发表回答