KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > susebox > TestUtilities


1 /*
2  * TestUtilities.java: utility methods for JUnit tests
3  *
4  * Copyright (C) 2002 Heiko Blau
5  *
6  * This file belongs to the Susebox Java core test suite.
7  * The Susebox Java core test suite is free software; you can redistribute it
8  * and/or modify it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of the License,
10  * or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License along
18  * with the Susebox Java core test suite. If not, write to the
19  *
20  * Free Software Foundation, Inc.
21  * 59 Temple Place, Suite 330,
22  * Boston, MA 02111-1307
23  * USA
24  *
25  * or check the Internet: http://www.fsf.org
26  *
27  * The Susebox Java core test suite uses the test framework JUnit by Kent Beck
28  * and Erich Gamma. You should have received a copy of their JUnit licence
29  * agreement along with the Susebox Java test suite.
30  *
31  * We do NOT provide the JUnit archive junit.jar nessecary to compile and run
32  * our tests, since we assume, that You either have it already or would like
33  * to get the current release Yourself.
34  * Please visit either:
35  * http://sourceforge.net/projects/junit
36  * or
37  * http://junit.org
38  * to obtain JUnit.
39  *
40  * Contact:
41  * email: heiko@susebox.de
42  */

43
44 package de.susebox;
45
46 //-----------------------------------------------------------------------------
47
// Imports
48
//
49

50 //-----------------------------------------------------------------------------
51
// Class TestUtilities
52
//
53

54 /**<p>
55  * This class is a generic test for implementations of the {@link ThrowableList}
56  * interface. Instead of testing each implementation by its own, the common
57  * pattern of all these exceptions is used to define tests on all of them.
58  *</p>
59  *
60  * @see ThrowableList
61  * @author Heiko Blau
62  */

63 public class TestUtilities {
64   
65   /**
66    * The method looks for an explicitely given TestRunner type in the first
67    * element of the given argument array. Valid values are:
68    *<ul><li>
69    * swingui: use the class {@link junit.swingui.TestRunner}
70    *</li><li>
71    * awtui: use the class {@link junit.awtui.TestRunner}
72    *</li><li>
73    * textui: use the class {@link junit.textui.TestRunner}
74    *</li></ul>
75    * If no type is given the method will use an {@link junit.textui.TestRunner}
76    * instance.
77    *
78    * @param tests an array containing the test classes to run
79    * @param args the command line arguments
80    */

81   public static void run(String JavaDoc[] tests, String JavaDoc[] args) {
82     if (args != null && args.length > 0) {
83       if (args[0].equals("swingui")) {
84         new junit.swingui.TestRunner().main(tests);
85       } else if (args[0].equals("awtui")) {
86         new junit.awtui.TestRunner().main(tests);
87       } else {
88         new junit.textui.TestRunner().main(tests);
89       }
90     } else {
91       new junit.textui.TestRunner().main(tests);
92     }
93   }
94 }
95
Popular Tags