Thanks Rod. One thing you may want to do though is add your code snippet to the Cargo wiki for posterity!
Here would be a good place: http://wiki.apache.org/jakarta-cactus/UsefulCode Thanks! -Vincent > -----Original Message----- > From: Rod Macpherson [mailto:[EMAIL PROTECTED] > Sent: mercredi 21 septembre 2005 21:11 > To: Cactus Users List > Subject: RE: Sweeter Suites > > Fine, be that way:) > > I agree it's an incomplete and somewhat fluffy Junit extension. > > Here's the implementation for anybody interested: > > package junit.framework.sugar; > > import java.lang.reflect.Constructor; > import java.lang.reflect.InvocationTargetException; > > import junit.framework.TestCase; > import org.apache.cactus.ServletTestSuite; > > Public class MethodTestSuite extends ServletTestSuite > { > private Constructor constructor; > > public MethodTestSuite(Class<? extends TestCase> klass) > { > try > { > constructor = klass.getConstructor(new Class[] { > String.class } ); > } > catch(NoSuchMethodException e) > { > assert false : e.getMessage(); > } > } > > public void add(String test) > { > try > { > > addTest((TestCase)constructor.newInstance((Object[])new > String[]{test})); > } > catch(InvocationTargetException e) > { > assert false : e.getMessage(); > } > catch(InstantiationException e) > { > assert false : e.getMessage(); > } > catch(IllegalAccessException e) > { > assert false : e.getMessage(); > } > } > } > > -----Original Message----- > From: Vincent Massol [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 21, 2005 11:57 AM > To: 'Cactus Users List' > Subject: RE: Sweeter Suites > > Hi Rod, > > > -----Original Message----- > > From: Rod Macpherson [mailto:[EMAIL PROTECTED] > > Sent: mercredi 21 septembre 2005 15:42 > > To: Cactus Users List > > Subject: Sweeter Suites > > > > Would something like this be worth adding to cactus? I cobbled > > together a class called MethodTestSuite that dynamically creates tests > > > based on a method name. Granted, it's just syntatic sugar for > > suite.add(newMyTestSuite("myMethod")) which I found rather tart:) > > Thanks for the proposal. Personally I don't think it fits in the Cactus > project. I don't see anything related to Cactus there. I do see stuff > related to JUnit though but JUnit is a different project... > > > public class MyTestSuite extends TestCase { > > public static Test suite() > > { > > MethodTestSuite suite = new > > MethodTestSuite(MyTestSuite.class); > > > > suite.add("testDial"); > > suite.add("testConnect"); > > suite.add("testDisconnect"); > > > > return suite; > > } > > ... > > } > > It doesn't buy you much I think and also it doesn't support Test suite > constructors that take more than a string parameter. Anyway that's a > junit topic. > > Thanks > -Vincent > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]