java.langAssertionError errorsJUnit

Top patterns

  1. JUnit test assertion failed

    AssertionError is thrown when using JUnit's internal assertions methods compare two different values and those are not equal. Also, the developer can invoke the method when the test logic fails.

    The simplest code to reproduce the error is the following:

    import static org.junit.Assert.fail;
    public class FailTest { 
       public void shouldAssertFail() { 
          if( ... ) {
             fail("Any message");

    Mind the static import. The fail is part of the JUnit API.

    Your best course of action is to use the debugger to see why the test is failing and what is the condition that is not being met.

DescriptionException TypeEntry MethodWeb pages

JUnit test assertion failed

4176Web pages