Search in sources :

Example 6 with StartTestItemRQ

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

the class BuildStepTest method testType.

@Test
public void testType() {
    when(testResult.getMethod()).thenReturn(testNGMethod);
    when(testNGMethod.getConstructorOrMethod()).thenReturn(constructorOrMethod);
    when(testNGMethod.isTest()).thenReturn(true);
    StartTestItemRQ rq = testNGService.buildStartStepRq(testResult);
    assertThat("Incorrect test item type", rq.getType(), is("STEP"));
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 7 with StartTestItemRQ

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

the class NestedStepTest method nestedTest.

@Test
public void nestedTest() {
    mockNestedSteps(client, testStepIdOrder.get(0));
    TestUtils.runTests(singletonList(TestNgListener.class), NestedStepFeaturePassedTest.class);
    ArgumentCaptor<StartTestItemRQ> nestedStepCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    ArgumentCaptor<FinishTestItemRQ> finishNestedCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(client, timeout(1000).times(1)).startTestItem(same(testMethodId), nestedStepCaptor.capture());
    verify(client, timeout(1000).times(1)).finishTestItem(same(stepIdList.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 : TestNgListener(com.epam.reportportal.testng.integration.TestNgListener) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) NestedStepMultiLevelTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepMultiLevelTest) NestedStepWithBeforeEachTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepWithBeforeEachTest) NestedStepFeaturePassedTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepFeaturePassedTest) Test(org.junit.jupiter.api.Test) NestedStepFeatureFailedTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepFeatureFailedTest)

Example 8 with StartTestItemRQ

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

the class NestedStepTest method failedNestedTest.

@Test
public void failedNestedTest() {
    mockNestedSteps(client, testStepIdOrder.get(0));
    try {
        TestUtils.runTests(singletonList(TestNgListener.class), 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, timeout(1000).times(1)).startTestItem(same(testMethodId), nestedStepCaptor.capture());
    verify(client, timeout(1000).times(1)).finishTestItem(same(stepIdList.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 : TestNgListener(com.epam.reportportal.testng.integration.TestNgListener) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) NestedStepMultiLevelTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepMultiLevelTest) NestedStepWithBeforeEachTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepWithBeforeEachTest) NestedStepFeaturePassedTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepFeaturePassedTest) Test(org.junit.jupiter.api.Test) NestedStepFeatureFailedTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepFeatureFailedTest)

Example 9 with StartTestItemRQ

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

the class NestedStepTest method nestedInBeforeMethodTest.

@Test
public void nestedInBeforeMethodTest() {
    mockNestedSteps(client, testStepIdOrder.get(0));
    TestUtils.runTests(singletonList(TestNgListener.class), NestedStepWithBeforeEachTest.class);
    ArgumentCaptor<StartTestItemRQ> nestedStepCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    ArgumentCaptor<FinishTestItemRQ> finishNestedCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(client, timeout(1000).times(1)).startTestItem(same(testMethodId), nestedStepCaptor.capture());
    verify(client, timeout(1000).times(1)).finishTestItem(same(stepIdList.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 : TestNgListener(com.epam.reportportal.testng.integration.TestNgListener) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) NestedStepMultiLevelTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepMultiLevelTest) NestedStepWithBeforeEachTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepWithBeforeEachTest) NestedStepFeaturePassedTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepFeaturePassedTest) Test(org.junit.jupiter.api.Test) NestedStepFeatureFailedTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepFeatureFailedTest)

Example 10 with StartTestItemRQ

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

the class NestedStepTest method testWithMultiLevelNested.

@Test
public void testWithMultiLevelNested() throws NoSuchMethodException {
    mockNestedSteps(client, testStepIdOrder);
    TestUtils.runTests(singletonList(TestNgListener.class), NestedStepMultiLevelTest.class);
    ArgumentCaptor<StartTestItemRQ> nestedStepCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    ArgumentCaptor<FinishTestItemRQ> finishNestedCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(client, timeout(1000).times(1)).startTestItem(same(testMethodId), nestedStepCaptor.capture());
    verify(client, timeout(1000).times(1)).finishTestItem(same(stepIdList.get(0)), finishNestedCaptor.capture());
    verify(client, timeout(1000).times(1)).startTestItem(same(stepIdList.get(0)), nestedStepCaptor.capture());
    verify(client, timeout(1000).times(1)).finishTestItem(same(stepIdList.get(1)), finishNestedCaptor.capture());
    List<StartTestItemRQ> nestedSteps = nestedStepCaptor.getAllValues();
    nestedSteps.forEach(step -> {
        assertNotNull(step);
        assertFalse(step.isHasStats());
    });
    StartTestItemRQ stepWithInnerStep = nestedSteps.get(0);
    assertEquals(METHOD_WITH_INNER_METHOD_NAME_TEMPLATE, stepWithInnerStep.getName());
    StartTestItemRQ innerStep = nestedSteps.get(1);
    assertEquals("I am - " + NestedStepMultiLevelTest.class.getDeclaredMethod("innerMethod").getName(), innerStep.getName());
}
Also used : NestedStepMultiLevelTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepMultiLevelTest) TestNgListener(com.epam.reportportal.testng.integration.TestNgListener) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) NestedStepMultiLevelTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepMultiLevelTest) NestedStepWithBeforeEachTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepWithBeforeEachTest) NestedStepFeaturePassedTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepFeaturePassedTest) Test(org.junit.jupiter.api.Test) NestedStepFeatureFailedTest(com.epam.reportportal.testng.integration.feature.nested.NestedStepFeatureFailedTest)

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