diff --git a/jgiven-examples/src/test/java/com/tngtech/jgiven/examples/nested/NestedStepsTest.java b/jgiven-examples/src/test/java/com/tngtech/jgiven/examples/nested/NestedStepsTest.java index c0a28b1e0f..03ebca1356 100644 --- a/jgiven-examples/src/test/java/com/tngtech/jgiven/examples/nested/NestedStepsTest.java +++ b/jgiven-examples/src/test/java/com/tngtech/jgiven/examples/nested/NestedStepsTest.java @@ -1,5 +1,7 @@ package com.tngtech.jgiven.examples.nested; +import static org.assertj.core.api.Assertions.assertThat; + import org.junit.Test; import org.testng.Assert; @@ -23,6 +25,17 @@ public void a_scenario_with_nested_steps() { } + @Test + public void a_scenario_with_a_failing_nested_step_on_purpose() { + + given().I_fill_out_the_registration_form_with_invalid_values(); + + when().I_submit_the_form(); + + then().the_password_matches(); + + } + static class NestedStage extends Stage { @ProvidedScenarioState @@ -45,6 +58,18 @@ public NestedStage I_fill_out_the_registration_form_with_valid_values() { .and().I_enter_a_repeated_password( "password1234" ); } + @NestedSteps + public NestedStage I_fill_out_the_registration_form_with_invalid_values() { + return I_enter_a_name( "Franky" ) + .and().I_enter_a_email_address( "franky@acme.com" ) + .and().something_fails_for_demonstration_purposes(); + } + + public NestedStage something_fails_for_demonstration_purposes() { + assertThat( true ).as( "Fails on purpose" ).isFalse(); + return self(); + } + @NestedSteps public NestedStage I_enter_a_name( String name ) { return I_think_a_name( name )