Search in sources :

Example 6 with Launch

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);
}
Also used : Launch(com.epam.reportportal.service.Launch)

Example 7 with Launch

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"));
}
Also used : Maybe(io.reactivex.Maybe) Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) JunitDynamicNestedTest(com.epam.reportportal.junit5.features.nested.JunitDynamicNestedTest) Test(org.junit.jupiter.api.Test)

Example 8 with Launch

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));
}
Also used : Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) OneDisabledOneEnabledTest(com.epam.reportportal.junit5.features.disabled.OneDisabledOneEnabledTest) OneDisabledTest(com.epam.reportportal.junit5.features.disabled.OneDisabledTest)

Example 9 with Launch

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());
}
Also used : Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) BeforeEachAssumptionFailedTest(com.epam.reportportal.junit5.features.skipped.BeforeEachAssumptionFailedTest) SingleTest(com.epam.reportportal.junit5.features.coderef.SingleTest) Test(org.junit.jupiter.api.Test) AssumptionFailedTest(com.epam.reportportal.junit5.features.skipped.AssumptionFailedTest)

Example 10 with Launch

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());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TestUtils(com.epam.reportportal.junit5.util.TestUtils) BeforeEach(org.junit.jupiter.api.BeforeEach) Launch(com.epam.reportportal.service.Launch) Maybe(io.reactivex.Maybe) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) BeforeEachAssumptionFailedTest(com.epam.reportportal.junit5.features.skipped.BeforeEachAssumptionFailedTest) Answer(org.mockito.stubbing.Answer) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) TestInstance(org.junit.jupiter.api.TestInstance) ArgumentCaptor(org.mockito.ArgumentCaptor) Matchers.nullValue(org.hamcrest.Matchers.nullValue) SingleTest(com.epam.reportportal.junit5.features.coderef.SingleTest) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) StepReporter(com.epam.reportportal.service.step.StepReporter) CommonUtils(com.epam.reportportal.util.test.CommonUtils) ItemStatus(com.epam.reportportal.listeners.ItemStatus) Mockito.times(org.mockito.Mockito.times) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) ArgumentMatchers.notNull(org.mockito.ArgumentMatchers.notNull) AssumptionFailedTest(com.epam.reportportal.junit5.features.skipped.AssumptionFailedTest) Maybe(io.reactivex.Maybe) Launch(com.epam.reportportal.service.Launch) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Launch (com.epam.reportportal.service.Launch)33 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)22 Test (org.junit.jupiter.api.Test)18 Maybe (io.reactivex.Maybe)9 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)8 SingleTest (com.epam.reportportal.junit5.features.coderef.SingleTest)5 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)5 Collectors (java.util.stream.Collectors)5 CommonUtils (com.epam.reportportal.util.test.CommonUtils)4 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)4 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)4 OneDisabledOneEnabledTest (com.epam.reportportal.junit5.features.disabled.OneDisabledOneEnabledTest)3 OneDisabledTest (com.epam.reportportal.junit5.features.disabled.OneDisabledTest)3 JunitDynamicNestedTest (com.epam.reportportal.junit5.features.nested.JunitDynamicNestedTest)3 AssumptionFailedTest (com.epam.reportportal.junit5.features.skipped.AssumptionFailedTest)3 BeforeEachAssumptionFailedTest (com.epam.reportportal.junit5.features.skipped.BeforeEachAssumptionFailedTest)3 ItemStatus (com.epam.reportportal.listeners.ItemStatus)3 ReportPortal (com.epam.reportportal.service.ReportPortal)3 ArgumentCaptor (org.mockito.ArgumentCaptor)3 Answer (org.mockito.stubbing.Answer)3