Skip to content

Commit c671313

Browse files
olivierlemaslempkorstanje
authored andcommitted
Fix Scenario.isFailed
Adapt `Scenario.isFailed()` to change in `Scenario.getStatus()`. Fixes cucumber#1215.
1 parent 953b5a3 commit c671313

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

core/src/main/java/cucumber/runtime/ScenarioImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public Result.Type getStatus() {
6969

7070
@Override
7171
public boolean isFailed() {
72-
return "failed".equals(getStatus());
72+
return getStatus() == Result.Type.FAILED;
7373
}
7474

7575
@Override

core/src/test/java/cucumber/runtime/ScenarioResultTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
import static java.util.Arrays.asList;
1414
import static org.hamcrest.CoreMatchers.sameInstance;
15-
import static org.junit.Assert.assertEquals;
16-
import static org.junit.Assert.assertThat;
15+
import static org.junit.Assert.*;
1716
import static org.mockito.Mockito.mock;
1817
import static org.mockito.Mockito.verify;
1918
import static org.mockito.Mockito.when;
@@ -37,13 +36,15 @@ public void passed_failed_pending_undefined_skipped_is_failed() throws Exception
3736
s.add(new Result(Result.Type.UNDEFINED, 0L, null));
3837
s.add(new Result(Result.Type.SKIPPED, 0L, null));
3938
assertEquals(Result.Type.FAILED, s.getStatus());
39+
assertTrue(s.isFailed());
4040
}
4141

4242
@Test
4343
public void passed_and_skipped_is_skipped_although_we_cant_have_skipped_without_undefined_or_pending() throws Exception {
4444
s.add(new Result(Result.Type.PASSED, 0L, null));
4545
s.add(new Result(Result.Type.SKIPPED, 0L, null));
4646
assertEquals(Result.Type.SKIPPED, s.getStatus());
47+
assertFalse(s.isFailed());
4748
}
4849

4950
@Test
@@ -53,6 +54,7 @@ public void passed_pending_undefined_skipped_is_pending() throws Exception {
5354
s.add(new Result(Result.Type.PENDING, 0L, null));
5455
s.add(new Result(Result.Type.SKIPPED, 0L, null));
5556
assertEquals(Result.Type.UNDEFINED, s.getStatus());
57+
assertFalse(s.isFailed());
5658
}
5759

5860
@Test
@@ -61,6 +63,7 @@ public void passed_undefined_skipped_is_undefined() throws Exception {
6163
s.add(new Result(Result.Type.UNDEFINED, 0L, null));
6264
s.add(new Result(Result.Type.SKIPPED, 0L, null));
6365
assertEquals(Result.Type.UNDEFINED, s.getStatus());
66+
assertFalse(s.isFailed());
6467
}
6568

6669
@Test

0 commit comments

Comments
 (0)