Jacoco in Linux environment

56 views
Skip to first unread message

Kallesh Kallu

unread,
Sep 5, 2019, 7:03:15 AM9/5/19
to JaCoCo and EclEmma Users
Hi, 
i am trying to get code coverage of my Java Test code in a Linux environment , Does Jacoco support linux environment ? if supported then what will be the output?

Regards,
Kallesh K

Jitendra Kumar

unread,
Sep 5, 2019, 7:26:04 AM9/5/19
to jac...@googlegroups.com
Hi Kallesh,

Yes, It works in Linux.

You can try below stuff, for sure it will work.

Using examples that come with Tomcat as following:

 

java -version

 

openjdk version "11.0.1" 2018-10-16

OpenJDK Runtime Environment 18.9 (build 11.0.1+13)

OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

 

mkdir /tmp/j

cd /tmp/j

 

wget "http://repo1.maven.org/maven2/org/jacoco/jacoco/0.8.3/jacoco-0.8.3.zip"

aunpack jacoco-0.8.3.zip

 

wget "https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.29/bin/apache-tomcat-8.5.29.tar.gz"

aunpack apache-tomcat-8.5.29.tar.gz

 

cat <<END >./apache-tomcat-8.5.29/bin/setenv.sh

CATALINA_OPTS="\${CATALINA_OPTS} -javaagent:/tmp/j/jacoco-0.8.3/lib/jacocoagent.jar=destfile=/tmp/j/jacoco.exec"

END

 

./apache-tomcat-8.5.29/bin/catalina.sh start

 

curl http://localhost:8080/examples/servlets/servlet/HelloWorldExample

 

./apache-tomcat-8.5.29/bin/catalina.sh stop 60

 

I just got non zero file:

 

ls -l jacoco.exec

 

-rw-r----- 1 evgeny.mandrikov wheel 38463 Mar  7 20:53 jacoco.exec

 

That includes information about execution of HelloWorldExample :

 

java -jar jacoco-0.8.3/lib/jacococli.jar execinfo jacoco.exec | grep HelloWorldExample

 

f4baf7db7add6fb6   19 of  19   HelloWorldExample

 

Among many other class files:

 

java -jar jacoco-0.8.3/lib/jacococli.jar execinfo jacoco.exec | wc -l

 

703

 

And got following report:

 

java -jar jacoco-0.8.3/lib/jacococli.jar report jacoco.exec --classfiles apache-tomcat-8.5.29/webapps/examples/WEB-INF/classes/ --html report


Thanks & Regards,
Jitendra Kumar


--
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/c9daf288-183e-4d26-b628-c7feefdf3846%40googlegroups.com.

Kallesh Kallu

unread,
Oct 30, 2019, 11:53:45 AM10/30/19
to JaCoCo and EclEmma Users
Thanks for answer, I could able to generate the jacoco.exec file with data, but it seems like does not  contain coverage for Tests run.
How to configure automated Testcases in Jacoco.


Regards,
Kallesh K

Kallesh Kallu

unread,
Oct 30, 2019, 12:33:28 PM10/30/19
to jac...@googlegroups.com
I am attaching the sample pic of report generated , I can only see constructor and associated methods used during creation of class instances are covered ,  which makes me think that this coverage was just run on a plain started service, not during the actual tests run.


--
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.
jacoco.PNG

Marc Hoffmann

unread,
Oct 31, 2019, 1:05:52 PM10/31/19
to jac...@googlegroups.com
Hi Kallesh,

the screenshot you attached is not created by JaCoCo, probably you use some other tool to to create the report. Please check with the project of that tool.

Also with such a sparse description of your setup it is impossible to tell what’s going wrong here. Please provide a executable reproducer (e.g. on Github) which demonstrates the problem.

Regards,
-marc


Kallesh Kallu

unread,
Nov 3, 2019, 8:20:01 PM11/3/19
to jac...@googlegroups.com
Screenshot I attached is from jenkins which is generated after creating a jacoco.exec file and showing generated exec from jenkins tool.

My requirement is 
I need to generate Jacoco report for automated testcases which are in java. 
Please let me know how to go about it.

Regards,
Kallesh

Marc Hoffmann

unread,
Nov 4, 2019, 6:17:08 PM11/4/19
to JaCoCo and EclEmma Users
Hi Kallesh,

the Jenkins plugin is not maintained by us. Please check with the respective project how to configure the plugin properly.

Regards,
-marc

Kallesh Kallu

unread,
Nov 6, 2019, 8:01:50 AM11/6/19
to jac...@googlegroups.com
then how to view the report ? there is a jacoco jenkins plugin through which i could able to view the report.
Is there any other way we can view it ? i got the jacoco.exec file 

Regards,
Kallesh K


Marc Hoffmann

unread,
Nov 8, 2019, 4:44:30 AM11/8/19
to jac...@googlegroups.com

Hi Kallesh,

it depends on your build system: JaCoCo provides tools to create JaCoCo coverage reports for Ant and Maven as well as on the command line. See JaCoCo documentation.

Regards,
-marc

Kallesh Kallu

unread,
Nov 20, 2019, 2:03:41 AM11/20/19
to jac...@googlegroups.com
What Are all the limitations of Jacoco?
I could see threading is not covered
Lamda expressions not covered, reflection etc.. not covered
Can I please know limitations of jacoco

Regards,
Kallesh K

Evgeny Mandrikov

unread,
Nov 20, 2019, 4:25:10 AM11/20/19
to JaCoCo and EclEmma Users

On Wednesday, November 20, 2019 at 8:03:41 AM UTC+1, Kallesh Kallu wrote:
What Are all the limitations of Jacoco?
I could see threading is not covered
Lamda expressions not covered, reflection etc.. not covered
Can I please know limitations of jacoco
 
There is no limitations regarding multithreading, lambda expressions, reflection, etc.
Here is example of two lambda expressions - first one is not executed and hence correctly shown as not covered, second one is executed and hence correctly shown as covered:




Kallesh Kallu

unread,
Nov 20, 2019, 4:40:51 AM11/20/19
to jac...@googlegroups.com, mand...@gmail.com
I have a situation where there are some threads running upon starting of a service and some time before the Actual Automation tests run.
In this case only things which is run by tests, is getting coverage report , not the threads which started before automation has run.

Regards,
Kallesh K

--
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.

Evgeny Mandrikov

unread,
Nov 20, 2019, 5:10:53 AM11/20/19
to JaCoCo and EclEmma Users


On Wednesday, November 20, 2019 at 10:40:51 AM UTC+1, Kallesh Kallu wrote:
I have a situation where there are some threads running upon starting of a service and some time before the Actual Automation tests run.
In this case only things which is run by tests, is getting coverage report , not the threads which started before automation has run.

By default JaCoCo records execution from the beginning of the run of Java Virtual Machine to its end.


On Thursday, October 31, 2019 at 6:05:52 PM UTC+1, Marc R. Hoffmann wrote:
Also with such a sparse description of your setup it is impossible to tell what’s going wrong here. Please provide a executable reproducer (e.g. on Github) which demonstrates the problem.

It is impossible to understand what exactly you do and how without complete example that can be executed by us and not just by you.

Kallesh Kallu

unread,
Nov 21, 2019, 12:33:29 AM11/21/19
to jac...@googlegroups.com, mand...@gmail.com
I have added below line in my start up file , it looks like all the classes are not covered, threads are not covered 

wrapper.java.additional.8=-javaagent:/opt/hpe/ssmc/yajsw/conf/jacocoagent.jar=append=true


Is there a way to include all 


Regards,

kallesh K




--
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.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages