use of com.epam.reportportal.testng.integration.feature.callback.CallbackReportingTest in project agent-java-testNG by reportportal.
the class CallbackReportingIntegrationTest method callbackReportingTest.
@Test
public void callbackReportingTest() {
ReportPortalClient client = CallbackReportingListener.getReportPortal().getClient();
try {
TestUtils.runTests(Collections.singletonList(CallbackReportingListener.class), CallbackReportingTest.class);
} catch (Exception ex) {
// do nothing
ex.printStackTrace();
}
// Start parent suite
verify(client, times(1)).startTestItem(any());
ArgumentCaptor<FinishTestItemRQ> captor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
// Start test class and test method
verify(client, times(6)).finishTestItem(eq(testMethodUuid), captor.capture());
ArgumentCaptor<SaveLogRQ> saveLogRQArgumentCaptor = ArgumentCaptor.forClass(SaveLogRQ.class);
verify(client, times(1)).log(saveLogRQArgumentCaptor.capture());
Map<String, List<FinishTestItemRQ>> finishMapping = captor.getAllValues().stream().filter(it -> Objects.nonNull(it.getDescription())).collect(groupingBy(FinishExecutionRQ::getDescription));
FinishTestItemRQ firstTestCallbackFinish = finishMapping.get("firstTest").get(0);
FinishTestItemRQ secondTestCallbackFinish = finishMapping.get("secondTest").get(0);
assertEquals("PASSED", firstTestCallbackFinish.getStatus());
assertEquals("FAILED", secondTestCallbackFinish.getStatus());
SaveLogRQ logRequest = saveLogRQArgumentCaptor.getValue();
assertEquals("Error message", logRequest.getMessage());
assertEquals("ERROR", logRequest.getLevel());
}
Aggregations