01: package com.mockrunner.test.consistency;
02:
03: import java.lang.reflect.Method;
04:
05: import junit.framework.Test;
06: import junit.framework.TestResult;
07: import junit.framework.TestSuite;
08: import junit.textui.TestRunner;
09:
10: public class Launcher {
11: public void run(String testClassName) throws Exception {
12: Class testClass = this .getClass().getClassLoader().loadClass(
13: testClassName);
14: Test test = null;
15: if (!Test.class.isAssignableFrom(testClass)) {
16: Method method = testClass.getMethod("suite", null);
17: test = (Test) method.invoke(null, null);
18: } else {
19: test = new TestSuite(testClass);
20: }
21: TestResult result = TestRunner.run(test);
22: if (!result.wasSuccessful()) {
23: throw new RuntimeException("Test " + testClassName
24: + " failed");
25: }
26: }
27: }
|