Search in sources :

Example 16 with Launch

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

the class TestNGService method startConfiguration.

@Override
public void startConfiguration(ITestResult testResult) {
    TestMethodType type = TestMethodType.getStepType(testResult.getMethod());
    testResult.setAttribute(RP_METHOD_TYPE, type);
    StartTestItemRQ rq = buildStartConfigurationRq(testResult, type);
    if (Boolean.TRUE == rq.isRetry()) {
        testResult.setAttribute(RP_RETRY, Boolean.TRUE);
    }
    Maybe<String> parentId = getConfigParent(testResult, type);
    Launch myLaunch = launch.get();
    Maybe<String> itemID = myLaunch.startTestItem(parentId, rq);
    testResult.setAttribute(RP_ID, itemID);
}
Also used : Launch(com.epam.reportportal.service.Launch)

Example 17 with Launch

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

the class TestCaseIdTest method testCaseIdFromCodeRefAndParams.

@Test
public void testCaseIdFromCodeRefAndParams() {
    TestUtils.runTests(Collections.singletonList(TestReportPortalListener.class), TestCaseIdFromCodeRefAndParams.class);
    String expectedCodeRef = TestCaseIdFromCodeRefAndParams.class.getCanonicalName() + "." + TestCaseIdFromCodeReference.STEP_NAME;
    List<String> expectedTestCaseIds = Stream.of("one", "two", "three").map(it -> expectedCodeRef + "[" + it + "]").collect(Collectors.toList());
    // Start parent suites
    verify(launch, times(1)).startTestItem(any());
    ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test and steps
    verify(launch, times(4)).startTestItem(any(), captor.capture());
    StartTestItemRQ testRequest = extractRequest(captor, "test");
    List<String> actualTestCaseIds = extractRequests(captor, "step").stream().map(StartTestItemRQ::getTestCaseId).collect(Collectors.toList());
    assertThat(testRequest.getName(), equalTo(TestUtils.TEST_NAME));
    assertThat(actualTestCaseIds, equalTo(expectedTestCaseIds));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Launch(com.epam.reportportal.service.Launch) Mock(org.mockito.Mock) Maybe(io.reactivex.Maybe) CommonUtils(com.epam.reportportal.util.test.CommonUtils) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) TestUtils(com.epam.reportportal.testng.integration.util.TestUtils) Answer(org.mockito.stubbing.Answer) Mockito(org.mockito.Mockito) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) List(java.util.List) TestUtils.extractRequests(com.epam.reportportal.testng.integration.util.TestUtils.extractRequests) ArgumentCaptor(org.mockito.ArgumentCaptor) Stream(java.util.stream.Stream) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) TestUtils.extractRequest(com.epam.reportportal.testng.integration.util.TestUtils.extractRequest) Matchers.equalTo(org.hamcrest.Matchers.equalTo) com.epam.reportportal.testng.integration.feature.testcaseid(com.epam.reportportal.testng.integration.feature.testcaseid) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Collections(java.util.Collections) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 18 with Launch

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

the class AssumptionsTest method verify_assumption_failure_marks_test_as_skipped.

@Test
public void verify_assumption_failure_marks_test_as_skipped() {
    TestUtils.runClasses(AssumptionFailedTest.class);
    Launch launch = AssumptionsTestExtension.LAUNCH;
    // Start parent Suite
    verify(launch).startTestItem(any(StartTestItemRQ.class));
    // Start a test
    verify(launch, times(1)).startTestItem(notNull(), any(StartTestItemRQ.class));
    ArgumentCaptor<FinishTestItemRQ> finishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(launch, times(2)).finishTestItem(any(), finishCaptor.capture());
    List<FinishTestItemRQ> finishItems = finishCaptor.getAllValues();
    assertThat(finishItems.get(0).getStatus(), equalTo(ItemStatus.SKIPPED.name()));
    assertThat(finishItems.get(1).getStatus(), nullValue());
}
Also used : Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) BeforeEachAssumptionFailedTest(com.epam.reportportal.junit5.features.skipped.BeforeEachAssumptionFailedTest) SingleTest(com.epam.reportportal.junit5.features.coderef.SingleTest) Test(org.junit.jupiter.api.Test) AssumptionFailedTest(com.epam.reportportal.junit5.features.skipped.AssumptionFailedTest)

Example 19 with Launch

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

the class AttributesTest method verify_class_level_attributes.

@Test
public void verify_class_level_attributes() {
    TestUtils.runClasses(ClassLevelAttributesTest.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(), hasSize(1));
    ItemAttributesRQ attribute = testRequest.getAttributes().iterator().next();
    assertThat(attribute.getKey(), equalTo(ClassLevelAttributesTest.KEY));
    assertThat(attribute.getValue(), equalTo(ClassLevelAttributesTest.VALUE));
    StartTestItemRQ stepRequest = extractRequest(captor, "step");
    assertThat(stepRequest.getAttributes(), anyOf(nullValue(), emptyIterable()));
}
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 20 with Launch

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

the class CodeReferenceTest method verify_dynamic_test_code_reference_generation.

@Test
public void verify_dynamic_test_code_reference_generation() {
    TestUtils.runClasses(SingleDynamicTest.class);
    Launch launch = CodeReferenceTestExtension.LAUNCH;
    ArgumentCaptor<StartTestItemRQ> suiteCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start parent Suite
    verify(launch, times(1)).startTestItem(suiteCaptor.capture());
    ArgumentCaptor<StartTestItemRQ> testCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start a test class and a test
    verify(launch, times(2)).startTestItem(notNull(), testCaptor.capture());
    String className = SingleDynamicTest.class.getCanonicalName();
    StartTestItemRQ suiteRq = suiteCaptor.getValue();
    assertThat(suiteRq.getCodeRef(), equalTo(className));
    List<StartTestItemRQ> rqValues = testCaptor.getAllValues();
    String testName = className + ".testForTestFactory";
    assertThat(rqValues.get(0).getCodeRef(), equalTo(testName));
    assertThat(rqValues.get(1).getCodeRef(), equalTo(testName + "$" + SingleDynamicTest.TEST_CASE_DISPLAY_NAME));
}
Also used : Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test) SingleTest(com.epam.reportportal.junit5.features.coderef.SingleTest) SingleDynamicTest(com.epam.reportportal.junit5.features.coderef.SingleDynamicTest)

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