jacoco the html incorrect

116 views
Skip to first unread message

Liangbin Dai

unread,
Jul 11, 2016, 9:06:16 PM7/11/16
to JaCoCo and EclEmma Users
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

覆盖率.png
html.png

Marc Hoffmann

unread,
Jul 12, 2016, 11:07:27 AM7/12/16
to jac...@googlegroups.com
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
> --
> 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 jacoco+un...@googlegroups.com.
> 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

Liangbin Dai

unread,
Jul 12, 2016, 10:20:04 PM7/12/16
to JaCoCo and EclEmma Users


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 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写道:

Liangbin Dai

unread,
Jul 12, 2016, 11:30:57 PM7/12/16
to JaCoCo and EclEmma Users
sorry , I will show you my idea (maybe it is incorrect )
1)I guess the .exec data is right ,because when I call a http interface the .exec file size grows,I guess is has collected the coverage data
2) if the .exec data is right ,it just seems the html report just shows incorrect ,because to produce the report I will provider classes files 、 source files and .exec data .The relation betwwen them is .exec data is dumped with running classed ,and the classes file can map the source files ,if the .exec data has collected the coverage ,either the .exec data is not matched with classes file ,or the classes files is not matched with the source code. but when I clicked the class in the html report (right conner) is seems the classes file and source file mapping is right.
and I guess maybe my applicaion use some jars affecting the .exec data ~
waiting your reply 

在 2016年7月12日星期二 UTC+8下午11:07:27,Marc R. Hoffmann写道:
Hi,

Liangbin Dai

unread,
Jul 12, 2016, 11:31:49 PM7/12/16
to JaCoCo and EclEmma Users


在 2016年7月12日星期二 UTC+8上午9:06:16,Liangbin Dai写道:

Liangbin Dai

unread,
Jul 15, 2016, 11:53:52 AM7/15/16
to JaCoCo and EclEmma Users

Hi  marc ,can you help me ?

在 2016年7月12日星期二 UTC+8下午11:07:27,Marc R. Hoffmann写道:
Hi,

Liangbin Dai

unread,
Jul 15, 2016, 11:54:46 AM7/15/16
to JaCoCo and EclEmma Users


在 2016年7月12日星期二 UTC+8上午9:06:16,Liangbin Dai写道:
Hi marc:

Liangbin Dai

unread,
Jul 15, 2016, 11:55:23 AM7/15/16
to JaCoCo and EclEmma Users
在 2016年7月13日星期三 UTC+8上午10:20:04,Liangbin Dai写道:
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages