Update JUnit4TestShouldUseAfterAnnotation
This commit is contained in:
1 parent
77c05afd55
commit
4c3d237031
3 files changed
+8
-5
No files matched your search
@@ -659,9 +659,8 @@ JUnit 5 introduced @AfterEach and @AfterAll annotations to execute methods after
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ClassOrInterfaceBodyDeclaration
|
||||
[MethodDeclaration[@Name='tearDown']]
|
||||
[not(Annotation/*/Name[
|
||||
//MethodDeclaration[@Name='tearDown']
|
||||
[not(ModifierList/Annotation[
|
||||
pmd-java:typeIs('org.junit.After')
|
||||
or pmd-java:typeIs('org.junit.jupiter.api.AfterEach')
|
||||
or pmd-java:typeIs('org.junit.jupiter.api.AfterAll')
|
||||
|
||||
-1
@@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.bestpractices;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
@org.junit.Ignore("Rule has not been updated yet")
|
||||
public class JUnit4TestShouldUseAfterAnnotationTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
+6
-1
@@ -8,6 +8,7 @@
|
||||
<description>Contains tearDown</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
import org.junit.Test;
|
||||
public class Foo {
|
||||
public void tearDown() {
|
||||
}
|
||||
@@ -19,9 +20,11 @@ public class Foo {
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>Contains @tearDown</description>
|
||||
<description>Contains @After tearDown</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import org.junit.Test;
|
||||
import org.junit.After;
|
||||
public class Foo {
|
||||
@After
|
||||
public void tearDown() {
|
||||
@@ -37,6 +40,8 @@ public class Foo {
|
||||
<description>Renamed tearDown</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import org.junit.Test;
|
||||
import org.junit.After;
|
||||
public class Foo {
|
||||
@After
|
||||
public void clean() {
|
||||
|
||||
Reference in new issue
Block a user