1 package org.junit.runners; 2 3 import java.lang.reflect.InvocationTargetException ; 4 import java.lang.reflect.Method ; 5 import java.lang.reflect.Modifier ; 6 7 import junit.framework.Test; 8 import org.junit.internal.runners.OldTestClassRunner; 9 10 22 public class AllTests extends OldTestClassRunner { 23 @SuppressWarnings ("unchecked") 24 public AllTests(Class <?> klass) throws Throwable { 25 super(testFromSuiteMethod(klass)); 26 } 27 28 public static Test testFromSuiteMethod(Class <?> klass) throws Throwable { 29 Method suiteMethod= null; 30 Test suite= null; 31 try { 32 suiteMethod= klass.getMethod("suite"); 33 if (! Modifier.isStatic(suiteMethod.getModifiers())) { 34 throw new Exception (klass.getName() + ".suite() must be static"); 35 } 36 suite= (Test) suiteMethod.invoke(null); } catch (InvocationTargetException e) { 38 throw e.getCause(); 39 } 40 return suite; 41 } 42 } 43 | Popular Tags |