Search in sources :

Example 46 with StartTestItemRQ

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

the class TestCaseIdTest method testCaseIdFromCodeRefAndParamsTest.

@Test
void testCaseIdFromCodeRefAndParamsTest() {
    TestUtils.runClasses(TestCaseIdFromCodeRefAndParamsTest.class);
    String expectedCodeRef = "com.epam.reportportal.junit5.features.testcaseid.TestCaseIdFromCodeRefAndParamsTest.parametrized";
    List<String> expected = IntStream.of(101, 0).mapToObj(it -> expectedCodeRef + "[" + it + "]").collect(Collectors.toList());
    Launch launch = TestCaseIdExtension.LAUNCH;
    // Start parent Suite
    verify(launch, times(1)).startTestItem(any());
    ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start a test
    verify(launch, times(3)).startTestItem(notNull(), captor.capture());
    List<StartTestItemRQ> requests = captor.getAllValues();
    assertThat(requests.stream().map(e -> e.getType().toLowerCase()).collect(Collectors.toList()), hasItem("suite"));
    List<String> actual = requests.stream().filter(it -> "step".equalsIgnoreCase(it.getType())).map(StartTestItemRQ::getTestCaseId).collect(Collectors.toList());
    assertThat(actual, equalTo(expected));
}
Also used : IntStream(java.util.stream.IntStream) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TestUtils(com.epam.reportportal.junit5.util.TestUtils) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Launch(com.epam.reportportal.service.Launch) Maybe(io.reactivex.Maybe) com.epam.reportportal.junit5.features.testcaseid(com.epam.reportportal.junit5.features.testcaseid) CommonUtils(com.epam.reportportal.util.test.CommonUtils) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Answer(org.mockito.stubbing.Answer) Mockito(org.mockito.Mockito) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) List(java.util.List) TestInstance(org.junit.jupiter.api.TestInstance) ArgumentCaptor(org.mockito.ArgumentCaptor) Matchers.hasItem(org.hamcrest.Matchers.hasItem) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ArgumentMatchers.notNull(org.mockito.ArgumentMatchers.notNull) Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 47 with StartTestItemRQ

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

the class TestCaseIdTest method test_verify_test_case_id_supports_templating_with_self_reference.

@Test
void test_verify_test_case_id_supports_templating_with_self_reference() {
    TestUtils.runClasses(TestCaseIdTemplateTest.class);
    Launch launch = TestCaseIdExtension.LAUNCH;
    // Start parent Suite
    verify(launch, times(1)).startTestItem(any());
    ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start a test
    verify(launch, times(1)).startTestItem(notNull(), captor.capture());
    StartTestItemRQ request = captor.getValue();
    assertThat(request.getTestCaseId(), equalTo(TestCaseIdTemplateTest.TEST_CASE_ID_VALUE.replace("{this.FIELD}", TestCaseIdTemplateTest.FIELD)));
}
Also used : Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 48 with StartTestItemRQ

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

the class LinkAnnotationTest method test_description_should_not_override_attached_links.

@Test
public void test_description_should_not_override_attached_links() {
    mockLaunch(client, namedUuid("launchUuid"), suitedUuid, testClassUuid, stepUuids.get(0));
    TestNG result = runTests(TestLinkAndDescription.class);
    assertThat(result.getStatus(), equalTo(0));
    ArgumentCaptor<StartTestItemRQ> startMethodCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test step
    verify(client).startTestItem(same(testClassUuid), startMethodCapture.capture());
    StartTestItemRQ startRequest = startMethodCapture.getValue();
    assertThat(startRequest.getDescription(), equalTo(TestLinkAndDescription.DESCRIPTION + FormatUtils.MARKDOWN_DELIMITER + FormatUtils.LINK_PREFIX + String.format(FormatUtils.LINK_MARKDOWN, TestLinkAndDescription.LINK_NAME, TestLinkAndDescription.LINK_URL)));
}
Also used : TestNG(org.testng.TestNG) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 49 with StartTestItemRQ

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

the class LinkAnnotationTest method test_description_should_not_override_attached_links_in_configuration_method.

