Search in sources :

Example 1 with JunitDynamicNestedTest

use of com.epam.reportportal.junit5.features.nested.JunitDynamicNestedTest in project agent-java-junit5 by reportportal.

the class JunitNestedTestTest method verify_dynamically_generated_nested_tests.

@Test
@SuppressWarnings("unchecked")
public void verify_dynamically_generated_nested_tests() {
    TestUtils.runClasses(JunitDynamicNestedTest.class);
    Launch launch = TestExtension.LAUNCH;
    ArgumentCaptor<StartTestItemRQ> suiteCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start parent Suite
    verify(launch, times(1)).startTestItem(suiteCaptor.capture());
    ArgumentCaptor<Maybe<String>> parentIdCaptor = ArgumentCaptor.forClass(Maybe.class);
    ArgumentCaptor<StartTestItemRQ> itemRqCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start inner items
    verify(launch, times(9)).startTestItem(parentIdCaptor.capture(), itemRqCaptor.capture());
    verify(launch, times(10)).finishTestItem(any(Maybe.class), any(FinishTestItemRQ.class));
    List<Maybe<String>> parentIds = parentIdCaptor.getAllValues();
    List<StartTestItemRQ> itemRqs = itemRqCaptor.getAllValues();
    int index = 0;
    String parentId = parentIds.get(index).blockingGet();
    StartTestItemRQ itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-JunitDynamicNestedTest-"));
    assertThat(itemRq.getName(), equalTo("dynamicTestsWithContainers()"));
    parentId = parentIds.get(++index).blockingGet();
    itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-dynamicTestsWithContainers()-"));
    assertThat(itemRq.getName(), equalTo("A"));
    parentId = parentIds.get(++index).blockingGet();
    itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-A-"));
    assertThat(itemRq.getName(), equalTo("A inner container"));
    parentId = parentIds.get(++index).blockingGet();
    itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-A inner container-"));
    assertThat(itemRq.getName(), equalTo("A Test 1"));
    parentId = parentIds.get(++index).blockingGet();
    itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-A inner container-"));
    assertThat(itemRq.getName(), equalTo("A Test 2"));
    parentId = parentIds.get(++index).blockingGet();
    itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-dynamicTestsWithContainers()-"));
    assertThat(itemRq.getName(), equalTo("B"));
    parentId = parentIds.get(++index).blockingGet();
    itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-B"));
    assertThat(itemRq.getName(), equalTo("B inner container"));
    parentId = parentIds.get(++index).blockingGet();
    itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-B inner container-"));
    assertThat(itemRq.getName(), equalTo("B Test 1"));
    parentId = parentIds.get(++index).blockingGet();
    itemRq = itemRqs.get(index);
    assertThat(parentId, Matchers.startsWith("suite-B inner container-"));
    assertThat(itemRq.getName(), equalTo("B Test 2"));
}
Also used : Maybe(io.reactivex.Maybe) Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) JunitDynamicNestedTest(com.epam.reportportal.junit5.features.nested.JunitDynamicNestedTest) Test(org.junit.jupiter.api.Test)

Aggregations

JunitDynamicNestedTest (com.epam.reportportal.junit5.features.nested.JunitDynamicNestedTest)1 Launch (com.epam.reportportal.service.Launch)1 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)1 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)1 Maybe (io.reactivex.Maybe)1 Test (org.junit.jupiter.api.Test)1