use of com.epam.reportportal.service.ReportPortalClient 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());
}
use of com.epam.reportportal.service.ReportPortalClient in project agent-java-junit5 by reportportal.
the class StepReporterTest method verify_failed_nested_step_not_fails_test_run.
@Test
public void verify_failed_nested_step_not_fails_test_run() {
TestExtension.init();
Listener listener = new Listener();
runClasses(listener, ManualStepReporterFeatureTest.class);
ReportPortalClient client = TestExtension.client.get();
ArgumentCaptor<FinishTestItemRQ> finishNestedStep = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(client, timeout(1000)).finishTestItem(eq(TestExtension.stepUuidList.get(2)), finishNestedStep.capture());
ArgumentCaptor<FinishTestItemRQ> finishTestStep = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(client, timeout(1000)).finishTestItem(eq(TestExtension.testMethodUuid), finishTestStep.capture());
assertThat(finishNestedStep.getValue().getStatus(), equalTo(ItemStatus.FAILED.name()));
assertThat(finishTestStep.getValue().getStatus(), equalTo(ItemStatus.FAILED.name()));
assertThat(listener.results.remove().getStatus(), sameInstance(TestExecutionResult.Status.SUCCESSFUL));
}
use of com.epam.reportportal.service.ReportPortalClient in project agent-java-junit5 by reportportal.
the class StepReporterTest method verify_listener_finishes_unfinished_step.
@Test
public void verify_listener_finishes_unfinished_step() {
TestExtension.init();
runClasses(ManualStepReporterSimpleTest.class);
ReportPortalClient client = TestExtension.client.get();
verify(client, timeout(1000)).finishTestItem(eq(TestExtension.stepUuidList.get(0)), any());
}
use of com.epam.reportportal.service.ReportPortalClient in project allure-java by reportportal.
the class TestUtils method mockLaunch.
@SuppressWarnings("unchecked")
public static <T extends Collection<String>> void mockLaunch(ReportPortalClient client, String launchUuid, String suiteUuid, Collection<Pair<String, T>> testSteps) {
when(client.startLaunch(any())).thenReturn(createMaybe(new StartLaunchRS(launchUuid, 1L)));
Maybe<ItemCreatedRS> suiteMaybe = createMaybe(new ItemCreatedRS(suiteUuid, suiteUuid));
when(client.startTestItem(any())).thenReturn(suiteMaybe);
List<Maybe<ItemCreatedRS>> testResponses = testSteps.stream().map(Pair::getKey).map(uuid -> createMaybe(new ItemCreatedRS(uuid, uuid))).collect(Collectors.toList());
Maybe<ItemCreatedRS> first = testResponses.get(0);
Maybe<ItemCreatedRS>[] other = testResponses.subList(1, testResponses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(suiteUuid), any())).thenReturn(first, other);
testSteps.forEach(test -> {
String testClassUuid = test.getKey();
List<Maybe<ItemCreatedRS>> stepResponses = test.getValue().stream().map(uuid -> createMaybe(new ItemCreatedRS(uuid, uuid))).collect(Collectors.toList());
Maybe<ItemCreatedRS> myFirst = stepResponses.get(0);
Maybe<ItemCreatedRS>[] myOther = stepResponses.subList(1, stepResponses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(testClassUuid), any())).thenReturn(myFirst, myOther);
new HashSet<>(test.getValue()).forEach(testMethodUuid -> when(client.finishTestItem(same(testMethodUuid), any())).thenReturn(createMaybe(new OperationCompletionRS())));
when(client.finishTestItem(same(testClassUuid), any())).thenReturn(createMaybe(new OperationCompletionRS()));
});
Maybe<OperationCompletionRS> suiteFinishMaybe = createMaybe(new OperationCompletionRS());
when(client.finishTestItem(eq(suiteUuid), any())).thenReturn(suiteFinishMaybe);
when(client.finishLaunch(eq(launchUuid), any())).thenReturn(createMaybe(new OperationCompletionRS()));
}
use of com.epam.reportportal.service.ReportPortalClient in project allure-java by reportportal.
the class TestUtils method mockNestedSteps.
@SuppressWarnings("unchecked")
public static void mockNestedSteps(final ReportPortalClient client, final List<Pair<String, String>> parentNestedPairs) {
Map<String, List<String>> responseOrders = parentNestedPairs.stream().collect(Collectors.groupingBy(Pair::getKey, Collectors.mapping(Pair::getValue, Collectors.toList())));
responseOrders.forEach((k, v) -> {
List<Maybe<ItemCreatedRS>> responses = v.stream().map(uuid -> TestUtils.createMaybe(new ItemCreatedRS(uuid, uuid))).collect(Collectors.toList());
Maybe<ItemCreatedRS> first = responses.get(0);
Maybe<ItemCreatedRS>[] other = responses.subList(1, responses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(k), any())).thenReturn(first, other);
});
parentNestedPairs.forEach(p -> when(client.finishTestItem(same(p.getValue()), any())).thenAnswer((Answer<Maybe<OperationCompletionRS>>) invocation -> TestUtils.createMaybe(new OperationCompletionRS())));
}
Aggregations