This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Testing and the fly likes Any good opensource code coverage tools? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Any good opensource code coverage tools?" Watch "Any good opensource code coverage tools?" New topic
Author

Any good opensource code coverage tools?

Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Are there good opensource code coverage tools? please let me know if there is one.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
There is Hansel but I have never used it so I can't comment on the quality/usefulness.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Vincent Massol
Author
Ranch Hand

Joined: Aug 09, 2003
Posts: 70
Originally posted by karthik Guru:
Are there good opensource code coverage tools? please let me know if there is one.

There are none that I know of at this moment in time. The most promising is Quilt. However, I much prefer Clover (not free, except for open source projects). There's also jcoverage which looks very nice (again not free, except for open source projects).


-Vincent<br /><a href="http://www.manning.com/massol" target="_blank" rel="nofollow">JUnit in Action</a> author
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Vincent, why isn't Quilt up to it just yet (assuming I interpreted your words correctly)?
Vincent Massol
Author
Ranch Hand

Joined: Aug 09, 2003
Posts: 70
Originally posted by Lasse Koskela:
Vincent, why isn't Quilt up to it just yet (assuming I interpreted your words correctly)?

Actually, I'm not sure... I've tried it about 1 year ago and it looked nice but it wasn't easy to use and:
- it was using a specific classloader which is not that easy to integrate for J2EE applications
- it wasn't doing statement coverage
I haven't looked at it recently as I've been extremely happy with Clover which is really easy to use.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Actually, I'm not sure... I've tried it about 1 year ago and it looked nice but it wasn't easy to use and:
- it was using a specific classloader which is not that easy to integrate for J2EE applications

Thanks. I just remembered that Hansel also uses an instrumenting class loader so they're probably both no-no's for testing code coverage in a J2EE context...
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
I recently (like two weeks ago) got a copy of Clover and it really is an excellent tool. Very easy to use, particularly if you're an IntelliJ user.
Vlad Roubtsov
Greenhorn

Joined: Jun 14, 2003
Posts: 9
Check out EMMA as well.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
In addition to those already mentioned in this thread, there's JCoverage/gpl and GroboUtils code coverage.
Tonny Tssagovic
Ranch Hand

Joined: Dec 30, 2003
Posts: 226
Hello people,
I just read this thread and I have a question, isn't code coverage done in Unit testing? I mean u make assertions with input that would actually go through all kind of extreme situations in loops /if/else statements and so on, so that ur input is actually checking full code coverage???
If This is not the case, then how would you chose your input/expected output pairs??
How about system /final test, what kind of input would you chose?
Please help a newbie!
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Yes, code coverage is about how thoroughly your test code exercises your production code.
Tonny Tssagovic
Ranch Hand

Joined: Dec 30, 2003
Posts: 226
Thanks for the reply Lasse
And is this (code coverage) usually done by Unit testing the classes?
and how about the final SYSTEM test?
Thanks in advance
Vlad Roubtsov
Greenhorn

Joined: Jun 14, 2003
Posts: 9
Originally posted by Tonny Tssagovic:
And is this (code coverage) usually done by Unit testing the classes?
and how about the final SYSTEM test?


How you induce code coverage is up to you. In many case you would have a functional testsuite written: a collection of unit testcases that exercise product logic in various ways. Running such a testsuite with a code coverage tool allows you to see how well you are targeting your product code with your testcases. A good functional testsuite will have basic block/line coverage somewhere in the area of 80%+ and method coverage in the area of 70%+. Good software companies will not release software with code coverage below such thresholds.

However, this is not the only way to get code coverage. For example, you might have an interactive application that is difficult to test automatically. In this case you might test the application by hand (or use a team of QA engineers with a set of standard UI interaction scripts) and get code coverage this way, without an automated testsuite.

"System" testing usually refers to validating the product code on the platform on which is will be deployed. E.g., if your targeted platform is Solaris, you would have to get yourself a machine that runs Solaris even though you are developing on win32 or Linux.

Ideally, you validate code coverage way before system testing. In fact, you should do it while still writing testcases. This is because a code coverage tool allows you to see which packages are still untouched by the testcases and to partition your test writing time in the best possible way.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Any good opensource code coverage tools?
 
Similar Threads
One interview question i faced today, any one help ?
all classes?
Coverage Tool
Open Source Tools
Code coverage tools and AIX