forked from phoedos/pmd
#1446 False positive with JUnit4TestShouldUseBeforeAnnotation when TestNG is used
This commit is contained in:
@ -310,6 +310,7 @@ JUnit 4 skips the setUp method and executes all methods annotated with @Before b
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//CompilationUnit[not(ImportDeclaration/Name[starts-with(@Image, "org.testng")])]
|
||||
//ClassOrInterfaceBodyDeclaration[MethodDeclaration/MethodDeclarator[@Image='setUp']]
|
||||
[count(Annotation//Name[@Image='Before'])=0]
|
||||
]]>
|
||||
@ -346,6 +347,7 @@ JUnit 4 skips the tearDown method and executes all methods annotated with @After
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//CompilationUnit[not(ImportDeclaration/Name[starts-with(@Image, "org.testng")])]
|
||||
//ClassOrInterfaceBodyDeclaration[MethodDeclaration/MethodDeclarator[@Image='tearDown']]
|
||||
[count(Annotation//Name[@Image='After'])=0]
|
||||
]]>
|
||||
|
@ -47,4 +47,18 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>#1446 False positive with JUnit4TestShouldUseBeforeAnnotation when TestNG is used</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import org.testng.annotations.AfterMethod;
|
||||
|
||||
public class Foo {
|
||||
@AfterMethod
|
||||
public void tearDown(Method m) {
|
||||
//...
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
@ -56,6 +56,20 @@ public class Foo {
|
||||
public void setUp() {
|
||||
esSetup.execute(EsSetup.deleteAll());
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>#1446 False positive with JUnit4TestShouldUseBeforeAnnotation when TestNG is used</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
||||
public class Foo {
|
||||
@BeforeMethod
|
||||
public void setUp(Method m) {
|
||||
//...
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
@ -25,6 +25,8 @@
|
||||
* [#1440](https://sourceforge.net/p/pmd/bugs/1440/): NPE in AvoidCallingFinalize
|
||||
* java-imports/UnnecessaryFullyQualifiedName
|
||||
* [#1436](https://sourceforge.net/p/pmd/bugs/1436/): UnnecessaryFullyQualifiedName false positive on clashing static imports with enums
|
||||
* java-migrating/JUnit4TestShouldUseBeforeAnnotation
|
||||
* [#1446](https://sourceforge.net/p/pmd/bugs/1446/): False positive with JUnit4TestShouldUseBeforeAnnotation when TestNG is used
|
||||
* java-naming/SuspiciousEqualsMethodName
|
||||
* [#1431](https://sourceforge.net/p/pmd/bugs/1431/): SuspiciousEqualsMethodName false positive
|
||||
* java-optimizations/RedundantFieldInitializer
|
||||
|
Reference in New Issue
Block a user