
org.sonar.l10n.pmd.rules.pmd-unit-tests.UseAssertTrueInsteadOfAssertEquals.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-pmd-plugin Show documentation
Show all versions of sonar-pmd-plugin Show documentation
Sonar-PMD is a plugin that provides coding rules from PMD.
The newest version!
When asserting a value is the same as a boolean literal, use assertTrue/assertFalse, instead of assertEquals. Example:
public class MyTestCase extends TestCase {
public void testMyCase() {
boolean myVar = true;
// Ok
assertTrue("myVar is true", myVar);
// Bad
assertEquals("myVar is true", true, myVar);
// Bad
assertEquals("myVar is false", false, myVar);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy