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.DefaultMonitor; 14 15 19 public class DefaultBehaviourTest 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 DefaultMonitor()); 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 testSuccess14() { 42 m_engine.runTest(new TestSuite(SuccessAssert14TestCase.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", 0, m_listener.test_error); 50 assertEquals("test_success", 1, m_listener.test_success); 51 } 52 53 public void testError() { 54 m_engine.runTest(new TestSuite(ErrorTestCase.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", 0, m_listener.test_failure); 61 assertEquals("test_error", 1, m_listener.test_error); 62 assertEquals("test_success", 0, m_listener.test_success); 63 } 64 65 public void testFailure() { 66 m_engine.runTest(new TestSuite(FailureTestCase.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", 1, m_listener.test_started); 72 assertEquals("test_failure", 1, m_listener.test_failure); 73 assertEquals("test_error", 0, m_listener.test_error); 74 assertEquals("test_success", 0, m_listener.test_success); 75 } 76 77 public void testFailureAssert14() { 78 m_engine.runTest(new TestSuite(FailureAssert14TestCase.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", 2, m_listener.test_started); 84 assertEquals("test_failure", 2, 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 testIgnored() { 90 m_engine.runTest(new TestSuite(IgnoredTestCase.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", 4, m_listener.test_ignored); 95 assertEquals("test_started", 1, m_listener.test_started); 96 assertEquals("test_failure", 0, m_listener.test_failure); 97 assertEquals("test_error", 0, m_listener.test_error); 98 assertEquals("test_success", 0, m_listener.test_success); 99 } 100 101 public void testWarning() { 102 m_engine.runTest(new TestSuite(WarningTestCase.class)); 103 assertEquals("run_started", 1, m_listener.run_started); 104 assertEquals("run_stopped", 0, m_listener.run_stopped); 105 assertEquals("run_ended", 1, m_listener.run_ended); 106 assertEquals("test_ignored", 0, m_listener.test_ignored); 107 assertEquals("test_started", 1, m_listener.test_started); 108 assertEquals("test_failure", 1, m_listener.test_failure); 109 assertEquals("test_error", 0, m_listener.test_error); 110 assertEquals("test_success", 0, m_listener.test_success); 111 } 112 113 public void testSuccessTestSetup() { 114 m_engine.runTest(new TestSuite(SuccessTestSetup.class)); 115 assertEquals("run_started", 1, m_listener.run_started); 116 assertEquals("run_stopped", 0, m_listener.run_stopped); 117 assertEquals("run_ended", 1, m_listener.run_ended); 118 assertEquals("test_ignored", 0, m_listener.test_ignored); 119 assertEquals("test_started", 3, m_listener.test_started); 120 assertEquals("test_failure", 1, m_listener.test_failure); 121 assertEquals("test_error", 1, m_listener.test_error); 122 assertEquals("test_success", 1, m_listener.test_success); 123 } 124 125 public void testFailureTestSetup() { 126 m_engine.runTest(new TestSuite(FailSetupTestSetup.class)); 127 assertEquals("run_started", 1, m_listener.run_started); 128 assertEquals("run_stopped", 0, m_listener.run_stopped); 129 assertEquals("run_ended", 1, m_listener.run_ended); 130 assertEquals("test_ignored", 0, m_listener.test_ignored); 131 assertEquals("test_started", 3, m_listener.test_started); 132 assertEquals("test_failure", 1, m_listener.test_failure); 133 assertEquals("test_error", 1, m_listener.test_error); 134 assertEquals("test_success", 1, m_listener.test_success); 135 } 136 137 public void testErrorTestSetup() { 138 m_engine.runTest(new TestSuite(ErrorSetupTestSetup.class)); 139 assertEquals("run_started", 1, m_listener.run_started); 140 assertEquals("run_stopped", 0, m_listener.run_stopped); 141 assertEquals("run_ended", 1, m_listener.run_ended); 142 assertEquals("test_ignored", 0, m_listener.test_ignored); 143 assertEquals("test_started", 3, m_listener.test_started); 144 assertEquals("test_failure", 1, m_listener.test_failure); 145 assertEquals("test_error", 1, m_listener.test_error); 146 assertEquals("test_success", 1, m_listener.test_success); 147 } 148 149 public void testTestSetupFailure() { 150 m_engine.runTest(new TestSuite(SetupFailTestCase.class)); 151 assertEquals("run_started", 1, m_listener.run_started); 152 assertEquals("run_stopped", 0, m_listener.run_stopped); 153 assertEquals("run_ended", 1, m_listener.run_ended); 154 assertEquals("test_ignored", 0, m_listener.test_ignored); 155 assertEquals("test_started", 3, m_listener.test_started); 156 assertEquals("test_failure", 3, m_listener.test_failure); 157 assertEquals("test_error", 0, m_listener.test_error); 158 assertEquals("test_success", 0, m_listener.test_success); 159 } 160 161 public void testTestSetupError() { 162 m_engine.runTest(new TestSuite(SetupErrorTestCase.class)); 163 assertEquals("run_started", 1, m_listener.run_started); 164 assertEquals("run_stopped", 0, m_listener.run_stopped); 165 assertEquals("run_ended", 1, m_listener.run_ended); 166 assertEquals("test_ignored", 0, m_listener.test_ignored); 167 assertEquals("test_started", 3, m_listener.test_started); 168 assertEquals("test_failure", 0, m_listener.test_failure); 169 assertEquals("test_error", 3, m_listener.test_error); 170 assertEquals("test_success", 0, m_listener.test_success); 171 } 172 173 } 174 | Popular Tags |