Coverage per test - jacoco, tomcat and sonar

隐身守侯 提交于 2019-12-14 03:54:23

问题


I have looked around the net with lot of information regarding the topic scattered but not one that fits my need.

I plan to measure the coverage of system test cases. Our system test cases run in a clustered environment supported by Tomcat server. So in different JVM. There are multiple instance of Tomcat running where system test cases run, hence I get multiple jacoco bump files at each Tomcat.

I am attaching jacoco agent jar to tomcat startup as VM argument: -javaagent:org.jacoco.agent-runtime.jar=destfile=jacoco.exec,append=true

I have maven set up to run the system test cases(once triggered the test runs in deployed tomcat server). I use fail safe plugin for this. I collect the different jacaco files post test case execution and get a merged jacoco file with below plugin setup.

 <plugin>
       <groupId>org.jacoco</groupId>
       <artifactId>jacoco-maven-plugin</artifactId>
       <version>${jacoco.version}</version>
       <configuration>
            <fileSets>
               <fileSet>     
                  <directory>jacoco-execs</directory>
                  <includes>
                     <include>*.exec</include>
                  </includes>
               </fileSet>
            </fileSets>
            <!-- File containing the merged data -->
            <destFile>../jacoco-merged/merged.exec</destFile>
      </configuration>                        
</plugin>

In sonar pom I supply the location of this merged jacoco exec to get the coverage report. ../merged.exec

With the set up I manage to get the line coverage report in sonar board however I do not get coverage per test and sonar logs have below error "No information about coverage per test."

I am aware that I must attach a jacoco listener to get this information. I am facing problem in doing so as I do not generate the jacoco file using maven but by attaching jacoco agent to tomcat startup via vm arguments. Is there a way to add a listener via VM argument, the way we add the javaagent?

Please advise.

来源:https://stackoverflow.com/questions/34924996/coverage-per-test-jacoco-tomcat-and-sonar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!