Reports calls to assertion methods with “expected” and “actual” arguments of incompatible types. Such calls often indicate that there is a bug.
The inspection applies to the following methods:
- org.junit.Assert.assertEquals(), org.junit.Assert.assertNotEquals()
- org.junit.Assert.assertSame(), org.junit.Assert.assertNotSame()
- org.assertj.core.api.Assert.isEqualTo(), org.assertj.core.api.Assert.isNotEqualTo()
- org.assertj.core.api.Assert.isSameAs(), org.assertj.core.api.Assert.isNotSameAs()
The assertNotEquals() and isNotEqualTo() methods are also reported,
however they are highlighted with a weak warning to take into account the case when the equals() contract is tested.
Test samples where the warning is fired:
assertEquals("1", 1);
assertNotSame(new int[0], 0);
// weak warning, because of a possible false positive case
assertThat(foo).as("user type").isNotEqualTo(bar);