»»»»

org.junit.Assert.assertEquals errorsJUnit

Top patterns

  1. JUnit "equals" comparison failed

    ComparisonFailure is thrown when using JUnit's internal assertions to compare two strings, number or objects that are not equal. The simplest code to reproduce the error is the following:

    import static org.junit.Assert.assertEquals;
    
    public class ObjectComparisonTest { 
    
       @Test 
       public void shouldAssertStrings() { 
          assertEquals("Jhon", "John");  //The letters are in different order
       } 
    
       @Test 
       public void shouldAssertNumbers() { 
          assertEquals(1, 2); 
       } 
    
       @Test 
       public void shouldAssertObjects() {
          Person p1 = new Person();
          Person p2 = new Person();
          assertEquals(p1, p2);  // The object instances are not the same
       } 
    }
    
    class Person { ... }
    

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

  2. Assert.assertEquals() has thrown a NullPointerException
    No solution
Error patternsExceptions
DescriptionException TypeEntry MethodWeb pages

JUnit "equals" comparison failed

org.junit.ComparisonFailure
org.junit.Assert.assertEquals
656Web pages
1Solution
ComparisonFailureAssert.assertEquals656

Assert.assertEquals() has thrown a NullPointerException

java.lang.NullPointerException
5 frames hidden
org.junit.Assert.assertEquals
0Web pages
NullPointerExceptionAssert.assertEquals0
Nothing to list here.