Search code examples
javacode-coveragejunit3rtc

JUnit 3, how to find which tests covered my lines of code? (RTC...maybe?)


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.


Solution

  • 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").