Search in sources :

Example 1 with CallbackReportingTest

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());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) java.util(java.util) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) CallbackReportingTest(com.epam.reportportal.testng.integration.feature.callback.CallbackReportingTest) com.epam.ta.reportportal.ws.model(com.epam.ta.reportportal.ws.model) Maybe(io.reactivex.Maybe) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) ReportPortal(com.epam.reportportal.service.ReportPortal) SaveLogRQ(com.epam.ta.reportportal.ws.model.log.SaveLogRQ) Test(org.junit.jupiter.api.Test) TestUtils(com.epam.reportportal.testng.integration.util.TestUtils) Mockito(org.mockito.Mockito) CallbackReportingListener(com.epam.reportportal.testng.integration.CallbackReportingListener) ArgumentCaptor(org.mockito.ArgumentCaptor) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) TestUtils.standardParameters(com.epam.reportportal.testng.integration.util.TestUtils.standardParameters) ItemCreatedRS(com.epam.ta.reportportal.ws.model.item.ItemCreatedRS) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SaveLogRQ(com.epam.ta.reportportal.ws.model.log.SaveLogRQ) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) CallbackReportingListener(com.epam.reportportal.testng.integration.CallbackReportingListener) CallbackReportingTest(com.epam.reportportal.testng.integration.feature.callback.CallbackReportingTest) Test(org.junit.jupiter.api.Test)

Aggregations

ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)1 ReportPortal (com.epam.reportportal.service.ReportPortal)1 ReportPortalClient (com.epam.reportportal.service.ReportPortalClient)1 CallbackReportingListener (com.epam.reportportal.testng.integration.CallbackReportingListener)1 CallbackReportingTest (com.epam.reportportal.testng.integration.feature.callback.CallbackReportingTest)1 TestUtils (com.epam.reportportal.testng.integration.util.TestUtils)1 TestUtils.standardParameters (com.epam.reportportal.testng.integration.util.TestUtils.standardParameters)1 com.epam.ta.reportportal.ws.model (com.epam.ta.reportportal.ws.model)1 ItemCreatedRS (com.epam.ta.reportportal.ws.model.item.ItemCreatedRS)1 StartLaunchRS (com.epam.ta.reportportal.ws.model.launch.StartLaunchRS)1 SaveLogRQ (com.epam.ta.reportportal.ws.model.log.SaveLogRQ)1 Maybe (io.reactivex.Maybe)1 java.util (java.util)1 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 Mockito (org.mockito.Mockito)1