Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cobertura in eclipse

I just installed ecobertura plugin, but it looks like not a very user-friendly tool from within eclipse. is there any good plugin for cobertura in eclipse or article to describe how to use ecobertura?

I'm used to seeing code complexity and coverge etc in a very nice way.

I need to use cobertura, because the build system in the back-end uses it, so it makes sens to use it in the IDE as well.

Regards

like image 611
Charbel Avatar asked Feb 17 '11 11:02

Charbel


People also ask

How do I run cobertura in eclipse?

Now that eCobertura is installed, restart Eclipse and show the coverage session view under Windows → Show View → Other → Cobertura.

What is cobertura format?

Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage.

Where is cobertura report?

start test in web interface ( by default localhost:9000/@tests) and go to your_host:your_port/@cobertura ( by default it's http://localhost:9000/@cobertura ) for generate new report or reset previous. And now you can see html report in iframe or directly on file:/path/to/your/application/test-result/code-coverage/.


3 Answers

I was looking for a tutorial for our team members to start using eCobertura and came across here. I end up writing one myself. Posting back here hope it may help others looking for a jump start.

http://kennethxu.blogspot.com/2012/01/cobertura-and-eclipse-ecobertura.html

like image 100
Kenneth Xu Avatar answered Oct 05 '22 20:10

Kenneth Xu


From the sources:

  • there should be launch configuration's "filters" tab, for you to define what class to filter and analyze: see changeset 2ecbb202e8c5
  • there is no instances of "cyclomatic complexity" anywhere in the code.

But you still can fork the code base (like mileszk did) and add any feature you want (and contribute back to the main project of course ;) )

like image 30
VonC Avatar answered Oct 05 '22 19:10

VonC


I am using Eclipse Luna and I had difficulty installing the ecobertura plugin. So I installed EclEmma plugin and it was intitutive to use it. After installing the plugin, restart the eclipse IDE.

To find the coverage of the test cases you have written, all you have to do is

Right click on the desired package or even the whole project > Coverage As > Junit Test

The Coverage View automatically appears. Or you can open the coverage view from Window > Show View > Other > Java > Coverage. Or you can just type "Coverage" in the Quick Access search box in the eclipse.

The Coverage view is capable of displaying the coverage percentage at project level, source folder level, package level, Class level and even at method level.

Coverage View

You can change the root level of the entries shown in the coverage tree by using the toolbar in the coverage view.

Tool bar in the Coverage View

enter image description here

You can change the coverage parameters to method or Line or instruction or brach based on your requirement.

enter image description here

And finally you can export the test coverage results to HTML or XML or CSV formats by right-clicking anywhere inside the coverage view and selecting Export session.

enter image description hereexport test coverage reportexport test coverage report format

like image 27
rudrasiva86 Avatar answered Oct 05 '22 20:10

rudrasiva86