1
2
3
4
5
6
7
8 package cldcunit.runner;
9
10 import junit.framework.Test;
11 import junit.framework.TestCase;
12 import junit.framework.TestMethod;
13
14 public class InstrumentedTestCaseHelper extends BaseTestCaseHelper {
15
16 public InstrumentedTestCaseHelper() {
17 }
18
19 public void setTestCase(TestCase testCase) {
20 super.setTestCase(testCase);
21 }
22
23
24 public TestMethod[] createAllTestMethods() {
25 TestCase testCase = getTestCase();
26 if (TestCaseReflectionData.class.isAssignableFrom(testCase.getClass())) {
27 return ((TestCaseReflectionData)testCase).getDeclaredTestMethods();
28 } else {
29
30 return null;
31 }
32 }
33
34 public TestMethod createTestMethod(String name) {
35 TestCase testCase = getTestCase();
36 if (TestCaseReflectionData.class.isAssignableFrom(testCase.getClass())) {
37 TestMethod[] methods = ((TestCaseReflectionData)testCase).getDeclaredTestMethods();
38 for (int i = 0; i < methods.length; i++) {
39 if (methods[i].getName().equals(name)) {
40 return methods[i];
41 }
42 }
43 return null;
44 } else {
45 throw new Error("TestCase " + testCase + " is not instrumented");
46 }
47 }
48
49 public Test getSuite() {
50 TestCase testCase = getTestCase();
51 if (TestCaseReflectionData.class.isAssignableFrom(testCase.getClass())) {
52 return ((TestCaseReflectionData)testCase).getSuite();
53 } else {
54 throw new Error("TestCase " + testCase + " is not instrumented");
55 }
56 }
57
58
59 }