alexruiz / fest-assert-2.x

FEST Fluent Assertions 2.x
http://fest.easytesting.org
Apache License 2.0
402 stars 69 forks source link

Assert that a block of code is throwing #166

Open danieldietrich opened 10 years ago

danieldietrich commented 10 years ago

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

joel-costigliola commented 9 years ago

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