@@ -40,7 +40,7 @@ public class RunnerTest {
40
40
private final Backend backend = mock (Backend .class );
41
41
private final Runtime runtime = createRuntime (backend );
42
42
private final Runner runner = runtime .getRunner ();
43
-
43
+
44
44
@ Test
45
45
public void hooks_execute_when_world_exist () throws Throwable {
46
46
HookDefinition beforeHook = addBeforeHook (runtime );
@@ -61,7 +61,7 @@ public void steps_are_skipped_after_failure() throws Throwable {
61
61
doThrow (RuntimeException .class ).when (failingBeforeHook ).execute (Matchers .<Scenario >any ());
62
62
StepDefinition stepDefinition = mock (StepDefinition .class );
63
63
64
- runner .runPickle (createPickleEventMatchingStepDefinitions (asList (stepDefinition )));
64
+ runner .runPickle (createPickleEventMatchingStepDefinitions (asList (stepDefinition ), runtime ));
65
65
66
66
InOrder inOrder = inOrder (failingBeforeHook , stepDefinition );
67
67
inOrder .verify (failingBeforeHook ).execute (Matchers .<Scenario >any ());
@@ -83,6 +83,25 @@ public void hooks_execute_also_after_failure() throws Throwable {
83
83
inOrder .verify (afterHook ).execute (Matchers .<Scenario >any ());
84
84
}
85
85
86
+ @ Test
87
+ public void steps_are_not_executed_on_dry_run () throws Throwable {
88
+ // Step without dry-run flag should be executed once
89
+ {
90
+ StepDefinition stepDefinition = mock (StepDefinition .class );
91
+ Runtime runtime = createRuntime (backend );
92
+ runtime .getRunner ().runPickle (createPickleEventMatchingStepDefinitions (asList (stepDefinition ), runtime ));
93
+ verify (stepDefinition ).execute (Matchers .anyString (), Matchers .<Object []>any ());
94
+ }
95
+
96
+ // Same step with dry-run flag should not be executred
97
+ {
98
+ StepDefinition stepDefinition = mock (StepDefinition .class );
99
+ Runtime dryRuntime = createRuntime (backend , "--dry-run" );
100
+ dryRuntime .getRunner ().runPickle (createPickleEventMatchingStepDefinitions (asList (stepDefinition ), dryRuntime ));
101
+ verify (stepDefinition , never ()).execute (Matchers .anyString (), Matchers .<Object []>any ());
102
+ }
103
+ }
104
+
86
105
@ Test
87
106
public void hooks_not_executed_in_dry_run_mode () throws Throwable {
88
107
Runtime runtime = createRuntime (backend , "--dry-run" );
@@ -141,7 +160,7 @@ private PickleEvent createEmptyPickleEvent() {
141
160
return new PickleEvent ("uri" , new Pickle (NAME , ENGLISH , NO_STEPS , NO_TAGS , MOCK_LOCATIONS ));
142
161
}
143
162
144
- private PickleEvent createPickleEventMatchingStepDefinitions (List <StepDefinition > stepDefinitions ) {
163
+ private PickleEvent createPickleEventMatchingStepDefinitions (List <StepDefinition > stepDefinitions , Runtime runtime ) {
145
164
List <PickleStep > steps = new ArrayList <PickleStep >(stepDefinitions .size ());
146
165
int i = 0 ;
147
166
for (StepDefinition stepDefinition : stepDefinitions ) {
0 commit comments