1 package org.junit.internal.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
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public class SuiteMethod extends JUnit38ClassRunner {
23 public SuiteMethod(Class<?> klass) throws Throwable {
24 super(testFromSuiteMethod(klass));
25 }
26
27 public static Test testFromSuiteMethod(Class<?> klass) throws Throwable {
28 Method suiteMethod = null;
29 Test suite = null;
30 try {
31 suiteMethod = klass.getMethod("suite");
32 if (!Modifier.isStatic(suiteMethod.getModifiers())) {
33 throw new Exception(klass.getName() + ".suite() must be static");
34 }
35 suite = (Test) suiteMethod.invoke(null);
36 } catch (InvocationTargetException e) {
37 throw e.getCause();
38 }
39 return suite;
40 }
41 }