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
PMD is a tool that looks for potential problems like possible bugs, dead code, suboptimal code, overcomplicated expressions or duplicate code.
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 - 2024 Weber Informatics LLC | Privacy Policy