Search in sources :

Example 11 with Launch

use of com.epam.reportportal.service.Launch 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)

Example 12 with Launch

use of com.epam.reportportal.service.Launch 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 13 with Launch

use of com.epam.reportportal.service.Launch 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 14 with Launch

use of com.epam.reportportal.service.Launch in project agent-java-testNG by reportportal.

the class TestNGService method startTestSuite.

@Override
public void startTestSuite(ISuite suite) {
    StartTestItemRQ rq = buildStartSuiteRq(suite);
    Launch myLaunch = launch.get();
    final Maybe<String> item = myLaunch.startTestItem(rq);
    if (myLaunch.getParameters().isCallbackReportingEnabled()) {
        addToTree(suite, item);
    }
    suite.setAttribute(RP_ID, item);
}
Also used : Launch(com.epam.reportportal.service.Launch)

Example 15 with Launch

use of com.epam.reportportal.service.Launch in project agent-java-testNG by reportportal.

the class TestNGService method finishTestSuite.

@Override
public void finishTestSuite(ISuite suite) {
    Maybe<String> rpId = getAttribute(suite, RP_ID);
    Launch myLaunch = launch.get();
    if (null != rpId) {
        FinishTestItemRQ rq = buildFinishTestSuiteRq(suite);
        myLaunch.finishTestItem(rpId, rq);
        suite.removeAttribute(RP_ID);
    }
    if (myLaunch.getParameters().isCallbackReportingEnabled()) {
        removeFromTree(suite);
    }
}
Also used : Launch(com.epam.reportportal.service.Launch)

Aggregations

Launch (com.epam.reportportal.service.Launch)33 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)22 Test (org.junit.jupiter.api.Test)18 Maybe (io.reactivex.Maybe)9 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)8 SingleTest (com.epam.reportportal.junit5.features.coderef.SingleTest)5 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)5 Collectors (java.util.stream.Collectors)5 CommonUtils (com.epam.reportportal.util.test.CommonUtils)4 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)4 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)4 OneDisabledOneEnabledTest (com.epam.reportportal.junit5.features.disabled.OneDisabledOneEnabledTest)3 OneDisabledTest (com.epam.reportportal.junit5.features.disabled.OneDisabledTest)3 JunitDynamicNestedTest (com.epam.reportportal.junit5.features.nested.JunitDynamicNestedTest)3 AssumptionFailedTest (com.epam.reportportal.junit5.features.skipped.AssumptionFailedTest)3 BeforeEachAssumptionFailedTest (com.epam.reportportal.junit5.features.skipped.BeforeEachAssumptionFailedTest)3 ItemStatus (com.epam.reportportal.listeners.ItemStatus)3 ReportPortal (com.epam.reportportal.service.ReportPortal)3 ArgumentCaptor (org.mockito.ArgumentCaptor)3 Answer (org.mockito.stubbing.Answer)3