[java] New rule: AssertStatementInTest#6557
Conversation
|
Compared to main: (comment created at 2026-05-13 23:56:52+00:00 for 93533b8) |
adangel
left a comment
There was a problem hiding this comment.
Thanks!
Can you additionally add a test case for Junit5 - as we mention it in the rule description, we should verify it.
Also, could you add a section in the release_notes describing the new rule?
Something like
pmd/docs/pages/release_notes.md
Lines 25 to 31 in e9787d8
Co-authored-by: Andreas Dangel <[email protected]>
Co-authored-by: Andreas Dangel <[email protected]>
Co-authored-by: Andreas Dangel <[email protected]>
Co-authored-by: Andreas Dangel <[email protected]>
Added a section for new and changed rules in release notes.
Updated the rule path for the Java assert statement detection.
| * {% rule java/codestyle/UnnecessaryModifier %} | ||
| * {% rule java/design/UseUtilityClass %} | ||
|
|
||
| ### 🌟️ New and Changed Rules |
There was a problem hiding this comment.
Thanks for providing the text for the release notes.
I'll move this up when merging - this section should be before "Changed rules"...
|
Oh - at some point, we should document, that SignatureDeclareThrowsException ignores test methods... we have an option for junit3. But for me it is not clear in the documentation, that it always ignores any test framework related methods. |
Describe the PR
The new rule suggests using framework assertions instead of
assertstatement in tests.The proposed implementation enforces that both in test methods and test setup/teardown methods, since in both cases the error messages are processed by the test runner.
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)