«« Java IOException and Code Coverage Looking for Work »»
blog header image
Unit Test Eclipse View
I'd like to have a plugin for Eclipse that will allow me to see unit tests I have written for a method. But not all unit tests that use that method because sometimes that could be a lot -- just the tests I've written to specifically test that method. I usually name the tests using a convention like:

test[MethodName]_[Description]()

and they will be grouped in files by class. To demonstrate this idea I'm going to take a method I made test-first from the AudioMan project. It takes a long of seconds and returns a formatted String of the format hh:mm:ss. Pretty simple, but it has quite a few tests and it would be nice if they were summarized in a compact view so I can make sure I have all of the boundary cases. Then I could do some semi-formal boundary value analysis. Here's a table of what the view might look like:

Tests for String formatTrackTime(long)
DescriptionInput (long)Output (String)
Negative-1IllegalArgumentException
Zero00:00
OneSecond10:01
TenSeconds100:10
OneMinuteMinusOneSecond590:59
OneMinute601:00
OneMinutePlusOneSecond611:01
TenMinutesMinusOneSecond5999:59
TenMinutes60010:00
TenMinutesPlusOneSecond60110:01
OneHourMinusOneSecond359959:59
OneHour36001:00:00
OneHourPlusOneSecond36011:00:01

I think this view would be a lot easier than looking at a bunch of unit tests -- even in the Outline View (below) -- that you have to scroll up and down.



After being able to view the tests the next step could be allowing the developer to insert a new test. You can fill in the description in the table, the test skeleton is made for you and you double-click on it to fill in the implementation.

After that you could get the plugin to make the tests for you completely. With simple inputs and outputs like this example it would be relatively easy I think, but sometimes tests can be much more complicated. In those cases it would still be useful to see the table view but instead of exact variable values written for inputs and outputs you would have brief descriptions and fill in the test implementation manually. Posted at November 03, 2003 at 12:03 AM EST
Last updated November 03, 2003 at 12:03 AM EST
Comments


I like the idea of tags like in .Net so that this info could be captured outside of the test name. This would allow assigned a test to multiple methods and purposes...

This additional request is when you are using your testing framework for more than just unit testing (because it can do so much more) - perhaps when resolving a bug.

i.e.
test_MakeSureThatThisSheeatNeverHappensAgain();

So, it would be nice to associate this test to the interaction of two methods for example ... just a thought

» Posted by: aforward at November 3, 2003 02:16 PM

Getting lazy on me already eh? :) While I can see the efficiency of allowing tests targetting more than one method I think it starts to stray from organized boundary value analysis. Targetting one method at a time is more explicit.

But I do agree that sometimes a bug or situation cannot be associated to one single method and we'd have to work around that sort of case.

I also like the idea of hooking to bugs to watch for bad regressions -- actually, any regression is bad but ones that customers have already noticed are really bad. But having the bug number in the method name is kinda useless -- maybe a link to the repository (ie. Bugzilla).

» Posted by: Ryan at November 3, 2003 02:27 PM

there's much to be desired in the realm of software testing ... i'm just wondering how much peeps are willing to pay for a methodology

» Posted by: aforward at November 3, 2003 03:20 PM

That is the ironic thing. Old-schoolers still think that it's something they can ship off afterwards. If only they realised how much of the testing phase they could cut out if they only did it during development BY developers ...

... of course then we'd have to get old school developers to write tests. Yeah right.

» Posted by: Ryan at November 3, 2003 04:50 PM

I do not think so.

» Posted by: Jim at January 6, 2004 05:30 AM
Google
 
Search scope: Web ryanlowe.ca