convert Jacoco to cobertura or viceversa

2,916 views
Skip to first unread message

Balugu Ravindhar

unread,
Apr 27, 2017, 8:20:50 AM4/27/17
to JaCoCo and EclEmma Users
Hi,
We have cobertura coverage and now we started with Jacoco. However we have to use both for some time so, i am looking for way to convert Jacoco coverage to Cobertura or vice-versa to have overall coverage report.
Any pointers? 

Thanks
Ravindhar

Sean Flanigan

unread,
Apr 27, 2017, 8:23:57 AM4/27/17
to jac...@googlegroups.com
It's not a pure Java solution, unfortunately, but we've been using the Python script https://github.com/rix0rrr/cover2cover successfully.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/e6605cbe-4fc5-447b-8152-c5caf56e1d49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Balugu Ravindhar

unread,
Apr 30, 2017, 2:31:07 AM4/30/17
to JaCoCo and EclEmma Users
Yes I have tried this the Python Tool cover2cover.py however, i am not been able to successful to convert Jacoco to cobertura. 
I did following, please help me what should be correct way.

We are actually trying measure the code coverage for Regression Tests, so the tests are run pre-production setups.
1) The application is Jboss based, so we have configured Jboss with java agent jar to dump the .exec file on completion of tests.
2) We run the Tests and stop the Jboss server, it dumps the .exec file.
3) Then we copy the jacoco.exec file to a Developer setup where we have src code. 
4) I have used the ant script to generate the report out of the collected jacoco.exec file. It generated couple of files. report.xml,report.csv , index,html,jacoco-session.html and respective class folder html files under target/site/jacoco/, 

ant report


Now the question is which file i should use for converting Jacoco to cobertura? is it report.xml ?

I tried this way but i don't see any cobertura.xml generated.

python cover2cover.py ../Jacoco/target/site/jacoco/report.xml /root/secmgt/

the console printed the below:

<?xml version="1.0" ?>
<coverage branch-rate="0.181364665237" complexity="81366.0" line-rate="0.277190735404" timestamp="1493102622"><sources><source>/root/secmgt/</source></sources><packages /></coverage>



to convert to cobertura, i have tried 

On Thursday, 27 April 2017 17:53:57 UTC+5:30, Sean Flanigan wrote:
It's not a pure Java solution, unfortunately, but we've been using the Python script https://github.com/rix0rrr/cover2cover successfully.
On 27 April 2017 at 22:20, Balugu Ravindhar <ravindha...@gmail.com> wrote:
Hi,
We have cobertura coverage and now we started with Jacoco. However we have to use both for some time so, i am looking for way to convert Jacoco coverage to Cobertura or vice-versa to have overall coverage report.
Any pointers? 

Thanks
Ravindhar

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

Sean Flanigan

unread,
Apr 30, 2017, 7:46:47 AM4/30/17
to jac...@googlegroups.com
Yes, it needs Jacoco's XML report. I think the second argument is supposed to be the root of your Java source directory, which typically contains "org" or "com". (For a Maven project, it would be {project-dir}/src/main/java.) Then you have to redirect the output to cobertura.xml instead of the console.


To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/918a883f-ab25-4367-b5a3-496028a468f9%40googlegroups.com.

Balugu Ravindhar

unread,
May 3, 2017, 2:35:22 AM5/3/17
to JaCoCo and EclEmma Users
Hi Sean,
I have tried giving the second argument src folder and redirected output cobertura.xml. I see only 2 lines which is does not seem like converted cobertura xml.
actually in my case i have many src folders, the one i given as argument below command is one of them. Is that an issue? how i can supply multiple src folders.
python cover2cover.py ../Jacoco/target/site/jacoco/report.xml ../secmgt/sm/src > ../cobertura/cobertura.xml

$ cat cobertura.xml
<?xml version="1.0" ?>
<coverage branch-rate="0.181364665237" complexity="81366.0" line-rate="0.277190735404" timestamp="1493102622"><sources><source>../secmgt/sm/sm-shared/src/net/juniper/jnap</source><source>../secmgt/sm/sm-shared/src/net/juniper/sm</source><source>../secmgt/sm/sm-shared/src/net/juniper/space</source></sources><packages /></coverage>

Appreciate your help!!

Thanks,
Ravindhar

Sean Flanigan

unread,
May 3, 2017, 3:45:03 AM5/3/17
to jac...@googlegroups.com
I think cover2cover does support multiple source roots, but it looks like you might have just one source *root* (with multiple package folders inside).

Try this:

python cover2cover.py ../Jacoco/target/site/jacoco/report.xml ../secmgt/sm/sm-shared/src > ../cobertura/cobertura.xml

If that doesn't work, reading cover2cover.py might give you a hint.


To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/8110b4f9-dc7a-43ba-901b-2d58fd607f5c%40googlegroups.com.

Balugu Ravindhar

unread,
May 3, 2017, 8:17:03 AM5/3/17
to jac...@googlegroups.com
I see something after correcting the src folders argument, but is this how it looks like? though the sources are properly dumped the packages/classes/branches/lines are empty. It seems the tool does not finding the packages under the sources. My project is not complete maven structured project. So how i can overcome this problem.


<?xml version="1.0" ?>
<coverage branch-rate="0.181364665237" complexity="81366.0"
line-rate="0.277190735404" timestamp="1493102622">
<sources>
...
...
...
</sources>
<packages />
</coverage>

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/MIf7EtffVS4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/8110b4f9-dc7a-43ba-901b-2d58fd607f5c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



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