Search in sources :

Example 36 with StartTestItemRQ

use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.

the class XunitImportHandler method startRootItem.

private void startRootItem(String name, String timestamp) {
    if (null != timestamp) {
        startItemTime = parseTimeStamp(timestamp);
        if (startSuiteTime.isAfter(startItemTime)) {
            startSuiteTime = LocalDateTime.of(startItemTime.toLocalDate(), startItemTime.toLocalTime());
        }
    } else {
        startItemTime = LocalDateTime.now();
    }
    StartTestItemRQ rq = buildStartTestRq(name);
    String id = startTestItemHandler.startRootItem(user, projectDetails, rq).getId();
    itemUuids.push(id);
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ)

Example 37 with StartTestItemRQ

use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.

the class XunitImportHandler method startTestItem.

private void startTestItem(String name) {
    StartTestItemRQ rq = buildStartTestRq(name);
    String id = startTestItemHandler.startChildItem(user, projectDetails, rq, itemUuids.peek()).getId();
    itemUuids.push(id);
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ)

Example 38 with StartTestItemRQ

use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project agent-java-junit5 by reportportal.

the class FailedBeforeEachReportsSkippedTestTest method agent_should_not_report_skipped_test_in_case_of_failed_after_each.

@Test
public void agent_should_not_report_skipped_test_in_case_of_failed_after_each() {
    TestUtils.runClasses(AfterEachFailedTest.class);
    Pair<List<Pair<String, StartTestItemRQ>>, Map<String, FinishTestItemRQ>> calls = verify_call_number_and_capture_arguments(4, LAUNCH);
    verifyNoMoreInteractions(LAUNCH);
    assertThat("There are 4 item created: suite, @BeforeEach, @Test and @AfterEach", ITEMS, hasSize(4));
    FinishTestItemRQ beforeEachFinish = calls.getValue().get(ITEMS.get(1));
    assertThat("@BeforeEach passed", beforeEachFinish.getStatus(), equalTo("PASSED"));
    FinishTestItemRQ testFinish = calls.getValue().get(ITEMS.get(2));
    assertThat("@Test passed", testFinish.getStatus(), equalTo("PASSED"));
    FinishTestItemRQ afterEachFinish = calls.getValue().get(ITEMS.get(3));
    assertThat("@AfterEach failed", afterEachFinish.getStatus(), equalTo("FAILED"));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Map(java.util.Map) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) BeforeEachFailedTest(com.epam.reportportal.junit5.features.skipped.BeforeEachFailedTest) AfterEachFailedTest(com.epam.reportportal.junit5.features.skipped.AfterEachFailedTest) BeforeEachFailedParametrizedTest(com.epam.reportportal.junit5.features.skipped.BeforeEachFailedParametrizedTest) Test(org.junit.jupiter.api.Test)

Example 39 with StartTestItemRQ

use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project agent-java-junit5 by reportportal.

the class FailedBeforeEachReportsSkippedTestTest method agent_should_report_skipped_parametrized_tests_in_case_of_failed_before_each.

@Test
public void agent_should_report_skipped_parametrized_tests_in_case_of_failed_before_each() {
    TestUtils.runClasses(BeforeEachFailedParametrizedTest.class);
    Pair<List<Pair<String, StartTestItemRQ>>, Map<String, FinishTestItemRQ>> calls = verify_call_number_and_capture_arguments(6, 1, LAUNCH);
    verifyNoMoreInteractions(LAUNCH);
    assertThat("There are 6 item created: parent suite, suite, 2 @BeforeEach, @Test 1 and @Test 2", ITEMS, hasSize(6));
    FinishTestItemRQ beforeEachFinish = calls.getValue().get(ITEMS.get(2));
    assertThat("@BeforeEach failed", beforeEachFinish.getStatus(), equalTo("FAILED"));
    Date currentDate = new Date();
    IntStream.rangeClosed(0, 1).boxed().forEach(i -> {
        StartTestItemRQ testStart = calls.getKey().get(3 + (i * 2)).getValue();
        assertThat("@Test has correct code reference", testStart.getCodeRef(), equalTo(BeforeEachFailedParametrizedTest.class.getCanonicalName() + ".testBeforeEachFailed"));
        assertThat("@Test has correct name", testStart.getName(), equalTo("[" + (i + 1) + "] " + BeforeEachFailedParametrizedTest.TestParams.values()[i]));
        FinishTestItemRQ testFinish = calls.getValue().get(ITEMS.get(3 + (i * 2)));
        assertThat("@Test reported as skipped", testFinish.getStatus(), equalTo(ItemStatus.SKIPPED.name()));
        assertThat("@Test issue muted", testFinish.getIssue(), sameInstance(Launch.NOT_ISSUE));
        assertThat(testFinish.getEndTime(), lessThanOrEqualTo(currentDate));
    });
}
Also used : BeforeEachFailedParametrizedTest(com.epam.reportportal.junit5.features.skipped.BeforeEachFailedParametrizedTest) ArrayList(java.util.ArrayList) List(java.util.List) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Map(java.util.Map) Date(java.util.Date) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) BeforeEachFailedTest(com.epam.reportportal.junit5.features.skipped.BeforeEachFailedTest) AfterEachFailedTest(com.epam.reportportal.junit5.features.skipped.AfterEachFailedTest) BeforeEachFailedParametrizedTest(com.epam.reportportal.junit5.features.skipped.BeforeEachFailedParametrizedTest) Test(org.junit.jupiter.api.Test)

Example 40 with StartTestItemRQ

use of com.epam.ta.reportportal.ws.model.StartTestItemRQ 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)

Aggregations

StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)159 Test (org.junit.jupiter.api.Test)124 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)30 List (java.util.List)21 TestNG (org.testng.TestNG)21 Launch (com.epam.reportportal.service.Launch)20 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)19 BeforeEach (org.junit.jupiter.api.BeforeEach)19 TestNgListener (com.epam.reportportal.testng.util.TestNgListener)18 Collectors (java.util.stream.Collectors)17 ArgumentCaptor (org.mockito.ArgumentCaptor)17 ReportPortal (com.epam.reportportal.service.ReportPortal)16 ReportPortalClient (com.epam.reportportal.service.ReportPortalClient)15 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)15 ArgumentMatchers.same (org.mockito.ArgumentMatchers.same)14 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)13 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)13 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)12 Set (java.util.Set)12 Nonnull (javax.annotation.Nonnull)12