fest-assert-2.x icon indicating copy to clipboard operation
fest-assert-2.x copied to clipboard

Assert that a block of code is throwing

Open danieldietrich opened this issue 10 years ago • 1 comments

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

danieldietrich avatar Jul 22 '14 19:07 danieldietrich

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

joel-costigliola avatar Jun 13 '15 05:06 joel-costigliola