JUnit Doclet PatchesAbout my JUnitDoclet patches
Exception Handling PatchDescriptionMy patch adds automatic code generation for exception handling. Consider the following method:
public void setPriceCode(int i) throws IllegalPriceException {
if(i != CHILDRENS || i != REGULAR || i != NEW_RELEASE){
throw new IllegalPriceException("illegal price code!");
}
else { priceCode = i; }
}
JUnitDoclet now generates the following test automatically:
public void testSetPriceCode throws Exception {
// JUnitDoclet begin method getTitle
//insert code testing basic functionality
try {
movie.setPriceCode(null);
}
catch (Throwable e) {
fail("Failed with:" + e);
}
//insert code triggering IllegalPriceException
try {
movie.setPriceCode(null);
fail("Should raise IllegalPriceException");
}
catch (IllegalPriceException e) {
}
catch (Throwable e) {
fail("Failed with:" + e);
}
// JUnitDoclet end method getTitle
}
RequirementsYou need version 1.0.2 of JUnitDoclet. Download
How to apply the patchTo apply the patch, get the source distribution, unzip the src.zip in it and then execute this: patch -p1 -u < JUnitDoclet_exeception_handling.patch © Copyright 2004 - 2006 Nicola Fankhauser. All Rights Reserved. |