Running code coverage with Cobertura and Jacoco

前端 未结 1 406
我在风中等你
我在风中等你 2021-02-06 12:51

I have a bit of a problem getting code coverage reports for both Integration Tests and Unit Tests in Sonar for a Maven Plugin project (which uses invoker plugin for the integrat

1条回答
  •  后悔当初
    2021-02-06 13:03

    Since you've configure the sonar as

     reuseReports
     
         ${project.basedir}/target/jacoco-t.exec
     
    

    This means you are telling sonar to reuse the existing report from sonar.jacoco.itReportPath. If there is no existing report, there is no any coverage.

    In may case, I use the cobertura and reuse its report from maven site generation. as the following configuration properties: -

    cobertura
    reuseReports
    
        ${project.build.directory}/surefire-reports
    
    
        ${project.build.directory}/site/cobertura/coverage.xml
    
    

    I can get the reuse by using the following command :-

    mvn clean install site sonar:sonar
    

    I can reproduce your issue by using the following command :-

    mvn clean install sonar:sonar
    

    The coverage is 0%. Since there is no existing report at the report path.

    Then please make sure that there is a report named "jacoco-t.exec" as specified before executing the sonar.

    Since I'm not familiar with the JaCoCo and do not know which maven phase that produces thae report file. I would suggest to execute the command like the following:-

    mvn clean test sonar:sonar
    

    or

    mvn clean install sonar:sonar
    

    or the same as mine

    mvn clean install site sonar:sonar
    

    I hope this may help.

    Regards,

    Charlee Ch.

    0 讨论(0)
提交回复
热议问题