#5 NullPointerException from assertEquals

open
nobody
None
5
2009-08-21
2009-08-21
Anonymous
No

I believe that there is an error within the Assertion class. When you call assertEquals with two objects that are null an exception is thrown.

They are still equal and should throw no exception. This should be caught in another way.

Discussion

  • CA Meijer
    CA Meijer
    2009-08-23

    The behavior is inconsistent with JUnit 3.8.

    Workaround: If the expected value is null, rather use assertNull(actual) to test whether the actual value is null.