01: package com.reeltwo.jumble.fast;
02:
03: import junit.framework.Test;
04: import junit.framework.TestCase;
05: import junit.framework.TestSuite;
06: import experiments.JumblerExperimentSecondTest;
07: import experiments.JumblerExperimentTest;
08:
09: /**
10: * Tests the corresponding class
11: *
12: * @author Tin Pavlinic
13: * @version $Revision: 500 $
14: */
15: public class FlatTestSuiteTest extends TestCase {
16: private FlatTestSuite mTest;
17:
18: public final void setUp() {
19: mTest = new FlatTestSuite();
20: }
21:
22: public void tearDown() {
23: mTest = null;
24: }
25:
26: public final void testCountTestCases() {
27: checkTestCases(3, new Class[] { JumblerExperimentTest.class,
28: JumblerExperimentSecondTest.class });
29: }
30:
31: public void testNoSuite() {
32: checkTestCases(2, new Class[] { NoSuiteT.class });
33: }
34:
35: public void testMismatchingSuite() {
36: checkTestCases(2, new Class[] { MismatchingSuiteT.class });
37: }
38:
39: private void checkTestCases(int cases, Class[] testClasses) {
40: for (int i = 0; i < testClasses.length; i++) {
41: mTest.addTestSuite(testClasses[i]);
42: }
43:
44: assertEquals(cases, mTest.countTestCases());
45: }
46:
47: public static Test suite() {
48: TestSuite suite = new TestSuite(FlatTestSuiteTest.class);
49: return suite;
50: }
51:
52: public static void main(String[] args) {
53: if (args.length == 0) {
54: junit.textui.TestRunner.run(suite());
55: } else {
56: String testName = args[0];
57: FlatTestSuite suite = new com.reeltwo.jumble.fast.FlatTestSuite();
58: suite.addTest(suite());
59:
60: for (int i = 0; i < suite.testCount(); i++) {
61: TestCase curTest = (TestCase) suite.testAt(i);
62: if (curTest.getName().equals(testName)) {
63: junit.textui.TestRunner.run(curTest);
64: }
65: }
66: }
67: }
68: }
|