Search code examples
javajunit

AssertNull should be used or AssertNotNull


This is a pretty dumb question but my first time with unit testing so: lets say I have an object variable like obj and I want my unit test to Fail if this obj is Null. so for assertions, should I say AssertNull or AssertNotNull ? I get confused how they are named.


Solution

  • Use assertNotNull(obj). assert means must be.