Thanks for your relpy, Mars.I will answer your problem and tell my setup detailly. 1)I use ant ,the ant vresion is Apache Ant(TM) version 1.9.7
2)the jacoco version is JaCoCo <http://www.eclemma.org/jacoco> 0.7.8.201606240924 3 a)the web application which I collect covereage data is a jar , the jar is got by maven command :mvn clean package,the compiler is maven-compiler-plugin:3.1:compile we startup the application use command: nohup java -jar -Xmx1536m -XX:MaxPermSize=512M -javaagent:/opt/jacocoagent.jar=includes=*,output=tcpserver,port=10003,address=1127.0.0.1 -Djava.security.egd=file:/dev/./urandom server-3.2.0-SNAPSHOT.jar --server.port=9001 --shell.ssh.port=2002 --spring.profiles.active=build > nohup.log & I restart my application after add the javaagent b)I donot know how to configure the application ,so I unzip the server-3.2.0-SNAPSHOT.jar ,and delete the lib file(if I donot delete the lib file the command ant report will show error message Error while creating report Caused by: java.io.IOException: Error while analyzing lib/bcprov-jdk16-1.46.jar@org/bouncycastle/LICENSE.class. Caused by: java.lang.IllegalStateException: Can't add different class with same name: org/bouncycastle/LICENSE ) and this is my build.xml ======================================================================================== project xmlns:ns0="antlib:org.jacoco.ant" default="rebuild" name="credit-card-server"> <!--Jacoco的安装路径--> <property name="jacocoantPath" value="/opt/apache-ant-1.9.7/lib/jacocoant.jar"/> <property name="jacocoResultPath" value="/jacoco/target"/> <!--最终生成.exec文件的路径,Jacoco就是根据这个文件生成最终的报告的--> <property name="jacocoexecPath" value="/jacoco/jacoco.exec"/> <!--生成覆盖率报告的路径--> <property name="reportfolderPath" value="${jacocoResultPath}/report/"/> <!--远程tomcat服务的ip地址--> <property name="server_ip" value="127.0.0.1"/> <!--前面配置的远程tomcat服务打开的端口,要跟上面配置的一样--> <property name="server_port" value="10003"/> <!--源代码路径可以包含多个源代码--> <property name="source" value="/jacoco/source/credit-card-server/src/main/java/" /> <!--.class文件路径可以包含多个--> <!--确认--> <property name="classes" value="/jacoco/classes/credit-card-server/"/> <!--让ant知道去哪儿找Jacoco--> <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"> <classpath path="${jacocoantPath}" /> </taskdef> <target name="clean"> <delete dir="${reportfolderPath}" /> </target> <!--dump任务: 根据前面配置的ip地址,和端口号, 访问目标tomcat服务,并生成.exec文件。--> <target name="dump"> <ns0:dump address="${server_ip}" reset="false" destfile="${jacocoexecPath}" port="${server_port}" append="false"/> </target> <!--jacoco任务: 根据前面配置的源代码路径和.class文件路径, 根据dump后,生成的.exec文件,生成最终的html覆盖率报告。--> <target name="report"> <ns0:report> <executiondata> <file file="${jacocoexecPath}" /> </executiondata> <structure name="credit-card-server"> <classfiles> <fileset dir="${classes}"> </fileset> </classfiles> <sourcefiles> <fileset dir="${source}" /> </sourcefiles> </structure> <html destdir="${reportfolderPath}" /> <csv destfile="${reportfolderPath}/report.csv" /> <xml destfile="${reportfolderPath}/report.xml" /> </ns0:report> </target> <target depends="clean,report" name="rebuild" /> </project> ========================================================================== ( someone tells I donot need unzip the jar file ,but I donnt know how to configuer it .I have used jacoco with ant before, but it is a war applicatiuon ,I can get the classes easily.) 4) I just unzip the jar file , delete the jar and lib file ,and donot modily the clsses manual. I can tell you what I do after I see the html report a)first,I calls an http interface manual, the use ant dump ,I found the .exec file size increased b) I checked the application ,the source file is same with the branch code(git pull) and the jar applicaion is same with the branch code . c) I checked the session ,it show the classes I calls , but the detail html page is still like the picture I show you .but somecode of the applicaion seems right(the highted code is continues) 在 2016年7月13日星期三 UTC+8上午10:20:04,Liangbin Dai写道: > > > Thanks for your relpy, Mars.I will answer your problem and tell my setup > detailly. > 1)I use ant ,the ant vresion is Apache Ant(TM) version 1.9.7 > > 2)the jacoco version is JaCoCo <http://www.eclemma.org/jacoco> > 0.7.8.201606240924 > > 3 > a)the web application which I collect covereage data is a jar , > the jar is got by maven command :mvn clean package,the compiler > is maven-compiler-plugin:3.1:compile > > we startup the application use command: > nohup java -jar -Xmx1536m -XX:MaxPermSize=512M > -javaagent:/opt/jacocoagent.jar=includes=*,output=tcpserver,port=10003,address=1127.0.0.1 > > -Djava.security.egd=file:/dev/./urandom server-3.2.0-SNAPSHOT.jar > --server.port=9001 --shell.ssh.port=2002 --spring.profiles.active=build > > nohup.log & > > I restart my application after add the javaagent > > b)I donot know how to configure the application ,so I unzip the > server-3.2.0-SNAPSHOT.jar ,and delete the lib file(if I donot delete the > lib file the command ant report will show error message Error while > creating report Caused by: java.io.IOException: Error while analyzing > lib/bcprov-jdk16-1.46.jar@org/bouncycastle/LICENSE.class. > Caused by: java.lang.IllegalStateException: Can't add different class with > same name: org/bouncycastle/LICENSE ) > and this is my build.xml > > ======================================================================================== > project xmlns:ns0="antlib:org.jacoco.ant" default="rebuild" > name="credit-card-server"> > <!--Jacoco的安装路径--> > <property name="jacocoantPath" > value="/opt/apache-ant-1.9.7/lib/jacocoant.jar"/> > > <property name="jacocoResultPath" value="/jacoco/target"/> > <!--最终生成.exec文件的路径,Jacoco就是根据这个文件生成最终的报告的--> > <property name="jacocoexecPath" value="/jacoco/jacoco.exec"/> > <!--生成覆盖率报告的路径--> > <property name="reportfolderPath" value="${jacocoResultPath}/report/"/> > <!--远程tomcat服务的ip地址--> > <property name="server_ip" value="127.0.0.1"/> > <!--前面配置的远程tomcat服务打开的端口,要跟上面配置的一样--> > <property name="server_port" value="10003"/> > <!--源代码路径可以包含多个源代码--> > <property name="source" > value="/jacoco/source/credit-card-server/src/main/java/" /> > > <!--.class文件路径可以包含多个--> > <!--确认--> > <property name="classes" value="/jacoco/classes/credit-card-server/"/> > > > <!--让ant知道去哪儿找Jacoco--> > <taskdef uri="antlib:org.jacoco.ant" > resource="org/jacoco/ant/antlib.xml"> > <classpath path="${jacocoantPath}" /> > </taskdef> > > <target name="clean"> > <delete dir="${reportfolderPath}" /> > </target> > > <!--dump任务: > 根据前面配置的ip地址,和端口号, > 访问目标tomcat服务,并生成.exec文件。--> > > <target name="dump"> > <ns0:dump address="${server_ip}" reset="false" > destfile="${jacocoexecPath}" port="${server_port}" append="false"/> > </target> > > <!--jacoco任务: > 根据前面配置的源代码路径和.class文件路径, > 根据dump后,生成的.exec文件,生成最终的html覆盖率报告。--> > > <target name="report"> > > <ns0:report> > > > <executiondata> > <file file="${jacocoexecPath}" /> > </executiondata> > > > <structure name="credit-card-server"> > <classfiles> > <fileset dir="${classes}"> > </fileset> > </classfiles> > <sourcefiles> > <fileset dir="${source}" /> > </sourcefiles> > </structure> > > > <html destdir="${reportfolderPath}" /> > <csv destfile="${reportfolderPath}/report.csv" /> > <xml destfile="${reportfolderPath}/report.xml" /> > </ns0:report> > </target> > <target depends="clean,report" name="rebuild" /> > </project> > ========================================================================== > ( someone tells I donot need unzip the jar file ,but I donnt know how to > configuer it .I have used jacoco with ant before, but it is a war > applicatiuon ,I can get the classes easily.) > > 4) I just unzip the jar file , delete the jar and lib file ,and donot > modily the clsses manual. > > I can tell you what I do after I see the html report > a)first,I calls an http interface manual, the use ant dump ,I found the > .exec file size increased > b) I checked the application ,the source file is same with the branch > code(git pull) and the jar applicaion is same with the branch code . > c) I checked the session ,it show the classes I calls , but the detail > html page is still like the picture I show you .but somecode of the > applicaion seems right(the highted code is continues) > > > > 在 2016年7月12日星期二 UTC+8下午11:07:27,Marc R. Hoffmann写道: >> >> Hi, >> >> this looks really strange. Only the first line is highligted as covered, >> right? >> >> Can you please provide some information about your setup: >> >> 1) How do you create the report (Maven, Ant, Eclipse, ...)? >> 2) What exact version of JaCoCo are you using (see footer of report)? >> 3) How do you compile your class files? What compiler vendor/version are >> you using? >> 4) Do you process you class files after compiling (e.g. for obfuscation) >> >> Regards, >> -marc >> >> On 2016-07-12 03:06, Liangbin Dai wrote: >> > Hi marc: >> > I get a html like this , I donot know why , >> > I hava already checkeck the sessions , it has the coverage the >> > classes which I calls manually. >> > but I donot know why html the coverage report seems incorrect , the >> > code should execute in order ,but the html seems incorrect because the >> > code execute uncontinues . >> > >> > I guess the problem is due to .exec data or classes files or source >> > files ,but I donot know how to make sure and config out what the >> > problem. >> > can you help me ,thanks >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "JaCoCo and EclEmma Users" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an email to [email protected]. >> > To view this discussion on the web visit >> > >> https://groups.google.com/d/msgid/jacoco/2d1e58e6-039e-4f31-942e-91dc4bbcab31%40googlegroups.com >> >> > [1]. >> > For more options, visit https://groups.google.com/d/optout. >> > >> > >> > Links: >> > ------ >> > [1] >> > >> https://groups.google.com/d/msgid/jacoco/2d1e58e6-039e-4f31-942e-91dc4bbcab31%40googlegroups.com?utm_medium=email&utm_source=footer >> >> > -- You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/867afde2-4211-4f06-8ade-f6e35e9048e5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
