Chapter 22: Code Coverage with jcoverage


Overview

Code coverage represents a new facet of test driven development (TDD), that is moving many developers to write their tests first and their classes to fit the tests. Code coverage aids this philosophy by ensuring that you are indeed testing what you think you are testing. It also allows you to quickly fix your tests for new pieces of functionality, by highlighting new or changed code that may not be properly tested. This enables developers to move forward with confidence that their code is fully tested .

As part of any unit testing implementation you should seriously consider adding code coverage to your toolbox. jcoverage is one such tool. There are other options: Quilt, another open source project, offers the same kind of reports ; and there is Clover, which is a closed source but open source project-friendly tool. Of these tools, though, we use jcoverage for several reasons: it is code-complete, it is available under the GPL license for free use, and there is a closed source version with advanced features also available.

So, what does jcoverage offer you? jcoverage uses byte-code manipulation or enhancement to hook into your base classes for unit testing analysis. jcoverage refers to this as instrumentation , and it uses this instrumentation along with your unit tests to generate reports. The reports list classes that you haven't completely tested, as well as problematic areas in your code that could cause you grief later on. By doing this it can ensure that you are indeed properly testing all of your code ”you are "test-infected" aren't you? After all, code that isn't properly tested is potentially buggy code, and that is something that none of us wants.

start sidebar
Where to Get jcoverage

jcoverage was created by jcoverage ltd. It is available in two versions jcoverage+ which is a commercial product or jcoverage which is licensed under the GNU Public License and is available as a free download. jcoverage+ adds in quite a few features and is worth checking out if you like the open source version. Both versions can be downloaded from:

http://www.jcoverage.com/

end sidebar
 



Professional Java Tools for Extreme Programming
Professional Java Tools for Extreme Programming: Ant, XDoclet, JUnit, Cactus, and Maven (Programmer to Programmer)
ISBN: 0764556177
EAN: 2147483647
Year: 2003
Pages: 228

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net