All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.pmd.rules.pmd-unit-tests.UseAssertTrueInsteadOfAssertEquals.html Maven / Gradle / Ivy

Go to download

PMD is a tool that looks for potential problems like possible bugs, dead code, suboptimal code, overcomplicated expressions or duplicate code.

There is a newer version: 2.4
Show 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 - 2024 Weber Informatics LLC | Privacy Policy