Pattern selector

Most relevant patterns first. Most helpful ones displayed. Click here to show all.

  1. Assert.failNotEquals() has thrown an AssertionError
    JUnit
    65
    1340
    60
  2. JUnit test assertion failed
    JUnit
    178
    2919
    155

Your stack trace compared to the selected pattern

Jump to solutionsExpand frames
java.lang.AssertionError: expected:<20030303> but was:<20010101>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:743)

Solution

chinthana11 months ago

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.

External results for this pattern (10)

  1. Rajini Sivaramvia Google Groups1 week ago
    expected:<5> but was:<1>
    Show stack trace
  2. phantomiivia GitHub4 weeks ago
  3. andrewdesvia GitHub4 weeks ago
    expected:<200> but was:<404>
    Show stack trace
  4. mbrukmanvia GitHub1 month ago
    expected:<2> but was:<4>
    Show stack trace
  5. yanokwavia GitHub1 month ago
    expected:<5> but was:<0>
    Show stack trace
  6. wildfly-civia GitHub1 month ago
    expected:<11> but was:<19>
    Show stack trace
  7. wildfly-civia GitHub1 month ago
    expected:<11> but was:<19>
    Show stack trace
  8. wildfly-civia GitHub1 month ago
    expected:<11> but was:<19>
    Show stack trace
  9. wildfly-civia GitHub1 month ago
    block not present after 5000 ms
    Show stack trace
  10. wildfly-civia GitHub1 month ago
    expected:<12> but was:<20>
    Show stack trace