carbidecpp20devenv/plugins/org.eclipse.test.source_3.3.0.v20080507/src/org.junit4_4.3.1/junitsrc/org/junit/runners/AllTests.java
equal
deleted
inserted
replaced
|
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 /** Runner for use with JUnit 3.8.x-style AllTests classes |
|
11 * (those that only implement a static <code>suite()</code> |
|
12 * method). For example: |
|
13 * <pre> |
|
14 * @RunWith(AllTests.class) |
|
15 * public class ProductTests { |
|
16 * public static junit.framework.Test suite() { |
|
17 * ... |
|
18 * } |
|
19 * } |
|
20 * </pre> |
|
21 */ |
|
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); // static method |
|
37 } catch (InvocationTargetException e) { |
|
38 throw e.getCause(); |
|
39 } |
|
40 return suite; |
|
41 } |
|
42 } |