diff --git a/engine/src/main/java/com/chutneytesting/engine/domain/execution/strategies/ForEachStrategy.java b/engine/src/main/java/com/chutneytesting/engine/domain/execution/strategies/ForEachStrategy.java index 98521530c..65ec91394 100644 --- a/engine/src/main/java/com/chutneytesting/engine/domain/execution/strategies/ForEachStrategy.java +++ b/engine/src/main/java/com/chutneytesting/engine/domain/execution/strategies/ForEachStrategy.java @@ -71,7 +71,7 @@ public Status execute(ScenarioExecution scenarioExecution, iterations.forEach(it -> { HashMap mergedContext = new HashMap<>(localContext); mergedContext.putAll(it.getRight()); - DefaultStepExecutionStrategy.instance.execute(scenarioExecution, it.getLeft()/*step*/, scenarioContext, mergedContext/*localContext*/, strategies); + DefaultStepExecutionStrategy.instance.execute(scenarioExecution, it.getLeft(), scenarioContext, mergedContext, strategies); }); } else { diff --git a/engine/src/test/java/com/chutneytesting/engine/domain/execution/engine/step/StepStateTest.java b/engine/src/test/java/com/chutneytesting/engine/domain/execution/engine/step/StepStateTest.java index c466c82ad..7c00c21ab 100644 --- a/engine/src/test/java/com/chutneytesting/engine/domain/execution/engine/step/StepStateTest.java +++ b/engine/src/test/java/com/chutneytesting/engine/domain/execution/engine/step/StepStateTest.java @@ -35,7 +35,7 @@ public class StepStateTest { @Test void should_change_state() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); stepState.successOccurred(); assertThat(stepState.status()).isEqualTo(Status.SUCCESS); @@ -55,7 +55,7 @@ void should_change_state() { @Test void should_handle_null_or_empty_errors() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); stepState.errorOccurred(null, ""); stepState.addErrors(null, ""); @@ -65,7 +65,7 @@ void should_handle_null_or_empty_errors() { @Test void should_handle_null_or_empty_informations() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); stepState.successOccurred(null, ""); stepState.addInformation(null, ""); @@ -75,7 +75,7 @@ void should_handle_null_or_empty_informations() { @Test void should_manage_watch_with_idempotency() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); List durations = new ArrayList<>(); IntStream.range(1, 5).forEach(i -> { @@ -100,7 +100,7 @@ void should_manage_watch_with_idempotency() { @Test void should_manage_watch_independently_of_status() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); Status initialStatus = stepState.status(); stepState.startWatch(); @@ -113,7 +113,7 @@ void should_manage_watch_independently_of_status() { @Test void should_change_status_and_clean_logs_when_reset() { // Given - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); stepState.addInformation("..."); stepState.errorOccurred("..."); @@ -132,7 +132,7 @@ void should_change_status_and_clean_logs_when_reset() { @Test void should_begin_execution() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); stepState.beginExecution(); awaitDuring(100, MILLISECONDS); @@ -155,7 +155,7 @@ void should_begin_execution() { @Test void should_end_execution() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); stepState.startWatch(); Status initialStatus = stepState.status(); awaitDuring(100, MILLISECONDS); @@ -175,7 +175,7 @@ void should_end_execution() { @Test void should_change_parent_step_running_status_when_end_execution() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); stepState.beginExecution(); assertThat(stepState.status()).isEqualTo(Status.RUNNING); @@ -191,7 +191,7 @@ class ConcurrentMessagesModification { class Informations { @RepeatedTest(20) void add_information() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); for (int i = 0; i < 10000; i++) { stepState.addInformation("info " + i); } @@ -208,7 +208,7 @@ void add_information() { @RepeatedTest(20) void success_occurred() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); for (int i = 0; i < 10000; i++) { stepState.addInformation("info " + i); } @@ -228,7 +228,7 @@ void success_occurred() { class Errors { @RepeatedTest(20) void add_error() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); for (int i = 0; i < 10000; i++) { stepState.addErrors("error " + i); } @@ -245,7 +245,7 @@ void add_error() { @RepeatedTest(20) void error_occurred() { - StepState stepState = new StepState("Test"); + StepState stepState = new StepState(); for (int i = 0; i < 10000; i++) { stepState.addErrors("error " + i); } diff --git a/engine/src/test/java/com/chutneytesting/engine/domain/execution/strategies/ForEachStrategyTest.java b/engine/src/test/java/com/chutneytesting/engine/domain/execution/strategies/ForEachStrategyTest.java index ba194a3f8..b75d88b67 100644 --- a/engine/src/test/java/com/chutneytesting/engine/domain/execution/strategies/ForEachStrategyTest.java +++ b/engine/src/test/java/com/chutneytesting/engine/domain/execution/strategies/ForEachStrategyTest.java @@ -309,15 +309,24 @@ public void should_accept_nested_loops_and_override_dataset() { public void should_accept_nested_loops_with_different_dataset() { // G final TestEngine testEngine = new ExecutionConfiguration().embeddedTestEngine(); - ExecutionRequestDto requestDto = Jsons.loadJsonFromClasspath("scenarios_examples/forEachStrategy/step_nested_iterations_with_extended_dataset.json", ExecutionRequestDto.class); + ExecutionRequestDto requestDto = Jsons.loadJsonFromClasspath("scenarios_examples/forEachStrategy/step_nested_iterations_with_different_dataset.json", ExecutionRequestDto.class); // W StepExecutionReportDto result = testEngine.execute(requestDto); // T - StepExecutionReportDto parentIterativeStep = result.steps.get(0); - assertThat(parentIterativeStep.steps).hasSize(2); // has 2 iterations - assertThat(result.status).isEqualTo(SUCCESS); + assertThat(result).hasFieldOrPropertyWithValue("status", SUCCESS); + assertThat(result.name).isEqualTo("Test iterations"); + assertThat(result.steps).hasSize(1); + assertThat(result.steps.get(0).name).isEqualTo(" - Hello env ${#env} "); + assertThat(result.steps.get(0).steps).hasSize(2); + assertThat(result.steps.get(0).steps.get(0).name).isEqualTo("0 - Hello env envX "); + assertThat(result.steps.get(0).steps.get(1).name).isEqualTo("1 - Hello env envY "); + assertThat(result.steps.get(0).steps.get(0).steps).hasSize(1); + assertThat(result.steps.get(0).steps.get(0).steps.get(0).name).isEqualTo(" - Hello nested on envX with user ${#user}"); + assertThat(result.steps.get(0).steps.get(0).steps.get(0).steps).hasSize(2); + assertThat(result.steps.get(0).steps.get(0).steps.get(0).steps.get(0).name).isEqualTo("0 - Hello nested on envX with user userA"); + assertThat(result.steps.get(0).steps.get(0).steps.get(0).steps.get(1).name).isEqualTo("1 - Hello nested on envX with user userB"); } @Test diff --git a/engine/src/test/resources/scenarios_examples/forEachStrategy/step_nested_iterations_with_extended_dataset.json b/engine/src/test/resources/scenarios_examples/forEachStrategy/step_nested_iterations_with_different_dataset.json similarity index 100% rename from engine/src/test/resources/scenarios_examples/forEachStrategy/step_nested_iterations_with_extended_dataset.json rename to engine/src/test/resources/scenarios_examples/forEachStrategy/step_nested_iterations_with_different_dataset.json