AssertThrowsMultipleStatements
The lambda passed to assertThows should contain exactly one statement

Severity
WARNING
Has Fix?
REQUIRES_HUMAN_ATTENTION

The problem

If the body of the lambda passed to assertThrows contains multiple statements, executation of the lambda will stop at the first statement that throws an exception and all subsequent statements will be ignored.

This means that:

Don’t do this:

```java {.bad} ImmutableList xs; assertThrows( UnsupportedOperationException.class, () -> { xs = ImmutableList.of(); // the test passes if this throws xs.add(0); assertThat(xs).isEmpty(); // this is never executed });


Do this instead:

```java {.good}
ImmutableList<Integer> xs = ImmutableList.of();
assertThrows(
    UnsupportedOperationException.class,
    () -> xs.add(0));
assertThat(xs).isEmpty();

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("AssertThrowsMultipleStatements") to the enclosing element.