[英]Jacoco report 0 classes
I am new with mvn & jacoco and I have an issue with mvn jacoco:report
who found 0 classes in the jacoco.exec file 我是mvn&jacoco的新手,并且mvn jacoco:report
有一个问题,他在jacoco.exec文件中找到了0个类
The jacoco agent is executed inside a docker container : -javaagent:/opt/jboss/jacoco/org.jacoco.agent.jar=destfile=/opt/jboss/jacoco/jacoco.exec,output=tcpserver,address=*,port=6667
jacoco代理在docker容器内执行: -javaagent:/opt/jboss/jacoco/org.jacoco.agent.jar=destfile=/opt/jboss/jacoco/jacoco.exec,output=tcpserver,address=*,port=6667
I passed the option in standalone.conf 我在standalone.conf中通过了该选项
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -javaagent:/opt/jboss/jacoco/org.jacoco.agent.jar=destfile=/opt/jboss/jacoco/jacoco.exec,output=tcpserver,address=*,port=6667"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
is it enough? 够了吗
When I launched jacoco:dump
I successfully connect to my container and a jacoco.exec file is created locally (not empty) 当我启动jacoco:dump
我成功连接到我的容器,并且在本地创建了jacoco.exec文件(不为空)
My app is like that : 我的应用程序是这样的:
My plugin config pom : 我的插件配置pom:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<configuration>
<dataFile>/home/mypath/jacoco.exec</dataFile>
<reset>true</reset>
<address>172.17.0.3</address>
<port>6667</port>
<append>false</append>
</configuration>
</plugin>
Edit : The jacococli generate a report so my exec file is correct 编辑:jacococli生成一个报告,所以我的exec文件是正确的
Edit : Ok so I think I find my issue the problem is my maven app is a dependency of my selenium project, it seems that jacoco-maven-plugin is unable to use a dependency (to get all the class files) to create the report but with ant there is more options so here is my solution : 编辑:好的,所以我认为我发现我的问题是我的Maven应用程序是我的硒项目的依赖项,似乎jacoco-maven-plugin无法使用依赖项(获取所有类文件)来创建报告但是用ant有更多选择,所以这是我的解决方案:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="report">
<!-- Execute an ant task within maven -->
<echo message="Generating JaCoCo Reports" />
<taskdef name="report"
classname="org.jacoco.ant.ReportTask">
<classpath
path="xxxtarget/*.jar" />
</taskdef>
<mkdir dir="${basedir}/target/coverage-report" />
<report>
<executiondata>
<fileset dir="${basedir}/target">
<include name="jacoco.exec" />
</fileset>
</executiondata>
<structure name="Integration Tests Coverage Report">
<classfiles>
<fileset dir="xxx/target" >
<include name="*.jar"/>
</fileset>
</classfiles>
</structure>
<html destdir="${basedir}/target/coverage-report/html" />
</report>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.ant</artifactId>
<version>0.8.2</version>
</dependency>
</dependencies>
</plugin>
I finally have the report automatically generated by the pom 我终于有了pom自动生成的报告
thanks 谢谢
How are you executing the jacoco report goal? 您如何执行jacoco报告目标?
You can try running the command something like this: 您可以尝试运行以下命令:
mvn -B -DskipTests org.jacoco:jacoco-maven-plugin:0.7.9:report -Djacoco.dataFile="<..>\target\jacoco-merged.exec"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.