mchr
mchr

Reputation: 6251

Java code coverage tools which support source line exclusions

I currently use Clover to measure the code coverage of my Java code. One feature which I rely on is the ability to exclude arbitrary sections of code from coverage reports:

///CLOVER:OFF because this case is simpler to verify by code read
if (lFile.isFile() &&
    lFile.getName().endsWith(FILE_EXTN) &&
    !lFile.delete())
{
  throw new IOException("delete() failed for: " + lFile);
}
///CLOVER:ON

I find this kind of exclusion makes it much easier to focus on testing the interesting logic while still achieving 100% code coverage.

Are there any other Java code coverage tools (either free or paid) which support this kind of fine grained exclusion? Whole class or whole method exclusions aren't good enough.

NOTE: I am currently investigating adding something suitable to JaCoCo (Issue #14).

Upvotes: 12

Views: 1603

Answers (2)

Captain Caveman
Captain Caveman

Reputation: 71

From my experience, the following all work well:

  • In terms of closed-source: Clover
  • In terms of open-source: Cobetura (but does not work with Java 7), EMMA

Upvotes: 1

Ruchira Gayan Ranaweera
Ruchira Gayan Ranaweera

Reputation: 35547

Followings are open source java code coverage tools. Those may help you NoUnit InsECT Jester JVMDI Code Coverage Analyser GroboCodeCoverage jcoverage/gpl JBlanket Cobertura Coverlipse Hansel CodeCover EMMA PIT

Upvotes: 1

Related Questions