Search in sources :

Example 41 with StartTestItemRQ

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

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

the class NestedStepTest method nestedTest.

@Test
public void nestedTest() {
    TestUtils.runClasses(NestedStepFeaturePassedTest.class);
    ArgumentCaptor<StartTestItemRQ> nestedStepCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    ArgumentCaptor<FinishTestItemRQ> finishNestedCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(CLIENT.get(), timeout(1000).times(1)).startTestItem(same(TEST_METHOD_ID), nestedStepCaptor.capture());
    verify(CLIENT.get(), timeout(1000).times(1)).finishTestItem(same(STEP_ID_LIST.get(0)), finishNestedCaptor.capture());
    StartTestItemRQ startTestItemRQ = nestedStepCaptor.getValue();
    assertNotNull(startTestItemRQ);
    assertFalse(startTestItemRQ.isHasStats());
    assertEquals("I am nested step with parameter - '" + PARAM + "'", startTestItemRQ.getName());
    FinishTestItemRQ finishNestedRQ = finishNestedCaptor.getValue();
    assertNotNull(finishNestedRQ);
    assertEquals("PASSED", finishNestedRQ.getStatus());
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) NestedStepFeatureFailedTest(com.epam.reportportal.junit5.features.nested.NestedStepFeatureFailedTest) NestedStepFeaturePassedTest(com.epam.reportportal.junit5.features.nested.NestedStepFeaturePassedTest) Test(org.junit.jupiter.api.Test) NestedStepMultiLevelTest(com.epam.reportportal.junit5.features.nested.NestedStepMultiLevelTest) NestedStepWithBeforeEachTest(com.epam.reportportal.junit5.features.nested.NestedStepWithBeforeEachTest)

Example 43 with StartTestItemRQ

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

the class NestedStepTest method failedNestedTest.

@Test
public void failedNestedTest() {
    try {
        TestUtils.runClasses(NestedStepFeatureFailedTest.class);
    } catch (Exception ex) {
    // to prevent this test failing
    }
    ArgumentCaptor<StartTestItemRQ> nestedStepCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    ArgumentCaptor<FinishTestItemRQ> finishNestedCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(CLIENT.get(), timeout(1000).times(1)).startTestItem(same(TEST_METHOD_ID), nestedStepCaptor.capture());
    verify(CLIENT.get(), timeout(1000).times(1)).finishTestItem(same(STEP_ID_LIST.get(0)), finishNestedCaptor.capture());
    StartTestItemRQ startTestItemRQ = nestedStepCaptor.getValue();
    assertNotNull(startTestItemRQ);
    assertFalse(startTestItemRQ.isHasStats());
    assertEquals("I am nested step with parameter - '" + PARAM + "'", startTestItemRQ.getName());
    FinishTestItemRQ finishNestedRQ = finishNestedCaptor.getValue();
    assertNotNull(finishNestedRQ);
    assertEquals("FAILED", finishNestedRQ.getStatus());
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) NestedStepFeatureFailedTest(com.epam.reportportal.junit5.features.nested.NestedStepFeatureFailedTest) NestedStepFeaturePassedTest(com.epam.reportportal.junit5.features.nested.NestedStepFeaturePassedTest) Test(org.junit.jupiter.api.Test) NestedStepMultiLevelTest(com.epam.reportportal.junit5.features.nested.NestedStepMultiLevelTest) NestedStepWithBeforeEachTest(com.epam.reportportal.junit5.features.nested.NestedStepWithBeforeEachTest)

Example 44 with StartTestItemRQ

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

the class NestedStepTest method nestedInBeforeMethodTest.

@Test
public void nestedInBeforeMethodTest() {
    TestUtils.runClasses(NestedStepWithBeforeEachTest.class);
    ArgumentCaptor<StartTestItemRQ> nestedStepCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    ArgumentCaptor<FinishTestItemRQ> finishNestedCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(CLIENT.get(), timeout(TimeUnit.SECONDS.toMillis(2)).times(1)).startTestItem(same(TEST_METHOD_ID), nestedStepCaptor.capture());
    verify(CLIENT.get(), timeout(TimeUnit.SECONDS.toMillis(2)).times(1)).finishTestItem(same(STEP_ID_LIST.get(0)), finishNestedCaptor.capture());
    StartTestItemRQ startTestItemRQ = nestedStepCaptor.getValue();
    assertNotNull(startTestItemRQ);
    assertFalse(startTestItemRQ.isHasStats());
    assertEquals("I am nested step with parameter - '" + PARAM + "'", startTestItemRQ.getName());
    FinishTestItemRQ finishNestedRQ = finishNestedCaptor.getValue();
    assertNotNull(finishNestedRQ);
    assertEquals("PASSED", finishNestedRQ.getStatus());
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) NestedStepFeatureFailedTest(com.epam.reportportal.junit5.features.nested.NestedStepFeatureFailedTest) NestedStepFeaturePassedTest(com.epam.reportportal.junit5.features.nested.NestedStepFeaturePassedTest) Test(org.junit.jupiter.api.Test) NestedStepMultiLevelTest(com.epam.reportportal.junit5.features.nested.NestedStepMultiLevelTest) NestedStepWithBeforeEachTest(com.epam.reportportal.junit5.features.nested.NestedStepWithBeforeEachTest)

Example 45 with StartTestItemRQ

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

the class AttributesTest method verify_method_level_attributes.

@Test
public void verify_method_level_attributes() {
    TestUtils.runClasses(MethodLevelAttributesTest.class);
    Launch launch = AttributesTestExtension.LAUNCH;
    ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test
    verify(launch).startTestItem(captor.capture());
    // Start step
    verify(launch).startTestItem(any(), captor.capture());
    StartTestItemRQ testRequest = extractRequest(captor, "suite");
    assertThat(testRequest.getAttributes(), anyOf(nullValue(), emptyIterable()));
    StartTestItemRQ stepRequest = extractRequest(captor, "step");
    assertThat(stepRequest.getAttributes(), hasSize(1));
    ItemAttributesRQ attribute = stepRequest.getAttributes().iterator().next();
    assertThat(attribute.getKey(), equalTo("myKey"));
    assertThat(attribute.getValue(), equalTo("myValue"));
}
Also used : ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) MethodLevelAttributesTest(com.epam.reportportal.junit5.features.attributes.MethodLevelAttributesTest) Test(org.junit.jupiter.api.Test) ClassLevelAttributesTest(com.epam.reportportal.junit5.features.attributes.ClassLevelAttributesTest)

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