1. Explore
  2. »
  3. JUnit
  4. »
  5. org.junit
  6. »
  7. Assert
  8. »
  9. fail
  10. »
  11. AssertionError

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 { 
    
       @Test 
       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.

  2. Assert.fail() has thrown an AssertionError
    No solution
  3. Assert.fail() has thrown a testCalendarBasedTimeout
    No solution
DescriptionException TypeEntry MethodWeb pages

JUnit test assertion failed

java.lang.AssertionError
org.junit.Assert.fail
4191Web pages
1Solution
AssertionErrorAssert.fail()4191

Assert.fail() has thrown an AssertionError

java.lang.AssertionError
1 frames hidden
org.junit.Assert.fail
40Web pages
AssertionErrorAssert.fail()40

Assert.fail() has thrown a testCalendarBasedTimeout

org.jboss.as.ejb3.timer.schedule.CalendarBasedTimeoutTestCase.testCalendarBasedTimeout
org.junit.Assert.fail
2Web pages
testCalendarBasedTimeoutAssert.fail()2