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
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class ExampleSubPackageTest extends TestCase {
26
27 public ExampleSubPackageTest() {
28 }
29
30
31
32 public void testFailure() {
33 fail("This test always fails.");
34 }
35
36
37
38
39
40
41
42 public void testError1() throws Exception {
43 throw new Exception("Test, throws a simple Exception.");
44 }
45
46
47
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
56
57 public void testThrowsError() throws Error {
58 throw new Error("Test, throws an Error.");
59 }
60
61
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
78
79
80
81
82
83 public static void main(String[] args) {
84 runTextUI();
85
86
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
100
101
102
103 public static TestSuite suite() {
104 return new TestSuite(ExampleSubPackageTest.class);
105 }
106
107 }
108