Skip to content

Commit 23c56a0

Browse files
authored
Fix CheckedRunnableTest#shouldApplyAnUncheckedFunctionThatThrows (#2954)
* `shouldApplyAnUncheckedFunctionThatThrows` always passed, when removing the `throw new Error()` because the failed asserting was immediately caught. ```java final Runnable runnable = CheckedRunnable.of(() -> { /*throw new Error();*/ }).unchecked(); // Test would still pass ``` Fixed by using `assertThrows` from JUnit
1 parent f8bfe52 commit 23c56a0

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/test/java/io/vavr/CheckedRunnableTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ public void shouldApplyAnUncheckedFunctionThatDoesNotThrow() {
6565
@Test
6666
public void shouldApplyAnUncheckedFunctionThatThrows() {
6767
final Runnable runnable = CheckedRunnable.of(() -> { throw new Error(); }).unchecked();
68-
try {
69-
runnable.run();
70-
Assertions.fail("Did expect an exception.");
71-
} catch(Error x) {
72-
// ok!
73-
}
68+
Assertions.assertThrows(Error.class, () -> runnable.run());
7469
}
7570
}

0 commit comments

Comments
 (0)