You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assertion methods are throwing a "java.lang.AssertionError". If this call is done within the try block of a try-catch cathing a similar error, you should make sure to test some properties of the exception. Otherwise, the assertion will never fail.
Noncompliant code example
@Test
public void should_throw_assertion_error() {
try {
throwAssertionError();
Assert.fail("Expected an AssertionError!"); // Noncompliant, the AssertionError will be caught and the test will never fail.
} catch (AssertionError e) {}
}
private void throwAssertionError() {
throw new AssertionError("My assertion error");
}
Compliant solution
assertThrows(AssertionError.class, () -> throwAssertionError());
try {
throwAssertionError();
Assert.fail("Expected an AssertionError!"); // Compliant, we made sure to test that the correct error is raised
} catch (AssertionErrore) {
Assert.assertThat(e.getMessage(), is("My assertion error"));
}
The text was updated successfully, but these errors were encountered:
아래 버그가 잡혀서 추후 수정하면 좋을 듯.
Assertion methods are throwing a "java.lang.AssertionError". If this call is done within the try block of a try-catch cathing a similar error, you should make sure to test some properties of the exception. Otherwise, the assertion will never fail.
Noncompliant code example
Compliant solution
The text was updated successfully, but these errors were encountered: