Skip to content

Commit bb0b9a5

Browse files
committed
3.2 Simplified forEach test
1 parent e1a6eb2 commit bb0b9a5

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

tests/java/itrx/chapter3/leaving/ForEachTest.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,15 @@ public void testBlockingForEach() throws InterruptedException {
122122
assertEquals(received, Arrays.asList(0L, 1L, 2L, 3L, 4L, -1L));
123123
}
124124

125-
@Test
125+
@Test(expected = Exception.class)
126126
public void testBlockingForEachError() {
127-
boolean caughtException = false;
128-
129127
Observable<Long> values = Observable.error(new Exception("Oops"));
130128

131-
try {
132-
values
133-
.take(5)
134-
.toBlocking()
135-
.forEach(
136-
v -> {});
137-
}
138-
catch (Exception e) {
139-
caughtException = true;
140-
}
141-
142-
assertTrue(caughtException);
129+
values
130+
.take(5)
131+
.toBlocking()
132+
.forEach(
133+
v -> {});
143134
}
144135

145136
}

0 commit comments

Comments
 (0)