Skip to content

Commit 1f1d462

Browse files
committed
feat(#1218): add
1 parent bf7c846 commit 1f1d462

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

core/citrus-base/src/test/java/org/citrusframework/DefaultTestCaseTest.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static org.citrusframework.TestResult.RESULT.FAILURE;
3535
import static org.citrusframework.TestResult.success;
3636
import static org.citrusframework.util.TestUtils.WAIT_THREAD_PREFIX;
37+
import static org.mockito.Mockito.doThrow;
3738
import static org.mockito.Mockito.inOrder;
3839
import static org.mockito.Mockito.mock;
3940
import static org.mockito.Mockito.times;
@@ -176,15 +177,18 @@ public void doExecuteAsync(final TestContext context) {
176177
}
177178

178179
@Test
179-
public void testTestListenerEventsWithSuccessTestResult() {
180+
public void testTestListenerEventsWithSuccessfulTestResult() {
180181
TestListener testListenerMock = mock();
181182
context.getTestListeners().addTestListener(testListenerMock);
183+
182184
BeforeTest beforeTestMock = mock();
183185
List<BeforeTest> beforeTestListMock = new ArrayList<>(){{add(beforeTestMock);}};
184186
context.setBeforeTest(beforeTestListMock);
187+
185188
TestAction testActionMock = mock();
186189
List<TestAction> testActionListMock = new ArrayList<>(){{add(testActionMock);}};
187190
fixture.setFinalActions(testActionListMock);
191+
188192
AfterTest afterTestMock = mock();
189193
List<AfterTest> afterTestListMock = new ArrayList<>(){{add(afterTestMock);}};
190194
context.setAfterTest(afterTestListMock);
@@ -206,28 +210,26 @@ public void testTestListenerEventsWithSuccessTestResult() {
206210
verifyNoMoreInteractions(testListenerMock);
207211
}
208212

209-
@Test()
213+
@Test(expectedExceptions = TestCaseFailedException.class)
210214
public void testTestListenerEventsWithFailedTestResult() {
211215
TestAction testActionMock = mock();
212-
// doThrow(CitrusRuntimeException.class).when(testActionMock).execute(context);
216+
doThrow(CitrusRuntimeException.class).when(testActionMock).execute(context);
213217
fixture.addTestAction(testActionMock);
214218
TestListener testListenerMock = mock();
215219
context.getTestListeners().addTestListener(testListenerMock);
220+
216221
BeforeTest beforeTestMock = mock();
217222
List<BeforeTest> beforeTestListMock = new ArrayList<>(){{add(beforeTestMock);}};
218223
context.setBeforeTest(beforeTestListMock);
224+
219225
List<TestAction> testActionListMock = new ArrayList<>(){{add(testActionMock);}};
220226
fixture.setFinalActions(testActionListMock);
227+
221228
AfterTest afterTestMock = mock();
222229
List<AfterTest> afterTestListMock = new ArrayList<>(){{add(afterTestMock);}};
223230
context.setAfterTest(afterTestListMock);
224-
// TestResult testResultMock = mock();
225-
// fixture.setTestResult(testResultMock);
226-
// when(testResultMock.isSuccess()).thenReturn(false);
227231

228232
fixture.doExecute(context);
229-
CitrusRuntimeException citrusRuntimeExceptionMock = mock();
230-
context.addException(citrusRuntimeExceptionMock);
231233
fixture.finish(context);
232234

233235
InOrder inOrder = inOrder(testListenerMock);
@@ -237,7 +239,7 @@ public void testTestListenerEventsWithFailedTestResult() {
237239
inOrder.verify(testListenerMock, times(1)).onTestFinish(fixture);
238240
inOrder.verify(testListenerMock, times(1)).onFinalActionsStart(fixture);
239241
inOrder.verify(testListenerMock, times(1)).onFinalActionsEnd(fixture);
240-
inOrder.verify(testListenerMock, times(1)).onTestFailure(fixture, citrusRuntimeExceptionMock);
242+
inOrder.verify(testListenerMock, times(1)).onTestFailure(fixture, fixture.getTestResult().getCause());
241243
inOrder.verify(testListenerMock, times(1)).onBeforeSequenceAfterTest(fixture);
242244
inOrder.verify(testListenerMock, times(1)).onAfterSequenceAfterTest(fixture);
243245
inOrder.verify(testListenerMock, times(1)).onTestEnd(fixture);

0 commit comments

Comments
 (0)