Code Coverage with Ruby and Python tests

381 views
Skip to first unread message

kanukal...@gmail.com

unread,
Aug 30, 2017, 4:03:35 PM8/30/17
to JaCoCo and EclEmma Users
Hello Community -

I have a java server that is tested with Ruby as well as Python based tests.

1. Is it possible to determine code coverage with Jacoco in this mixed environment?
2. Do the ANT instructions stay the same as provided for java tests?

Thanks.

Evgeny Mandrikov

unread,
Aug 30, 2017, 4:39:06 PM8/30/17
to JaCoCo and EclEmma Users, kanukal...@gmail.com
Hi,


On Wednesday, August 30, 2017 at 10:03:35 PM UTC+2, kanukal...@gmail.com wrote:
Hello Community -

I have a java server that is tested with Ruby as well as Python based tests.

1. Is it possible to determine code coverage with Jacoco in this mixed environment?


JaCoCo is completely neutral to the way you run your tests, so yes.
 

2. Do the ANT instructions stay the same as provided for java tests?


The ways to start application with attached JaCoCo Agent and generation of report stay the same as in case of Java tests.

Please carefully study documentation ( http://www.jacoco.org/jacoco/trunk/doc/ ) and materials already available in internet such as for example presentations ( http://www.jacoco.org/research/index.html ) and similar questions in this mailing list.
 

Thanks.


HTH.

kanukal...@gmail.com

unread,
Aug 31, 2017, 12:19:48 AM8/31/17
to JaCoCo and EclEmma Users, kanukal...@gmail.com
Evgeny,

Thanks. After going through docs, I have few more questions -

1. Since I use ANT file and have included <jacoco:coverage> tags around the executions, my understanding is that I don't need a separate java agent to run. Am I correct?

2. In the examples I see, I notice that sometime I see <jacoco:coverage> tags around the execution which needs to be instrumented (e.g. the server code that will be executed by tests) and sometimes I see these tags around the test execution (e.g. tests which run against server code). Not sure which is the correct approach?

Thanks,
Kanu

kanukal...@gmail.com

unread,
Aug 31, 2017, 12:24:56 AM8/31/17
to JaCoCo and EclEmma Users, kanukal...@gmail.com

Evgeny Mandrikov

unread,
Sep 4, 2017, 5:35:20 PM9/4/17
to JaCoCo and EclEmma Users, kanukal...@gmail.com


On Thursday, August 31, 2017 at 6:24:56 AM UTC+2, kanukal...@gmail.com wrote:
On Wednesday, August 30, 2017 at 9:19:48 PM UTC-7, kanukal...@gmail.com wrote:
> Evgeny,
>
> Thanks. After going through docs, I have few more questions -
>
> 1. Since I use ANT file and have included <jacoco:coverage> tags around the executions, my understanding is that I don't need a separate java agent to run. Am I correct?

"coverage" task configures nested tasks to enable use of agent.
 
>
> 2. In the examples I see, I notice that sometime I see <jacoco:coverage> tags around the execution which needs to be instrumented (e.g. the server code that will be executed by tests) and sometimes I see these tags around the test execution  (e.g. tests which run against server code). Not sure which is the correct approach?

Agent should always be attached to the JVM that executes application whose coverage should be measured.
 
>
> Thanks,
> Kanu

Kanu Kalra

unread,
Sep 26, 2017, 3:27:47 AM9/26/17
to Evgeny Mandrikov, JaCoCo and EclEmma Users
hi evgeny,

i have used Ant coverage tasks and it works perfectly fine for unit tests running in the same jvm as server. jacoco.exec file is created. 

But when tests run outside the server jvm, then no jacoco-it.exec file gets generated. It is the same instrumented code with ant coverage tasks. Any idea why?

Do I explicitely need to start the java agent for jacoco in server vm in addition to specifying ant coverage task?

Thanks
Kanu

Evgeny Mandrikov

unread,
Sep 26, 2017, 7:00:34 AM9/26/17
to JaCoCo and EclEmma Users
Once again: agent should be attached to the JVM that executes application whose coverage should be measured.

Task "coverage" configures nested tasks that start Java to use agent. Instrumentation is performed by agent at runtime within JVM that uses agent and does not affect classes on disk.

If task "coverage" is not used to start server, then it starts without agent and hence classes running inside this JVM are not instrumented and their coverage is not recorded.

So yes - if you want to measure coverage of classes that are executed in your server, then you must start server with agent.

As written in documentation at http://www.jacoco.org/jacoco/trunk/doc/ant.html :
if you can't use task "coverage" to launch your application, then alternatively you can use task "agent" that will define Ant property containing agent configuration that can be passed as parameter for "java" to start your server, or you can configure such "java" parameter manually without Ant at all.

supar...@gmail.com

unread,
Nov 15, 2017, 6:42:35 AM11/15/17
to JaCoCo and EclEmma Users
Hi,

Yes, it works perfectly fine with other test-codes as well. We have tried it manually and using c# test automation code to verify this. Same way, it will work for other languages too.

Feel free to check out our solution here:

http://www.qalearningguide.com/2017/10/code-coverage-for-android-using-jacoco.html

Hope this helps you as well.

Thanks,
Suparna

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages