Search in sources :

Example 66 with StartTestItemRQ

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

the class AllureAwareListener method buildStartStepRq.

@Override
@Nonnull
protected StartTestItemRQ buildStartStepRq(@Nonnull final Object runner, @Nullable final Description description, @Nonnull final FrameworkMethod method, @Nonnull final ReflectiveCallable callable, @Nullable final Date startTime) {
    StartTestItemRQ rq = super.buildStartStepRq(runner, description, method, callable, startTime);
    ItemType itemType = ItemType.valueOf(rq.getType());
    if (itemType == ItemType.STEP) {
        ofNullable(method.getMethod()).ifPresent(m -> {
            processLabels(rq, m);
            processAllureId(rq, m);
            processDescription(rq, Thread.currentThread().getContextClassLoader(), m);
            processLinks(rq, m);
            processPriority(rq, m);
            processFlaky(rq, m);
            processMuted(rq, m);
        });
    } else {
        ofNullable(method.getMethod()).ifPresent(m -> {
            processLabels(rq, m);
            processDescription(rq, Thread.currentThread().getContextClassLoader(), m);
            processLinks(rq, m);
        });
    }
    ofNullable(rq.getDescription()).ifPresent(d -> DESCRIPTION_TRACKER.put(method, d));
    return rq;
}
Also used : ItemType(com.epam.reportportal.listeners.ItemType) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Nonnull(javax.annotation.Nonnull)

Example 67 with StartTestItemRQ

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

the class AllureAwareExtension method buildStartStepRq.

@Override
@Nonnull
protected StartTestItemRQ buildStartStepRq(@Nonnull final ExtensionContext context, @Nonnull final List<Object> arguments, @Nonnull final ItemType itemType, @Nonnull final String description, @Nonnull final Date startTime) {
    StartTestItemRQ rq = super.buildStartStepRq(context, arguments, itemType, description, startTime);
    if (itemType == ItemType.SUITE) {
        context.getTestClass().ifPresent(c -> {
            processLabels(rq, c);
            processLinks(rq, c);
        });
    } else {
        context.getTestMethod().ifPresent(m -> {
            processLabels(rq, m);
            processAllureId(rq, m);
            processDescription(rq, Thread.currentThread().getContextClassLoader(), m);
            processLinks(rq, m);
            processPriority(rq, m);
            processFlaky(rq, m);
            processMuted(rq, m);
        });
        DESCRIPTION_TRACKER.put(context, rq.getDescription());
    }
    return rq;
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Nonnull(javax.annotation.Nonnull)

Example 68 with StartTestItemRQ

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

the class AllureAwareExtension method buildStartConfigurationRq.

@Override
@Nonnull
protected StartTestItemRQ buildStartConfigurationRq(@Nonnull Method method, @Nonnull ExtensionContext parentContext, @Nonnull ExtensionContext context, @Nonnull ItemType itemType) {
    StartTestItemRQ rq = super.buildStartConfigurationRq(method, parentContext, context, itemType);
    processLabels(rq, method);
    processDescription(rq, Thread.currentThread().getContextClassLoader(), method);
    processLinks(rq, method);
    ofNullable(rq.getDescription()).ifPresent(d -> DESCRIPTION_TRACKER.put(context, d));
    return rq;
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Nonnull(javax.annotation.Nonnull)

Example 69 with StartTestItemRQ

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

the class StaticNestedStepsTest method test_static_anonymous_step.

@Test
public void test_static_anonymous_step() {
    mockNestedSteps(client, nestedStepLinks.get(0));
    TestNG result = runTests(StaticAnonymousStep.class);
    assertThat(result.getStatus(), equalTo(0));
    ArgumentCaptor<StartTestItemRQ> startNestedStepCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
    verify(client).startTestItem(same(stepUuid), startNestedStepCapture.capture());
    StartTestItemRQ startStep = startNestedStepCapture.getValue();
    assertThat(startStep.getName(), equalTo(StaticAnonymousStep.class.getSimpleName() + " anonymous step 1"));
    assertThat(startStep.isHasStats(), equalTo(Boolean.FALSE));
    ArgumentCaptor<FinishTestItemRQ> finishNestedStepCapture = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(client).finishTestItem(same(nestedSteps.get(0)), finishNestedStepCapture.capture());
    FinishTestItemRQ finishStep = finishNestedStepCapture.getValue();
    assertThat(finishStep.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)

Example 70 with StartTestItemRQ

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

the class StaticNestedStepsTest method test_two_static_anonymous_step.

@Test
public void test_two_static_anonymous_step() {
    mockNestedSteps(client, nestedStepLinks);
    TestNG result = runTests(TwoStaticAnonymousSteps.class);
    assertThat(result.getStatus(), equalTo(0));
    ArgumentCaptor<StartTestItemRQ> startNestedStepCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
    verify(client, times(2)).startTestItem(same(stepUuid), startNestedStepCapture.capture());
    startNestedStepCapture.getAllValues().forEach(i -> {
        assertThat(i.getName(), matchesPattern(TwoStaticAnonymousSteps.class.getSimpleName() + " anonymous step \\d"));
        assertThat(i.isHasStats(), equalTo(Boolean.FALSE));
    });
    ArgumentCaptor<FinishTestItemRQ> finishNestedStepCapture = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(client).finishTestItem(same(nestedSteps.get(0)), finishNestedStepCapture.capture());
    verify(client).finishTestItem(same(nestedSteps.get(1)), finishNestedStepCapture.capture());
    finishNestedStepCapture.getAllValues().forEach(i -> assertThat(i.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