Registered: Jun, 2003
Re: Testing Private Methods with JUnit and SuiteRunner
Posted: May 25, 2004 2:05 AM
Bill, your parseArgsIntoLists function screamed duplication to me.
Does it indicate that parseArgsIntoLists should be moved into another class to promote reusability, as the JUnit FAQ suggests? Would Dave and Andy say its a warning sign that there's another class in there struggling to get out?
Yes and yes, imnsho.
I don't know Java, so the following probably doesn't work, and you may not care for the brace alignment, but it conveys, to me a much clearer sense of what is happening than the original code (and I'm sure real working Java could be written that looks more like this):
switch args[ i].firstTwoCharacters()
case "-p": addNextTwoArguments(runpathList, i);
"-e": reportersList.add(args[ i])
"-r": addNextTwoArguments(reportersList, i);
case "-s": addRemainingArguments(suitesList, i);
default: throw new IllegalArgumentException("Unrecognized argument: "
+ args[ i]);
And here's a bug (well, undesired behavior at least): in the web formatting code: since the java code includes bracket-i-bracket, it italicizes everything after(I'm adding spaces to prevent that...)