Search in sources :

Example 1 with com.epam.reportportal.junit5.features.testcaseid

use of com.epam.reportportal.junit5.features.testcaseid 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)

Aggregations

com.epam.reportportal.junit5.features.testcaseid (com.epam.reportportal.junit5.features.testcaseid)1 TestUtils (com.epam.reportportal.junit5.util.TestUtils)1 Launch (com.epam.reportportal.service.Launch)1 CommonUtils (com.epam.reportportal.util.test.CommonUtils)1 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)1 Maybe (io.reactivex.Maybe)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1 Matchers.hasItem (org.hamcrest.Matchers.hasItem)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 TestInstance (org.junit.jupiter.api.TestInstance)1 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.notNull (org.mockito.ArgumentMatchers.notNull)1