34
34
import static org .citrusframework .TestResult .RESULT .FAILURE ;
35
35
import static org .citrusframework .TestResult .success ;
36
36
import static org .citrusframework .util .TestUtils .WAIT_THREAD_PREFIX ;
37
+ import static org .mockito .Mockito .doThrow ;
37
38
import static org .mockito .Mockito .inOrder ;
38
39
import static org .mockito .Mockito .mock ;
39
40
import static org .mockito .Mockito .times ;
@@ -176,15 +177,18 @@ public void doExecuteAsync(final TestContext context) {
176
177
}
177
178
178
179
@ Test
179
- public void testTestListenerEventsWithSuccessTestResult () {
180
+ public void testTestListenerEventsWithSuccessfulTestResult () {
180
181
TestListener testListenerMock = mock ();
181
182
context .getTestListeners ().addTestListener (testListenerMock );
183
+
182
184
BeforeTest beforeTestMock = mock ();
183
185
List <BeforeTest > beforeTestListMock = new ArrayList <>(){{add (beforeTestMock );}};
184
186
context .setBeforeTest (beforeTestListMock );
187
+
185
188
TestAction testActionMock = mock ();
186
189
List <TestAction > testActionListMock = new ArrayList <>(){{add (testActionMock );}};
187
190
fixture .setFinalActions (testActionListMock );
191
+
188
192
AfterTest afterTestMock = mock ();
189
193
List <AfterTest > afterTestListMock = new ArrayList <>(){{add (afterTestMock );}};
190
194
context .setAfterTest (afterTestListMock );
@@ -206,28 +210,26 @@ public void testTestListenerEventsWithSuccessTestResult() {
206
210
verifyNoMoreInteractions (testListenerMock );
207
211
}
208
212
209
- @ Test ()
213
+ @ Test (expectedExceptions = TestCaseFailedException . class )
210
214
public void testTestListenerEventsWithFailedTestResult () {
211
215
TestAction testActionMock = mock ();
212
- // doThrow(CitrusRuntimeException.class).when(testActionMock).execute(context);
216
+ doThrow (CitrusRuntimeException .class ).when (testActionMock ).execute (context );
213
217
fixture .addTestAction (testActionMock );
214
218
TestListener testListenerMock = mock ();
215
219
context .getTestListeners ().addTestListener (testListenerMock );
220
+
216
221
BeforeTest beforeTestMock = mock ();
217
222
List <BeforeTest > beforeTestListMock = new ArrayList <>(){{add (beforeTestMock );}};
218
223
context .setBeforeTest (beforeTestListMock );
224
+
219
225
List <TestAction > testActionListMock = new ArrayList <>(){{add (testActionMock );}};
220
226
fixture .setFinalActions (testActionListMock );
227
+
221
228
AfterTest afterTestMock = mock ();
222
229
List <AfterTest > afterTestListMock = new ArrayList <>(){{add (afterTestMock );}};
223
230
context .setAfterTest (afterTestListMock );
224
- // TestResult testResultMock = mock();
225
- // fixture.setTestResult(testResultMock);
226
- // when(testResultMock.isSuccess()).thenReturn(false);
227
231
228
232
fixture .doExecute (context );
229
- CitrusRuntimeException citrusRuntimeExceptionMock = mock ();
230
- context .addException (citrusRuntimeExceptionMock );
231
233
fixture .finish (context );
232
234
233
235
InOrder inOrder = inOrder (testListenerMock );
@@ -237,7 +239,7 @@ public void testTestListenerEventsWithFailedTestResult() {
237
239
inOrder .verify (testListenerMock , times (1 )).onTestFinish (fixture );
238
240
inOrder .verify (testListenerMock , times (1 )).onFinalActionsStart (fixture );
239
241
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 () );
241
243
inOrder .verify (testListenerMock , times (1 )).onBeforeSequenceAfterTest (fixture );
242
244
inOrder .verify (testListenerMock , times (1 )).onAfterSequenceAfterTest (fixture );
243
245
inOrder .verify (testListenerMock , times (1 )).onTestEnd (fixture );
0 commit comments