Skip to content

Commit

Permalink
[doc] Document renamed/old rule names
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel committed Oct 4, 2024
1 parent 5ce4d29 commit a0818d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/pages/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ The old rule names still work but are deprecated.
* [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault()

### 🚨 API Changes
* java-bestpractices
* The old rule name `JUnit4TestShouldUseAfterAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseAfterAnnotation %} instead.
* The old rule name `JUnit4TestShouldUseBeforeAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} instead.
* The old rule name `JUnit4TestShouldUseTestAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseTestAnnotation %} instead.
* The old rule name `JUnitAssertionsShouldIncludeMessage` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestAssertionsShouldIncludeMessage %} instead.
* The old rule name `JUnitTestContainsTooManyAsserts` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestContainsTooManyAsserts %} instead.
* The old rule name `JUnitTestsShouldIncludeAssert` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldIncludeAssert %} instead.


### ✨ Merged pull requests
* [#4965](https://github.com/pmd/pmd/pull/4965): \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod)
Expand Down
12 changes: 12 additions & 0 deletions pmd-java/src/main/resources/category/java/bestpractices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,8 @@ Unit assertions should include an informative message - i.e., use the three-argu
`assertEquals()`, not the two-argument version.

This rule supports tests using JUnit (3, 4 and 5) and TestNG.

Note: This rule was named JUnitAssertionsShouldIncludeMessage before PMD 7.7.0.
</description>
<priority>3</priority>
<example>
Expand Down Expand Up @@ -1268,6 +1270,8 @@ public class Foo {
Customize the maximum number of assertions used by this Rule to suit your needs.

This rule checks for JUnit (3, 4 and 5) and TestNG Tests.

Note: This rule was named JUnitTestContainsTooManyAsserts before PMD 7.7.0.
</description>
<priority>3</priority>
<example>
Expand Down Expand Up @@ -1303,6 +1307,8 @@ public class MyTestCase {
with messages provide the developer a clearer idea of what the test does.

This rule checks for JUnit (3, 4 and 5) and TestNG Tests.

Note: This rule was named JUnitTestsShouldIncludeAssert before PMD 7.7.0.
</description>
<priority>3</priority>
<example>
Expand Down Expand Up @@ -1333,6 +1339,8 @@ public class Foo {

JUnit 4 will only execute methods annotated with `@After` after running each test.
JUnit 5 introduced `@AfterEach` and `@AfterAll` annotations to execute methods after each test or after all tests in the class, respectively.

Note: This rule was named JUnit4TestShouldUseAfterAnnotation before PMD 7.7.0.
</description>
<priority>3</priority>
<properties>
Expand Down Expand Up @@ -1380,6 +1388,8 @@ public class MyTest2 {

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.

Note: This rule was named JUnit4TestShouldUseBeforeAnnotation before PMD 7.7.0.
</description>
<priority>3</priority>
<properties>
Expand Down Expand Up @@ -1426,6 +1436,8 @@ public class MyTest2 {
In JUnit 4, only methods annotated with the `@Test` annotation are executed.
In JUnit 5, one of the following annotations should be used for tests: `@Test`, `@RepeatedTest`, `@TestFactory`, `@TestTemplate` or `@ParameterizedTest`.
In TestNG, only methods annotated with the `@Test` annotation are executed.

Note: This rule was named JUnit4TestShouldUseTestAnnotation before PMD 7.7.0.
</description>
<priority>3</priority>
<properties>
Expand Down

0 comments on commit a0818d5

Please sign in to comment.