SUnitToo Code Coverage Refactoring Browser
Return to home page
Comments Loading...
2007-01-19

I posted a sneak piccie of this a few days ago. I've just published it to public store. There are a couple of coverage tools around so I'm going to take a moment to explain why this one is different from the others.

The most well known coverage tool is called Zork-Analysis. It was built with categories in mind - you can add/remove wrappers en-masse via categories. It was also built when there were no wacky syntax extensions in VW - such as pragmas and other interesting things. As a result, this package sometimes works and sometimes doesn't. One of the nice things about this package was that it would gather up type information as it collected coverage information. It also knew which branches of your program had executed or not.

This was a big step up from the coverage tool I used to use in VisualAge Smalltalk, which only told you what had been run - and nothing more. So neither of these are state of the art any more. Kritic, really, is the state of the art code coverage tool for VisualWorks. Unfortunately, it is not finished nor released yet - but keep an eye out for when it does. It uses debugging probes to monitor what's going on. Like Zork, it knows which branches of code you've actually executed. It also has a UI that is designed around the idea of 'marking' code to be monitored.

So when I started the SUnitToo(verage) I wanted to break out of the mold of "mark code, run code". Instead, my coverage tool works virally. It starts with a unit test that you're running and wraps up any method that you're going to call (unless said method is a bad method to wrap up).

This avoids the classic UI pattern of "wrap up some code - do something - unwrap up the code". It also has the potential to capture type information - but I decided against doing that for now, since it was noise to what I was trying to achieve. The UI is also integrated in to SUnitToo(ls) such that you click "coverage on" before running your tests. The results will appear inline in the Refactoring Browser as red text giving you a percentage of coverage against classes and methods.

Methods themselves know what percentage of their execution pathways were executed. This is highly useful. Simple methods such as getters, setters, subclassResponsibility callers etc don't actually get counted in the coverage either. We're aiming for behavior here, not 100% coverage of everything even the smallest and most obvious of things.

To give this a go, load SUnitToo 39 and SUnitToo(ls) 34 + coverage. There's a button in the toolbar that looks like an eraser that 'resets' the coverage statistics whenever you want. Simply find some SUnitToo tests, click "coverage" on and run the tests.

Enjoy.