Testing equality or nullness with JUnit’s assertTrue()
or assertFalse()
should be simplified to the corresponding
dedicated assertion.
Noncompliant code example
Assert.assertTrue(a.equals(b));
Assert.assertTrue(a == b);
Assert.assertTrue(a == null);
Assert.assertTrue(a != null);
Assert.assertFalse(a.equals(b));
Compliant solution
Assert.assertEquals(a, b);
Assert.assertSame(a, b);
Assert.assertNull(a);
Assert.assertNotNull(a);
Assert.assertNotEquals(a, b);