1 package info.jtrac.watij; 2 3 import java.lang.reflect.Constructor ; 4 import java.lang.reflect.Method ; 5 import junit.framework.Test; 6 import junit.framework.TestCase; 7 import junit.framework.TestSuite; 8 import watij.runtime.ie.IE; 9 10 public abstract class WatijTestCase extends TestCase { 11 12 public WatijTestCase(String name) { 13 super(name); 14 } 15 16 private static ThreadLocalIE threadLocalIE; 17 protected static Class clazz; 18 protected IE ie; 19 20 public static Test suite() throws Exception { 21 threadLocalIE = new ThreadLocalIE(); 22 Constructor constructor = clazz.getDeclaredConstructors()[0]; 23 Method [] methods = clazz.getMethods(); 24 TestSuite s = new TestSuite(); 25 for(Method m : methods) { 26 if (m.getName().startsWith("test")) { 27 Test test = (Test) constructor.newInstance(new Object [] { m.getName() }); 28 s.addTest(test); 29 } 30 } 31 return s; 32 } 33 34 private static class ThreadLocalIE extends ThreadLocal { 35 @Override 36 public IE initialValue() { 37 return new IE(); 38 } 39 } 40 41 @Override 42 public final void setUp() { 43 ie = (IE) threadLocalIE.get(); 44 } 45 46 } 47 | Popular Tags |