@Override
    public void run(RunNotifier notifier) {
        simulationRunMetadataBuilder = SimulationRunMetadataBuilder.create();

        notifier.fireTestStarted(getDescription());
        for (ScenarioWithIndex scenarioWithIndex : scenarioRunnerDTO.getScenarioWithIndices()) {
            singleRunScenario(scenarioWithIndex, notifier, scenarioRunnerDTO.getSettings(), scenarioRunnerDTO.getBackground())
                    .ifPresent(simulationRunMetadataBuilder::addScenarioResultMetadata);
        }
        notifier.fireTestStarted(getDescription());
    }
@Test
    public void testRun() {
        ArgumentCaptor<Failure> failureArgumentCaptor = ArgumentCaptor.forClass(Failure.class);

        doThrow(new ScenarioException("Failed assertion", true))
                .when(abstractScenarioRunnerLocal).internalRunScenario(eq(scenarioRunnerDTOLocal.getScenarioWithIndices().get(0)),
                                                                       isA(ScenarioRunnerData.class),
                                                                       any(), any());
        doThrow(new ScenarioException("Generic exception"))
                .when(abstractScenarioRunnerLocal).internalRunScenario(eq(scenarioRunnerDTOLocal.getScenarioWithIndices().get(1)),
                                                                       isA(ScenarioRunnerData.class),
                                                                       any(), any());
        doThrow(new ScenarioException(new IllegalArgumentException("Wrong argument")))
                .when(abstractScenarioRunnerLocal).internalRunScenario(eq(scenarioRunnerDTOLocal.getScenarioWithIndices().get(2)),
                                                                       isA(ScenarioRunnerData.class),
                                                                       any(), any());
        doThrow(new RuntimeException("Unknown exception"))
                .when(abstractScenarioRunnerLocal).internalRunScenario(eq(scenarioRunnerDTOLocal.getScenarioWithIndices().get(3)),
                                                                       isA(ScenarioRunnerData.class),
                                                                       any(), any());
        assertThat(abstractScenarioRunnerLocal.simulationRunMetadataBuilder).isNull();
        RunNotifier runNotifier = spy(new RunNotifier());

        abstractScenarioRunnerLocal.run(runNotifier);

        assertThat(abstractScenarioRunnerLocal.simulationRunMetadataBuilder).isNotNull();
        verify(runNotifier, times(SCENARIO_DATA + 2)).fireTestStarted(isA(Description.class));
        verify(runNotifier, times(SCENARIO_DATA)).fireTestFailure(failureArgumentCaptor.capture());
        verify(runNotifier, times(SCENARIO_DATA)).fireTestFinished(isA(Description.class));

        List<Failure> capturedFailures = failureArgumentCaptor.getAllValues();
        assertThat(capturedFailures.get(0).getException()).hasMessage(ScenarioSimulationServerMessages.getIndexedScenarioMessage("Failed assertion", 1, "INDEX-0", "test"));
        assertThat(capturedFailures.get(0).getException()).isInstanceOf(IndexedScenarioAssertionError.class);
        assertThat(capturedFailures.get(1).getException()).hasMessage(ScenarioSimulationServerMessages.getIndexedScenarioMessage("Generic exception", 2, "INDEX-1", "test"));
        assertThat(capturedFailures.get(1).getException()).isInstanceOf(IndexedScenarioException.class);
        assertThat(capturedFailures.get(2).getException()).hasMessage(ScenarioSimulationServerMessages.getIndexedScenarioMessage("Wrong argument", 3, "INDEX-2", "test"));
        assertThat(capturedFailures.get(2).getException()).isInstanceOf(IndexedScenarioException.class);
        assertThat(capturedFailures.get(3).getException()).hasMessage(ScenarioSimulationServerMessages.getIndexedScenarioMessage("Unknown exception", 4, "INDEX-3", "test"));
        assertThat(capturedFailures.get(3).getException()).isInstanceOf(IndexedScenarioException.class);
    }