1

I was interested to get path coverage for my code after doing unit testing, but it contains lots of if-else conditions which make the actual number of paths like around 67k so is there any possibility with jmockit coverage tool to exclude some if conditions to be considered for path in the code.

Is there any other tool which I can use to achieve the same goal ?

solvesak
  • 166
  • 1
  • 13

1 Answers1

1

It looks like JMockit coverage allows you exclude code at the class level. See http://jmockit.googlecode.com/svn/trunk/www/tutorial/CodeCoverage.html. But I don't think there's a way to exclude anything at a lower level than the class.

For Cobertura, see Exclude methods from code coverage with Cobertura. Class level exclusions only, though.

However, note that a lot of people are moving away from Cobertura because it doesn't seem to be very actively developed anymore. JaCoCo seems to be the new favorite coverage tool. And it supports exclusions...see http://www.eclemma.org/jacoco/trunk/doc/agent.html. But again, only at the class level.

Community
  • 1
  • 1
Jeff Olson
  • 6,323
  • 2
  • 22
  • 26
  • So how do these tools handle *path* coverage (http://en.wikipedia.org/wiki/Code_coverage)? I think they do branch/decision coverage at best. – Ira Baxter May 14 '13 at 17:30
  • @IraBaxter, correct, I don't think any of these tools support path coverage. I wasn't actually aware of the difference between branch and path coverage, so thanks for pointing that out. See http://stackoverflow.com/questions/1518362/code-coverage-tools-in-java – Jeff Olson May 14 '13 at 17:43
  • And to clarify, JMockit Coverage *does* support path coverage, unlike Cobertura and JaCoCo. – Jeff Olson May 15 '13 at 00:43