jeudi 13 février 2020

assertEquals Vs assertTrue for boolean

You can test objects assertEquals(a,b) and assertTrue(a.equals(b)) or assertTrue(a==b) (for primitives). In this case of course assertEquals(a,b) is the only possible variant. It is null safe and more informative in case of test fault (you get exact fault not true or false).

I have a next question.

What about situation when we have only Boolean value to test?

assertEquals(true, a) and assertTrue(a)

What the difference can be?

I see the case when we check Boolean. Using assertTrue(a) is not null safe. And this is very important reason. In case of boolean don't see the difference.

Aucun commentaire:

Enregistrer un commentaire