@@ -137,25 +137,35 @@ void shouldAddExcludedPerformableScenariosToPerformableStory() {
137
137
138
138
@ Test
139
139
void shouldNotSkipStoryWhenGivenStoryIsFailed () {
140
- RunContext context = performStoryRun (false , GIVEN_SCENARIO_FAIL );
140
+ RunContext context = performStoryRun (new StoryControls ().doSkipStoryIfGivenStoryFailed (false ),
141
+ GIVEN_SCENARIO_FAIL );
141
142
assertThat (context .failureOccurred (), is (false ));
142
143
assertThat (context .configuration ().storyControls ().skipStoryIfGivenStoryFailed (), is (false ));
143
144
}
144
145
145
146
@ Test
146
147
void shouldSkipStoryWhenGivenStoryIsFailed () {
147
- RunContext context = performStoryRun (true , GIVEN_SCENARIO_FAIL );
148
+ RunContext context = performStoryRun (new StoryControls ().doSkipStoryIfGivenStoryFailed (true ),
149
+ GIVEN_SCENARIO_FAIL );
148
150
assertThat (context .failureOccurred (), is (true ));
149
151
assertThat (context .configuration ().storyControls ().skipStoryIfGivenStoryFailed (), is (true ));
150
152
}
151
153
152
154
@ Test
153
155
void shouldNotSkipStoryWhenGivenStoryIsPassed () {
154
- RunContext context = performStoryRun (true , "Scenario: given scenario title" );
156
+ RunContext context = performStoryRun (new StoryControls ().doSkipStoryIfGivenStoryFailed (true ),
157
+ "Scenario: given scenario title" );
155
158
assertThat (context .failureOccurred (), is (false ));
156
159
assertThat (context .configuration ().storyControls ().skipStoryIfGivenStoryFailed (), is (true ));
157
160
}
158
161
162
+ @ Test
163
+ void shouldResetCurrentStoryControlsOnlyForRootStory () {
164
+ StoryControls storyControls = mock (StoryControls .class );
165
+ performStoryRun (storyControls , GIVEN_SCENARIO_FAIL );
166
+ verify (storyControls ).resetCurrentStoryControls ();
167
+ }
168
+
159
169
@ Test
160
170
void shouldResetCurrentStoryControls () {
161
171
Configuration configuration = new MostUsefulConfiguration ();
@@ -334,14 +344,13 @@ private Map<String, String> createExamplesRow(String key1, String value1, String
334
344
return storyExampleFirstRow ;
335
345
}
336
346
337
- private RunContext performStoryRun (boolean skipScenariosAfterGivenStoriesFailure , String givenStoryAsString ) {
347
+ private RunContext performStoryRun (StoryControls storyControls , String givenStoryAsString ) {
338
348
String givenStoryPath = "given/path" ;
339
349
Scenario scenario = new Scenario ("base scenario title" , Meta .EMPTY );
340
350
Story story = new Story (STORY_PATH , null , null , null , new GivenStories (givenStoryPath ),
341
351
singletonList (scenario ));
342
352
343
- Configuration configuration = new MostUsefulConfiguration ().useStoryControls (
344
- new StoryControls ().doSkipStoryIfGivenStoryFailed (skipScenariosAfterGivenStoriesFailure ));
353
+ Configuration configuration = new MostUsefulConfiguration ().useStoryControls (storyControls );
345
354
StoryLoader storyLoader = mock (StoryLoader .class );
346
355
configuration .useStoryLoader (storyLoader );
347
356
when (storyLoader .loadStoryAsText (givenStoryPath )).thenReturn (givenStoryAsString );
0 commit comments