Skip to content

Commit

Permalink
checking for dry run option before running hooks.
Browse files Browse the repository at this point in the history
make sure that dryRun has not been set before running hooks.
  • Loading branch information
wjpowell committed Dec 28, 2012
1 parent ecdbd77 commit a5ace1a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 4 additions & 2 deletions core/src/main/java/cucumber/runtime/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ public void runAfterHooks(Reporter reporter, Set<Tag> tags) {
}

private void runHooks(List<HookDefinition> hooks, Reporter reporter, Set<Tag> tags, boolean isBefore) {
for (HookDefinition hook : hooks) {
runHookIfTagsMatch(hook, reporter, tags, isBefore);
if (!runtimeOptions.dryRun) {
for (HookDefinition hook : hooks) {
runHookIfTagsMatch(hook, reporter, tags, isBefore);
}
}
}

Expand Down
17 changes: 15 additions & 2 deletions core/src/test/java/cucumber/runtime/RuntimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,29 @@ public void non_strict_with_errors() {

assertEquals(0x1, runtime.exitStatus());
}

@Test
public void dry_run_set() {
Runtime runtime = createDryRunRuntime();
runtime.addError(new RuntimeException());

assertEquals(0x1, runtime.exitStatus());
}


@Test
public void strict_with_errors() {
Runtime runtime = createStrictRuntime();
runtime.addError(new RuntimeException());

assertEquals(0x1, runtime.exitStatus());
}

private Runtime createStrictRuntime() {
private Runtime createDryRunRuntime() {
return createRuntime("--dry-run");
}

private Runtime createStrictRuntime() {
return createRuntime("-g anything", "--strict");
}

Expand Down

0 comments on commit a5ace1a

Please sign in to comment.