jUnit - how to assert that a value not equals to both of another values

Viewed 5814

I used hamcrest library to test the code and I want to assert that the actual value(the first argument) not equals to both of 2 specified values("bad" and "good" in equalTo method). It should pass the test if the actual value (first argument of assertThat method) not equals to "good" and not equals to "bad". so I tried the following statement :

 @Test
public void valueNotEqualToBoth() {
    assertThat("good", not(allOf(equalTo("bad"), equalTo("good"))));
}

but it turns out that it pass the test but What I excepted is it shouldn't. because the first argument is equals to "good".

3 Answers
Related