KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > junitx > runner > engine > JUnitBehaviourTest


1 package junitx.runner.engine;
2
3 import junit.framework.TestCase;
4 import junit.framework.TestSuite;
5 import junitx.example.ErrorTestCase;
6 import junitx.example.FailureTestCase;
7 import junitx.example.IgnoredTestCase;
8 import junitx.example.SuccessTestCase;
9 import junitx.example.SetupErrorTestCase;
10 import junitx.example.SetupFailTestCase;
11 import junitx.example.*;
12 import junitx.example.WarningTestCase;
13 import junitx.runner.monitor.JUnitMonitor;
14
15 /**
16  * @version $Revision: 1.4 $, $Date: 2003/05/08 02:51:16 $
17  * @author <a HREF="mailto:vbossica@users.sourceforge.net">Vladimir Ritz Bossicard</a>
18  */

19 public class JUnitBehaviourTest extends TestCase {
20
21     private MockListener m_listener = new MockListener();
22     private RunEngine m_engine;
23
24     protected void setUp() {
25         m_engine = new RunEngine(new JUnitMonitor());
26         m_engine.addRunListener(m_listener);
27     }
28
29     public void testSuccess() {
30         m_engine.runTest(new TestSuite(SuccessTestCase.class));
31         assertEquals("run_started", 1, m_listener.run_started);
32         assertEquals("run_stopped", 0, m_listener.run_stopped);
33         assertEquals("run_ended", 1, m_listener.run_ended);
34         assertEquals("test_ignored", 0, m_listener.test_ignored);
35         assertEquals("test_started", 1, m_listener.test_started);
36         assertEquals("test_failure", 0, m_listener.test_failure);
37         assertEquals("test_error", 0, m_listener.test_error);
38         assertEquals("test_success", 1, m_listener.test_success);
39     }
40
41     public void testError() {
42         m_engine.runTest(new TestSuite(ErrorTestCase.class));
43         assertEquals("run_started", 1, m_listener.run_started);
44         assertEquals("run_stopped", 0, m_listener.run_stopped);
45         assertEquals("run_ended", 1, m_listener.run_ended);
46         assertEquals("test_ignored", 0, m_listener.test_ignored);
47         assertEquals("test_started", 1, m_listener.test_started);
48         assertEquals("test_failure", 0, m_listener.test_failure);
49         assertEquals("test_error", 1, m_listener.test_error);
50         assertEquals("test_success", 0, m_listener.test_success);
51     }
52
53     public void testFailure() {
54         m_engine.runTest(new TestSuite(FailureTestCase.class));
55         assertEquals("run_started", 1, m_listener.run_started);
56         assertEquals("run_stopped", 0, m_listener.run_stopped);
57         assertEquals("run_ended", 1, m_listener.run_ended);
58         assertEquals("test_ignored", 0, m_listener.test_ignored);
59         assertEquals("test_started", 1, m_listener.test_started);
60         assertEquals("test_failure", 1, m_listener.test_failure);
61         assertEquals("test_error", 0, m_listener.test_error);
62         assertEquals("test_success", 0, m_listener.test_success);
63     }
64
65     public void testIgnored() {
66         m_engine.runTest(new TestSuite(IgnoredTestCase.class));
67         assertEquals("run_started", 1, m_listener.run_started);
68         assertEquals("run_stopped", 0, m_listener.run_stopped);
69         assertEquals("run_ended", 1, m_listener.run_ended);
70         assertEquals("test_ignored", 0, m_listener.test_ignored);
71         assertEquals("test_started", 4, m_listener.test_started);
72         assertEquals("test_failure", 1, m_listener.test_failure);
73         assertEquals("test_error", 2, m_listener.test_error);
74         assertEquals("test_success", 1, m_listener.test_success);
75     }
76
77     public void testWarning() {
78         m_engine.runTest(new TestSuite(WarningTestCase.class));
79         assertEquals("run_started", 1, m_listener.run_started);
80         assertEquals("run_stopped", 0, m_listener.run_stopped);
81         assertEquals("run_ended", 1, m_listener.run_ended);
82         assertEquals("test_ignored", 0, m_listener.test_ignored);
83         assertEquals("test_started", 1, m_listener.test_started);
84         assertEquals("test_failure", 1, m_listener.test_failure);
85         assertEquals("test_error", 0, m_listener.test_error);
86         assertEquals("test_success", 0, m_listener.test_success);
87     }
88
89     public void testSuccessTestSetup() {
90         m_engine.runTest(new TestSuite(SuccessTestSetup.class));
91         assertEquals("run_started", 1, m_listener.run_started);
92         assertEquals("run_stopped", 0, m_listener.run_stopped);
93         assertEquals("run_ended", 1, m_listener.run_ended);
94         assertEquals("test_ignored", 0, m_listener.test_ignored);
95         assertEquals("test_started", 3, m_listener.test_started);
96         assertEquals("test_failure", 1, m_listener.test_failure);
97         assertEquals("test_error", 1, m_listener.test_error);
98         assertEquals("test_success", 1, m_listener.test_success);
99     }
100
101
102     public void testTestSetupFailure() {
103         m_engine.runTest(new TestSuite(SetupFailTestCase.class));
104         assertEquals("run_started", 1, m_listener.run_started);
105         assertEquals("run_stopped", 0, m_listener.run_stopped);
106         assertEquals("run_ended", 1, m_listener.run_ended);
107         assertEquals("test_ignored", 0, m_listener.test_ignored);
108         assertEquals("test_started", 3, m_listener.test_started);
109         assertEquals("test_failure", 3, m_listener.test_failure);
110         assertEquals("test_error", 0, m_listener.test_error);
111         assertEquals("test_success", 0, m_listener.test_success);
112     }
113
114     public void testTestSetupError() {
115         m_engine.runTest(new TestSuite(SetupErrorTestCase.class));
116         assertEquals("run_started", 1, m_listener.run_started);
117         assertEquals("run_stopped", 0, m_listener.run_stopped);
118         assertEquals("run_ended", 1, m_listener.run_ended);
119         assertEquals("test_ignored", 0, m_listener.test_ignored);
120         assertEquals("test_started", 3, m_listener.test_started);
121         assertEquals("test_failure", 0, m_listener.test_failure);
122         assertEquals("test_error", 3, m_listener.test_error);
123         assertEquals("test_success", 0, m_listener.test_success);
124     }
125     
126     public void testFailureTestSetup() {
127         m_engine.runTest(new TestSuite(FailSetupTestSetup.class));
128         assertEquals("run_started", 1, m_listener.run_started);
129         assertEquals("run_stopped", 0, m_listener.run_stopped);
130         assertEquals("run_ended", 1, m_listener.run_ended);
131         assertEquals("test_ignored", 0, m_listener.test_ignored);
132         assertEquals("test_started", 3, m_listener.test_started);
133         assertEquals("test_failure", 1, m_listener.test_failure);
134         assertEquals("test_error", 1, m_listener.test_error);
135         assertEquals("test_success", 1, m_listener.test_success);
136     }
137     
138     public void testErrorTestSetup() {
139         m_engine.runTest(new TestSuite(ErrorSetupTestSetup.class));
140         assertEquals("run_started", 1, m_listener.run_started);
141         assertEquals("run_stopped", 0, m_listener.run_stopped);
142         assertEquals("run_ended", 1, m_listener.run_ended);
143         assertEquals("test_ignored", 0, m_listener.test_ignored);
144         assertEquals("test_started", 3, m_listener.test_started);
145         assertEquals("test_failure", 1, m_listener.test_failure);
146         assertEquals("test_error", 1, m_listener.test_error);
147         assertEquals("test_success", 1, m_listener.test_success);
148     }
149 }
Popular Tags