17 lines
381 B
Plaintext
17 lines
381 B
Plaintext
== Compliant Solution
|
|
|
|
[source,text]
|
|
----
|
|
assertThrows(AssertionError.class, () -> throwAssertionError());
|
|
----
|
|
|
|
[source,text]
|
|
----
|
|
try {
|
|
throwAssertionError();
|
|
Assert.fail("Expected an AssertionError!"); // Compliant, we made sure to test that the correct error is raised
|
|
} catch (AssertionError e) {
|
|
Assert.assertThat(e.getMessage(), is("My assertion error"));
|
|
}
|
|
----
|