4

I have a massive program, and I want to execute a use case (will require user input), which will not be a JUnit test, kill the program, and see which lines of code were hit. This simple use case will go through thousands of lines of code, so adding trace comments on each line to see where I am will take forever.

Is there anything like this? If it could display the covered code in a way similar to http://www.eclemma.org/ that would be amazing!

Thanks for any help/information!

Sam
  • 51
  • 1
  • 4
  • What's wrong with eclemma? – Ira Baxter Mar 12 '13 at 09:00
  • @IraBaxter It won't show accurate results when an exception has occurred. – Duncan Jones Mar 12 '13 at 09:01
  • @Duncan Jones: Really? Specifically, what does it show that is inaccurate? (OP seemed to think it was fine) – Ira Baxter Mar 12 '13 at 09:02
  • 1
    @IraBaxter It will not mark all the code as covered. See [this FAQ entry](http://www.eclemma.org/faq.html#trouble05) titled "*Code with exceptions shows no coverage. Why?*". – Duncan Jones Mar 12 '13 at 09:04
  • Yes, @DuncanJones is correct. When I manually kill the program, eclemma says "Please do not terminate the java process manually from eclipse" and throws an error, and then doesn't show me any results. – Sam Mar 12 '13 at 09:09
  • @DuncanJones: So, two statements x=p+q; y=z/0; will not show coverage because the the divide-by-zero exception? Its pretty hard to do this with any scheme that uses probes. – Ira Baxter Mar 12 '13 at 09:09
  • @Sam: so a solution that would collect test coverage data, and allow you to gracefully abort the program while collecting that data, would be acceptable? (You seem to have a fixation on running-in-Eclipse, is that a necessity?) – Ira Baxter Mar 12 '13 at 09:11

1 Answers1

0

Our Java Test Coverage tool shows the executed lines (and partial lines) superimposed on your source code using its built-in display. It is not specifically Eclipse-based, but OP's issue seems to be with scale and interactivity, not Eclipse.

It suffers, as most probe-based test coverage tools do, from an inability to provide precise coverage information on unconditional blocks of code which throw an exception in the middle; it will record the entire block as "executed" if only part of it is executed, and it will capture the execution of any associated exception handler. However, unlike most binary instrumenters, if it encounters multiple conditionals in a single line of code, it will correctly capture which part of the line gets executed.

It can collect execution information from tests of any kind, include manual exercising of the code. It can also be configured to collect test coverage data at any point during program execution, so it is useful for collecting coverage on long-running server programs, or if you need to abort the execution at some arbitrary point.

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341