fest-assert-2.x
fest-assert-2.x copied to clipboard
Assert that a block of code is throwing
Hi,
it would be great to see integration with Java 8. This enables lazy evaluation, which would be helpful to assert that specific exceptions are thrown, e.g.
Assertions.assertThat(() -> {
throw new RuntimeException("Error");
}).isThrowing(RuntimeException.class, "Error");
For a working example implementation please take a look at this gist.
Thanks,
Daniel
you can give a try to AssertJ 3.0 that provides a similar feature : http://joel-costigliola.github.io/assertj/assertj-core-news.html#assertj-core-3.0.0-thrown-by