[Texas PLT logo]

COMP 402: Production Programming

  Code Coverage Tools  

Today's Menu:

Code Coverage Background

Code coverage tools record what parts of the program are executed. This is particularly useful in conjunction with unit tests, since the results of those tools show which portions of the program are exercised by the tests. For example, it can tell you that a test with an if-then-else construct only enters the then block, but never the else block.

To remember what lines have been executed how many times, either the source code or the compiled class files are annotated with counters for each line of code and statements incrementing those counters. Then the tests are run as usual, with the side effect of remembering how may times a line was executed. Before the program finishes, the values of the counters are written to disk and a report is generated.

Running Clover on DrJava

As long as you have Clover available on your system (e.g. on CSnet), you can run the unit tests and generate a code coverage report by typing:

ant clover

We will try to keep updated test coverage reports on the DrJava website.

  Code Coverage Tools  

URL: http://www.cs.rice.edu/teaching/402/09-spring/lectures/codeCoverage/index.shtml
Copyright © 2008-2010 Mathias Ricken