forked from phoedos/pmd
Merge branch 'bug-1453' into pmd/5.3.x
This commit is contained in:
@ -82,11 +82,13 @@ public abstract class AbstractJUnitRule extends AbstractJavaRule {
|
|||||||
return false; // skip various inapplicable method variations
|
return false; // skip various inapplicable method variations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean result = false;
|
||||||
if (isJUnit3Class) {
|
if (isJUnit3Class) {
|
||||||
return isJUnit3Method(method);
|
result = isJUnit3Method(method);
|
||||||
} else {
|
|
||||||
return isJUnit4Method(method);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result |= isJUnit4Method(method);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isJUnit4Method(ASTMethodDeclaration method) {
|
private boolean isJUnit4Method(ASTMethodDeclaration method) {
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.sourceforge.pmd.lang.java.rule.junit;
|
package net.sourceforge.pmd.lang.java.rule.junit;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
||||||
@ -21,17 +20,15 @@ public class TestClassWithoutTestCasesRule extends AbstractJUnitRule {
|
|||||||
boolean testsFound = false;
|
boolean testsFound = false;
|
||||||
|
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
for (Iterator<ASTMethodDeclaration> it = m.iterator(); it.hasNext() && !testsFound;) {
|
for (ASTMethodDeclaration md : m) {
|
||||||
ASTMethodDeclaration md = it.next();
|
if (!isInInnerClassOrInterface(md) && isJUnitMethod(md, data)) {
|
||||||
if (!isInInnerClassOrInterface(md)
|
testsFound = true;
|
||||||
&& isJUnitMethod(md, data)) {
|
}
|
||||||
testsFound = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!testsFound) {
|
if (!testsFound) {
|
||||||
addViolation(data, node);
|
addViolation(data, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -96,6 +96,23 @@ failure case does not extend TestCase
|
|||||||
<expected-problems>0</expected-problems>
|
<expected-problems>0</expected-problems>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
public class FooTest {
|
public class FooTest {
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>#1453 False positive when the test class extends an other.</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class MyTest extends YourTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void falseMethod() {
|
||||||
|
assertFalse(0 == 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
* [#1449](https://sourceforge.net/p/pmd/bugs/1449/): false positive when casting a variable to short
|
* [#1449](https://sourceforge.net/p/pmd/bugs/1449/): false positive when casting a variable to short
|
||||||
* java-design/AccessorClassGeneration:
|
* java-design/AccessorClassGeneration:
|
||||||
* [#1452](https://sourceforge.net/p/pmd/bugs/1452/): ArrayIndexOutOfBoundsException with Annotations for AccessorClassGenerationRule
|
* [#1452](https://sourceforge.net/p/pmd/bugs/1452/): ArrayIndexOutOfBoundsException with Annotations for AccessorClassGenerationRule
|
||||||
|
* java-junit/TestClassWithoutTestCases:
|
||||||
|
* [#1453](https://sourceforge.net/p/pmd/bugs/1453/): Test Class Without Test Cases gives false positive
|
||||||
* General
|
* General
|
||||||
* [#1455](https://sourceforge.net/p/pmd/bugs/1455/): PMD doesn't handle Java 8 explicit receiver parameters
|
* [#1455](https://sourceforge.net/p/pmd/bugs/1455/): PMD doesn't handle Java 8 explicit receiver parameters
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user