@Test
void shouldMergeRetriesTestResults() {

    String historyId = UUID.randomUUID().toString();
    List<LaunchResults> launchResultsList = createSingleLaunchResults(
            createTestResult(FIRST_RESULT, historyId, 1L, 9L),
            createTestResult(SECOND_RESULT, historyId, 11L, 19L),
            createTestResult(LAST_RESULT, historyId, 21L, 29L)
    );
    retryPlugin.aggregate(null, launchResultsList, null);
    Set<TestResult> results = launchResultsList.get(0).getAllResults();
    assertThat(results).as("test retries")
            .filteredOn(TestResult::isHidden)
            .extracting(TestResult::getName)
            .containsExactlyInAnyOrder(FIRST_RESULT, SECOND_RESULT);
    TestResult lastResult = results.stream()
            .filter(r -> !r.isHidden()).findFirst().orElseGet(null);
    assertThat(Collections.singletonList(lastResult))
            .as("latest test result")
            .extracting(TestResult::getName, TestResult::isHidden, TestResult::isFlaky)
            .containsExactlyInAnyOrder(tuple(LAST_RESULT, false, true));
    assertThat(results).as("test results with retries block")
            .filteredOn(result -> result.hasExtraBlock(RETRY_BLOCK_NAME))
            .hasSize(1);
    List<RetryItem> retries = lastResult.getExtraBlock(RETRY_BLOCK_NAME);
    assertThat(retries).as("test results retries block")
            .isNotNull()
            .hasSize(2);
}