Why doesn't JUnit provide assertNotEquals methods?

后端 未结 11 1120
忘了有多久
忘了有多久 2020-12-12 08:30

Does anybody know why JUnit 4 provides assertEquals(foo,bar) but not assertNotEqual(foo,bar) methods?

It provides assertNotSame

11条回答
  •  悲&欢浪女
    2020-12-12 09:18

    Usually I do this when I expect two objects to be equal:

    assertTrue(obj1.equals(obj2));
    

    and:

    assertFalse(obj1.equals(obj2));
    

    when they are expected to be unequal. I am aware that this not an answer to your question but it is the closest I can get. It could help others searching for what they can do in JUnit versions before JUnit 4.11.

提交回复
热议问题