JUnit Malformed Declaration
ID |
java.junit_malformed_declaration |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Java |
Tags |
best-practice, junit, testing |
Description
Reports @Test methods that violate JUnit’s declaration requirements: private or static modifiers, parameters without @ParameterizedTest, or a non-void return type in JUnit 5. Such methods are silently ignored by the test runner and never execute.
Rationale
Reliability — The malformed test method will not be picked up by the test runner, giving a false sense of test coverage.