Files
VV-ISTIC-TP3/pmd-documentation/UnnecessaryBooleanAssertion.md
Romain Lefeuvre 7155dd77be 2025 init
2025-11-18 14:43:08 +01:00

742 B

UnnecessaryBooleanAssertion

Usage: pmd check -d <source code folder> -R category/java/errorprone.xml/UnnecessaryBooleanAssertion -format <output format>

Description:

A JUnit test assertion with a boolean literal is unnecessary since it always will evaluate to the same thing. Consider using flow control (in case of assertTrue(false) or similar) or simply removing statements like assertTrue(true) and assertFalse(false). If you just want a test to halt after finding an error, use the fail() method and provide an indication message of why it did.

Example:



public class SimpleTest extends TestCase {
    public void testX() {
        assertTrue(true);       // serves no real purpose
    }
}