2

The scenario is: I've run JUnit code coverage in eclipse with RTC installed. I have this view called "Coverage" that I am not sure about, but it seems to show me the code coverage of my JUnit tests. It shows for every package, class and method a percent, and when look at a class in the editor some lines are indeed green, red or yellow.

My main issue is : How could i find out in what test is one of my methods covered? (And no, ctrl+G doesn't help, because it's referenced by many other methods until i get to the test method). Isn't there an easier way to find the test method starting from the method being tested?

I've also got a minor issue: why are some lines in the actual test methods colored in red? Is there possibly an exception being thrown and thus the code is not executed?

Thx, you guys rule.

vlad-ardelean
  • 7,480
  • 15
  • 80
  • 124
  • 1
    Did you try any code coverage tool, Emma, Cobertura usw. – Kayser Mar 13 '12 at 12:00
  • You seem to use the [eclipse emma plugin](http://www.eclemma.org/). Have a look at the site, it will at least tell you whhat the colors mean. I don't think this plugin supports finding the test that covered the lines. – oers Mar 13 '12 at 12:04

2 Answers2

1

Clover provides this feature, but it is not free. I've used Cobertura and Emma which are free, but Clover is worth the cost.

Paul Croarkin
  • 14,496
  • 14
  • 79
  • 118
1

If you are talking about RAD coverage (which can be integrated in RTC), see "Getting Started with Jazz Code Coverage":

Go to the project properties of your project (Alt+Enter), browse to the Coverage tab, and enable static code instrumentation.

packageexplorer coveragereport1

So your main class tested is the one of your Java Application.
The lines in red in your code are the lines not executed during your tests (ie, not "covered").

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250