rspec/rules/S5779/compliant.adoc
2022-02-04 16:28:24 +00:00

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"));
}
----