use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.
the class ReportPortalExtension method finishTemplate.
/**
* Finish a test template execution (basically a test class) with a specific status, builds a finish request based on the status
*
* @param context JUnit's test context
*/
protected void finishTemplate(@Nonnull final ExtensionContext context) {
Launch launch = getLaunch(context);
Maybe<String> templateId = testTemplates.remove(context);
launch.finishTestItem(templateId, buildFinishTestItemRq(context, null));
idMapping.remove(context);
}
use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.
the class JunitNestedTestTest method verify_dynamically_generated_nested_tests.
@Test
@SuppressWarnings("unchecked")
public void verify_dynamically_generated_nested_tests() {
TestUtils.runClasses(JunitDynamicNestedTest.class);
Launch launch = TestExtension.LAUNCH;
ArgumentCaptor<StartTestItemRQ> suiteCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start parent Suite
verify(launch, times(1)).startTestItem(suiteCaptor.capture());
ArgumentCaptor<Maybe<String>> parentIdCaptor = ArgumentCaptor.forClass(Maybe.class);
ArgumentCaptor<StartTestItemRQ> itemRqCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start inner items
verify(launch, times(9)).startTestItem(parentIdCaptor.capture(), itemRqCaptor.capture());
verify(launch, times(10)).finishTestItem(any(Maybe.class), any(FinishTestItemRQ.class));
List<Maybe<String>> parentIds = parentIdCaptor.getAllValues();
List<StartTestItemRQ> itemRqs = itemRqCaptor.getAllValues();
int index = 0;
String parentId = parentIds.get(index).blockingGet();
StartTestItemRQ itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-JunitDynamicNestedTest-"));
assertThat(itemRq.getName(), equalTo("dynamicTestsWithContainers()"));
parentId = parentIds.get(++index).blockingGet();
itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-dynamicTestsWithContainers()-"));
assertThat(itemRq.getName(), equalTo("A"));
parentId = parentIds.get(++index).blockingGet();
itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-A-"));
assertThat(itemRq.getName(), equalTo("A inner container"));
parentId = parentIds.get(++index).blockingGet();
itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-A inner container-"));
assertThat(itemRq.getName(), equalTo("A Test 1"));
parentId = parentIds.get(++index).blockingGet();
itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-A inner container-"));
assertThat(itemRq.getName(), equalTo("A Test 2"));
parentId = parentIds.get(++index).blockingGet();
itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-dynamicTestsWithContainers()-"));
assertThat(itemRq.getName(), equalTo("B"));
parentId = parentIds.get(++index).blockingGet();
itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-B"));
assertThat(itemRq.getName(), equalTo("B inner container"));
parentId = parentIds.get(++index).blockingGet();
itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-B inner container-"));
assertThat(itemRq.getName(), equalTo("B Test 1"));
parentId = parentIds.get(++index).blockingGet();
itemRq = itemRqs.get(index);
assertThat(parentId, Matchers.startsWith("suite-B inner container-"));
assertThat(itemRq.getName(), equalTo("B Test 2"));
}
use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.
the class DisabledTestTest method verify_a_disabled_test_reason_reported.
@Test
public void verify_a_disabled_test_reason_reported() {
TestUtils.runClasses(OneDisabledTestWithReason.class);
Launch launch = DisabledTestExtension.LAUNCH;
// Start parent Suite
verify(launch, times(1)).startTestItem(any());
ArgumentCaptor<StartTestItemRQ> captorStart = ArgumentCaptor.forClass(StartTestItemRQ.class);
// Start a test
verify(launch, times(1)).startTestItem(notNull(), captorStart.capture());
List<StartTestItemRQ> steps = captorStart.getAllValues();
assertThat("StartTestItem request has proper Description field", captorStart.getAllValues().get(0).getDescription(), equalTo(OneDisabledTestWithReason.REASON));
}
use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.
the class AssumptionsTest method verify_before_each_assumption_failure_marks_test_as_skipped.
@Test
public void verify_before_each_assumption_failure_marks_test_as_skipped() {
TestUtils.runClasses(BeforeEachAssumptionFailedTest.class);
Launch launch = AssumptionsTestExtension.LAUNCH;
// Start parent Suite
verify(launch).startTestItem(any(StartTestItemRQ.class));
// Start a test
verify(launch, times(2)).startTestItem(notNull(), any(StartTestItemRQ.class));
ArgumentCaptor<FinishTestItemRQ> finishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(launch, times(3)).finishTestItem(any(), finishCaptor.capture());
List<FinishTestItemRQ> finishItems = finishCaptor.getAllValues();
assertThat(finishItems.get(0).getStatus(), equalTo(ItemStatus.SKIPPED.name()));
assertThat(finishItems.get(1).getStatus(), equalTo(ItemStatus.SKIPPED.name()));
assertThat(finishItems.get(2).getStatus(), nullValue());
}
use of com.epam.reportportal.service.Launch in project agent-java-junit5 by reportportal.
the class AssumptionsTest method setupMock.
@BeforeEach
public void setupMock() {
AssumptionsTestExtension.LAUNCH = mock(Launch.class);
Launch launch = AssumptionsTestExtension.LAUNCH;
when(launch.getStepReporter()).thenReturn(StepReporter.NOOP_STEP_REPORTER);
when(launch.startTestItem(any())).thenAnswer((Answer<Maybe<String>>) invocation -> CommonUtils.createMaybeUuid());
when(launch.startTestItem(any(), any())).thenAnswer((Answer<Maybe<String>>) invocation -> CommonUtils.createMaybeUuid());
}
Aggregations