Why doesn't JUnit provide assertNotEquals methods?

后端 未结 11 1126
忘了有多久
忘了有多久 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:16

    I'm coming to this party pretty late but I have found that the form:

    static void assertTrue(java.lang.String message, boolean condition) 
    

    can be made to work for most 'not equals' cases.

    int status = doSomething() ; // expected to return 123
    assertTrue("doSomething() returned unexpected status", status != 123 ) ;
    

提交回复
热议问题