Skip to content

Commit bb2b8f3

Browse files
rabestroJegors Cemisovs
andauthored
Add test case for Bird Watcher exercise (#2956)
Add a test to `hasDayWithoutBirds` for when the last day has zero visits. This checks that the solution correctly checks the entire array. See also a the forum post https://forum.exercism.org/t/bird-watcher-in-java-should-we-add-a-test-case/17933/16. Also make `lastWeek` final in the test, since the field isn't meant to change in the test. Co-authored-by: Jegors Cemisovs <[email protected]>
1 parent bb0bca8 commit bb2b8f3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

exercises/concept/bird-watcher/src/test/java/BirdWatcherTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class BirdWatcherTest {
1616
private static final int TODAY = 4;
1717

1818
private BirdWatcher birdWatcher;
19-
private int lastWeek[] = {DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY};
19+
private final int[] lastWeek = {DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY};
2020

2121
@BeforeEach
2222
public void setUp() {
@@ -61,6 +61,13 @@ public void itShouldNotHaveDaysWithoutBirds() {
6161
assertThat(birdWatcher.hasDayWithoutBirds()).isFalse();
6262
}
6363

64+
@Test
65+
@Tag("task:4")
66+
@DisplayName("The hasDayWithoutBirds method returns true if the last day has zero visits")
67+
public void itHasLastDayWithoutBirds() {
68+
birdWatcher = new BirdWatcher(new int[]{1, 2, 5, 3, 7, 8, 0});
69+
assertThat(birdWatcher.hasDayWithoutBirds()).isTrue();
70+
}
6471

6572
@Test
6673
@Tag("task:5")

0 commit comments

Comments
 (0)