Affects PMD Version: 6.0.0
Rule:
SignatureDeclareThrowsException
Description:
SignatureDeclareThrowsException has a "IgnoreJUnitCompletely" property, which is documented as "Allow all methods in a JUnit testcase to throw Exceptions". My expectation is that "all methods" would include constructors, but setting this property to true still results in the rule firing for constructors.
Code Sample demonstrating the issue:
JUnitAnnotationTest.java
import org.junit.Test; import org.junit.Before; import org.junit.Assert; import junit.framework.TestCase; public class JUnitAnnotationTest extends TestCase { public JUnitAnnotationTest() throws Exception { } }
pmd-rules.xml
<?xml version="1.0"?> <ruleset name="Test PMD Rules" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> <description>Test PMD Rules</description> <rule ref="category/java/design.xml/SignatureDeclareThrowsException"> <properties> <property name="IgnoreJUnitCompletely" value="true"/> </properties> </rule> </ruleset>
Results:
/Users/dadams/tmp/JUnitAnnotationTest.java:7: A method/constructor should not explicitly throw java.lang.Exception
Expected: No errors.
Running PMD through: CLI & Gradle
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4