Skip to content

Commit

Permalink
Issue cucumber#196 process pending steps correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
klausbayrhammer committed Mar 31, 2012
1 parent de3d9ef commit 564d147
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
30 changes: 26 additions & 4 deletions core/src/main/java/cucumber/runtime/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,42 @@ public List<Throwable> getErrors() {

public byte exitStatus() {
byte result = 0x0;
if (hasErrors() || hasUndefinedStepsAndIsStrict()) {
if (hasErrors() || hasUndefinedOrPendingStepsAndIsStrict()) {
result |= ERRORS;
}
return result;
}

private boolean hasUndefinedStepsAndIsStrict()
private boolean hasUndefinedOrPendingStepsAndIsStrict()
{
return runtimeOptions.strict && undefinedStepsTracker.hasUndefinedSteps();
return runtimeOptions.strict && hasUndefinedOrPendingSteps();
}

private boolean hasUndefinedOrPendingSteps()
{
return hasUndefinedSteps() || hasPendingSteps();
}

private boolean hasUndefinedSteps()
{
return undefinedStepsTracker.hasUndefinedSteps();
}

private boolean hasPendingSteps()
{
return !errors.isEmpty() && !hasErrors();
}

private boolean hasErrors()
{
return !errors.isEmpty();
for (Throwable error : errors)
{
if (!(error instanceof PendingException))
{
return true;
}
}
return false;
}

public List<String> getSnippets() {
Expand Down
8 changes: 1 addition & 7 deletions core/src/test/java/cucumber/runtime/RuntimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void non_strict_with_pending_steps()
Runtime runtime = createNonStrictRuntime();
runtime.addError(new PendingException());

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

@Test
Expand Down Expand Up @@ -181,10 +181,4 @@ private Runtime createRuntime(String ... runtimeArgs)

return new Runtime(resourceLoader, classLoader, backends, runtimeOptions);
}

private void addPendingSteps(Runtime spy)
{
List<String> snippetList = Arrays.asList("snippet");
when(spy.getSnippets()).thenReturn(snippetList);
}
}

0 comments on commit 564d147

Please sign in to comment.