Pattern selector

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

  1. TestRollingUpgrade.testRollback() has thrown an AssertionError
    Unsorted
    0
    0
    0
  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 null, but was:<javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=org.apache.hadoop.hdfs.protocol.RollingUpgradeInfo$Bean,items=((itemName=blockPoolId,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=createdRollbackImages,itemType=javax.management.openmbean.SimpleType(name=java.lang.Boolean)),(itemName=finalizeTime,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=startTime,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)))),contents={blockPoolId=BP-421661364-67.195.81.153-1452420365057, createdRollbackImages=true, finalizeTime=0, startTime=1452420366966})>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotNull(Assert.java:664)
    at org.junit.Assert.assertNull(Assert.java:646)
    at org.junit.Assert.assertNull(Assert.java:656)
2 frames hidden

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. phantomiivia GitHub3 weeks ago
  2. andrewdesvia GitHub3 weeks ago
    expected:<200> but was:<404>
    Show stack trace
  3. mbrukmanvia GitHub4 weeks ago
    expected:<2> but was:<4>
    Show stack trace
  4. yanokwavia GitHub4 weeks ago
    expected:<5> but was:<0>
    Show stack trace
  5. wildfly-civia GitHub1 month ago
    expected:<11> but was:<19>
    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
    block not present after 5000 ms
    Show stack trace
  9. wildfly-civia GitHub1 month ago
    expected:<12> but was:<20>
    Show stack trace
  10. cdjacksonvia GitHub1 month ago
    198.75
    Show stack trace