diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index a89a911d51..17ffdd2ccb 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -20,7 +20,7 @@ Several rules for unit testing have been renamed to better reflect their actual * `java/bestpractices/JUnit4TestShouldUseAfterAnnotation` has been renamed to {% rule java/bestpractices/JUnitTestShouldUseAfterAnnotation %} -* `java/bestpractices/JUnit4TestShouldUseBeforeAnnotation` has been renamed to {% rule java/bestpractices/JUnitTestShouldUseBeforeAnnotation %} +* `java/bestpractices/JUnit4TestShouldUseBeforeAnnotation` has been renamed to {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} * `java/bestpractices/JUnit4TestShouldUseTestAnnotation` has been renamed to {% rule java/bestpractices/UnitTestShouldUseTestAnnotation %} diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 8356c31e49..efa61aed91 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -715,55 +715,7 @@ public class MyTest2 { - - - - -This rule detects methods called setUp() that are not properly annotated as a setup method. -This is primarily intended to assist in upgrading from JUnit 3, where setup methods were required to be called setUp(). -To a lesser extent, this may help detect omissions even under newer JUnit versions, as long as you are following this convention to name the methods. - -JUnit 4 will only execute methods annotated with @Before before all tests. -JUnit 5 introduced @BeforeEach and @BeforeAll annotations to execute methods before each test or before all tests in the class, respectively. - - 3 - - - - - - - - - - - + @@ -1462,6 +1414,54 @@ class Foo{ ]]> + + + + This rule detects methods called `setUp()` that are not properly annotated as a setup method. + This is primarily intended to assist in upgrading from JUnit 3, where setup methods were required to be called `setUp()`. + To a lesser extent, this may help detect omissions even under newer JUnit versions, as long as you are following this convention to name the methods. + + JUnit 4 will only execute methods annotated with `@Before` before all tests. + JUnit 5 introduced `@BeforeEach` and `@BeforeAll` annotations to execute methods before each test or before all tests in the class, respectively. + + 3 + + + + + + + + + + + + [java] JUnit4TestShouldUseBeforeAnnotation false positive when overriding setUp #1592 0 [java] JUnit4TestShouldUseBeforeAnnotation false positive when overriding setUp #1592 0