@Test
public void test_description_should_not_override_attached_links_in_configuration_method() {
    mockLaunch(client, namedUuid("launchUuid"), suitedUuid, testClassUuid, stepUuids);
    TestNG result = runTests(TestLinkAndDescriptionBefore.class);
    assertThat(result.getStatus(), equalTo(0));
    ArgumentCaptor<StartTestItemRQ> startMethodCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test step
    verify(client, times(2)).startTestItem(same(testClassUuid), startMethodCapture.capture());
    List<StartTestItemRQ> startBeforeRequests = startMethodCapture.getAllValues().stream().filter(s -> ItemType.BEFORE_METHOD.name().equals(s.getType())).collect(Collectors.toList());
    assertThat(startBeforeRequests, hasSize(1));
    StartTestItemRQ startRequest = startBeforeRequests.get(0);
    assertThat(startRequest.getDescription(), equalTo(TestLinkAndDescriptionBefore.DESCRIPTION + FormatUtils.MARKDOWN_DELIMITER + FormatUtils.LINK_PREFIX + String.format(FormatUtils.LINK_MARKDOWN, TestLinkAndDescriptionBefore.LINK_NAME, TestLinkAndDescriptionBefore.LINK_URL)));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) TestLinkAndDescription(com.epam.reportportal.testng.features.links.TestLinkAndDescription) TestMyFirstFeature(com.epam.reportportal.testng.features.attributes.TestMyFirstFeature) ReportPortal(com.epam.reportportal.service.ReportPortal) ItemType(com.epam.reportportal.listeners.ItemType) TestNgListener(com.epam.reportportal.testng.util.TestNgListener) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) ArgumentCaptor(org.mockito.ArgumentCaptor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestNG(org.testng.TestNG) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestUtils(com.epam.reportportal.testng.util.TestUtils) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) Matchers(org.hamcrest.Matchers) Collectors(java.util.stream.Collectors) Matchers.startsWith(org.hamcrest.Matchers.startsWith) TestLinkAndDescriptionBefore(com.epam.reportportal.testng.features.links.TestLinkAndDescriptionBefore) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) Stream(java.util.stream.Stream) FormatUtils(com.epam.reportportal.allure.FormatUtils) Collections(java.util.Collections) ArgumentMatchers.same(org.mockito.ArgumentMatchers.same) TestNG(org.testng.TestNG) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 50 with StartTestItemRQ

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

the class MethodNestedStepsTest method test_two_levels_method_step.

@Test
public void test_two_levels_method_step() {
    mockNestedSteps(client, nestedStepLinks.get(0));
    mockNestedSteps(client, Pair.of(nestedSteps.get(0), nestedSteps.get(1)));
    TestNG result = runTests(MethodTwoLevelsStep.class);
    assertThat(result.getStatus(), equalTo(0));
    ArgumentCaptor<StartTestItemRQ> startNestedStepCapture1 = ArgumentCaptor.forClass(StartTestItemRQ.class);
    verify(client).startTestItem(same(stepUuid), startNestedStepCapture1.capture());
    ArgumentCaptor<StartTestItemRQ> startNestedStepCapture2 = ArgumentCaptor.forClass(StartTestItemRQ.class);
    verify(client).startTestItem(same(nestedSteps.get(0)), startNestedStepCapture2.capture());
    StartTestItemRQ startStep1 = startNestedStepCapture1.getValue();
    assertThat(startStep1.getName(), not(emptyOrNullString()));
    assertThat(startStep1.isHasStats(), equalTo(Boolean.FALSE));
    StartTestItemRQ startStep2 = startNestedStepCapture2.getValue();
    assertThat(startStep2.getName(), not(emptyOrNullString()));
    assertThat(startStep2.isHasStats(), equalTo(Boolean.FALSE));
    ArgumentCaptor<FinishTestItemRQ> finishNestedStepCapture1 = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(client).finishTestItem(same(nestedSteps.get(0)), finishNestedStepCapture1.capture());
    FinishTestItemRQ finishStep1 = finishNestedStepCapture1.getValue();
    assertThat(finishStep1.getStatus(), equalTo(ItemStatus.PASSED.name()));
    ArgumentCaptor<FinishTestItemRQ> finishNestedStepCapture2 = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(client).finishTestItem(same(nestedSteps.get(1)), finishNestedStepCapture2.capture());
    FinishTestItemRQ finishStep2 = finishNestedStepCapture2.getValue();
    assertThat(finishStep2.getStatus(), equalTo(ItemStatus.PASSED.name()));
}
Also used : TestNG(org.testng.TestNG) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) 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