Skip to content

Commit

Permalink
add failing nested step for demonstration (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Schäfer committed Dec 12, 2015
1 parent 375904d commit b586229
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<NestedStage> {

@ProvidedScenarioState
Expand All @@ -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 )
Expand Down

0 comments on commit b586229

Please sign in to comment.