mardi 22 août 2017

How to return value true when equals in test (Mockito)?

I'm making test and I want to return true in this if:

if (verifier.IGNORE.equals(result)) {
   //do something
}

I tried to make this in test in that way:

when(Verifier.IGNORE.equals(any())).thenReturn(true);

And I also tried this:

@Mock
Verifier verifier;

@Test
public void someTest() {
    when(verifier.IGNORE.equals(any())).thenReturn(true);
}

But both don't work. How can I return true when this equals is called?

Aucun commentaire:

Enregistrer un commentaire