2025 init

This commit is contained in:
Romain Lefeuvre
2025-11-18 14:43:08 +01:00
commit 7155dd77be
39 changed files with 1134 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
# UnitTestContainsTooManyAsserts
*Usage:*
`pmd check -d <source code folder> -R category/java/bestpractices.xml/UnitTestContainsTooManyAsserts -format <output format>`
*Description:*
Unit tests should not contain too many asserts. Many asserts are indicative of a complex test, for which
it is harder to verify correctness. Consider breaking the test scenario into multiple, shorter test scenarios.
Customize the maximum number of assertions used by this Rule to suit your needs.
This rule checks for JUnit4, JUnit5 and TestNG Tests, as well as methods starting with "test".
*Example:*
```java
public class MyTestCase extends TestCase {
// Ok
public void testMyCaseWithOneAssert() {
boolean myVar = false;
assertFalse("should be false", myVar);
}
// Bad, too many asserts (assuming max=1)
public void testMyCaseWithMoreAsserts() {
boolean myVar = false;
assertFalse("myVar should be false", myVar);
assertEquals("should equals false", false, myVar);
}
}
```