1   package junitour.subpackage;
2   
3   import junit.framework.*;
4   import junit.textui.ResultPrinter;
5   
6   import junitour.UnitTestIncompleteError;
7   import junitour.MyResultPrinter;
8   import junitour.TourTestResult;
9   
10  /**
11   * This is a set of TestCases (methods have the prefix: test)
12   *
13   * created: by Hostlowsky, at 03.12.2003
14   * <pre>
15   *
16   * $Log$
17   * Revision 1.1  2003/12/04 23:45:16  hostlows
18   * new tests
19   *
20   *
21   * </pre>
22   * @author $Author: hostlows $, created by  <a href="mailto:hostlows@users.sf.net">Robert Hostlowsky</a>
23   * @version $Revision: 20 $, $Date: 2003-12-05 00:45:16 +0100 (Fr, 05 Dez 2003) $
24   */
25  public class ExampleSubPackageTest extends TestCase {
26  
27  	public ExampleSubPackageTest() {
28  	}
29  
30  	/** failing test method
31     */
32    public void testFailure() {
33  		fail("This test always fails.");
34    }
35  
36  
37    /** throws an Error, so failing
38     *
39     * @throws Exception
40     */
41  
42  	public void testError1() throws Exception {
43  	  throw new Exception("Test, throws a simple Exception.");
44  	}
45  
46  
47    /** results in a simple assertion failure
48     *
49     */
50    public void testSimpleFailingComparison() {
51  		assertEquals(	"bjey b=16, c=15, d=15, e=5",
52                    "b=16, c=15, d=15, e=5" );
53  	}
54  
55    /** throws a simple Error to let this test fail.
56     */
57    public void testThrowsError() throws Error {
58      throw new Error("Test, throws an Error.");
59    }
60  
61  	/** does nothing here. */
62    public void testNoFailureOk () {
63  	}
64  
65    public void testThrowsThrowable() throws Throwable {
66      throw new Throwable("Test, throws a Throwable object.");
67    }
68  
69    public void testThrowsRuntimeException () throws RuntimeException {
70      throw new RuntimeException("Test, throws a RuntimeException.");
71    }
72  
73  	public void testThrowsUnitTestIncompleteError()  {
74  		throw new UnitTestIncompleteError("This method throws the UnitTestIncompleteError.");
75  	}
76  
77  	/** main method to show the 'demo'
78     *
79     * starts the test Text-UI runner for this class's test suite.
80     *
81     * @param args
82     */
83    public static void main(String[] args) {
84  		runTextUI();
85    //		new junit.swingui.TestRunner().run(ExampleTest.class);
86    //		new junitour.swingui.TestRunner().run(ExampleTest.class);
87  	}
88  
89  	private static void runTextUI() {
90  		ResultPrinter resPrinter = new MyResultPrinter(System.out);
91  		final junit.textui.TestRunner testRunner = new junit.textui.TestRunner(resPrinter) {
92  					protected TestResult createTestResult() {
93  						return new TourTestResult();
94  					}
95  				};
96  		testRunner.doRun(suite());
97  	}
98  
99  	/** creates the testsuite object for this class's test methods.
100    *
101    * @return testsuite for this class
102    */
103   public static TestSuite suite() {
104 		return new TestSuite(ExampleSubPackageTest.class);
105 	}
106 
107 }
108