Skip to content

Commit db52d28

Browse files
authored
Separate best practices for JUnit 5, JUnit 6 and Jupiter (#828)
* Separate best practices for JUnit 5, JUnit 6 and Jupiter * Fix display name for JUnit 6 best practices * Create a separate shared junit-jupiter.yml
1 parent 1bb6616 commit db52d28

File tree

3 files changed

+57
-18
lines changed

3 files changed

+57
-18
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# Copyright 2025 the original author or authors.
3+
# <p>
4+
# Licensed under the Moderne Source Available License (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# <p>
8+
# https://docs.moderne.io/licensing/moderne-source-available-license
9+
# <p>
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
---
18+
type: specs.openrewrite.org/v1beta/recipe
19+
name: org.openrewrite.java.testing.junit.JupiterBestPractices
20+
displayName: JUnit Jupiter best practices
21+
description: Applies best practices to tests.
22+
tags:
23+
- testing
24+
- junit
25+
recipeList:
26+
# Included by both `JUnit6BestPractices` and `JUnit5BestPractices`, so avoid adding upgrade recipes here to run twice
27+
- org.openrewrite.java.testing.hamcrest.MigrateHamcrestToJUnit5
28+
- org.openrewrite.java.testing.junit5.StaticImports
29+
- org.openrewrite.java.testing.junit5.CleanupAssertions
30+
- org.openrewrite.java.testing.junit5.CsvSourceToValueSource
31+
- org.openrewrite.java.testing.cleanup.AssertLiteralBooleanToFailRecipes
32+
- org.openrewrite.java.testing.cleanup.AssertLiteralBooleanRemovedRecipe
33+
- org.openrewrite.java.testing.cleanup.RemoveTestPrefix
34+
- org.openrewrite.java.testing.cleanup.SimplifyTestThrows
35+
- org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
36+
- org.openrewrite.java.testing.cleanup.TestMethodsShouldBeVoid
37+
- org.openrewrite.java.testing.junit5.AddParameterizedTestAnnotation
38+
- org.openrewrite.java.testing.junit5.RemoveDuplicateTestTemplates
39+
- org.openrewrite.java.testing.junit5.RemoveTryCatchFailBlocks
40+
- org.openrewrite.java.testing.junit5.LifecycleNonPrivate
41+
- org.openrewrite.java.testing.junit5.AssertThrowsOnLastStatement
42+
- org.openrewrite.java.testing.junit5.AssertTrueInstanceofToAssertInstanceOf
43+
- org.openrewrite.java.testing.junit5.UseAssertSame

src/main/resources/META-INF/rewrite/junit5.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,15 @@
1717
---
1818
type: specs.openrewrite.org/v1beta/recipe
1919
name: org.openrewrite.java.testing.junit5.JUnit5BestPractices
20-
displayName: JUnit Jupiter best practices
20+
displayName: JUnit 5 best practices
2121
description: Applies best practices to tests.
2222
tags:
2323
- testing
2424
- junit
2525
recipeList:
2626
- org.openrewrite.java.testing.junit5.JUnit4to5Migration
2727
- org.openrewrite.java.testing.junit5.UpgradeToJUnit514
28-
- org.openrewrite.java.testing.hamcrest.MigrateHamcrestToJUnit5
29-
- org.openrewrite.java.testing.junit5.StaticImports
30-
- org.openrewrite.java.testing.junit5.CleanupAssertions
31-
- org.openrewrite.java.testing.junit5.CsvSourceToValueSource
32-
- org.openrewrite.java.testing.cleanup.AssertLiteralBooleanToFailRecipes
33-
- org.openrewrite.java.testing.cleanup.AssertLiteralBooleanRemovedRecipe
34-
- org.openrewrite.java.testing.cleanup.RemoveTestPrefix
35-
- org.openrewrite.java.testing.cleanup.SimplifyTestThrows
36-
- org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
37-
- org.openrewrite.java.testing.cleanup.TestMethodsShouldBeVoid
38-
- org.openrewrite.java.testing.junit5.AddParameterizedTestAnnotation
39-
- org.openrewrite.java.testing.junit5.RemoveDuplicateTestTemplates
40-
- org.openrewrite.java.testing.junit5.RemoveTryCatchFailBlocks
41-
- org.openrewrite.java.testing.junit5.LifecycleNonPrivate
42-
- org.openrewrite.java.testing.junit5.AssertThrowsOnLastStatement
43-
- org.openrewrite.java.testing.junit5.AssertTrueInstanceofToAssertInstanceOf
44-
- org.openrewrite.java.testing.junit5.UseAssertSame
28+
- org.openrewrite.java.testing.junit.JupiterBestPractices
4529
---
4630
type: specs.openrewrite.org/v1beta/recipe
4731
name: org.openrewrite.java.testing.junit5.StaticImports

src/main/resources/META-INF/rewrite/junit6.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
# limitations under the License.
1515
#
1616

17+
---
18+
type: specs.openrewrite.org/v1beta/recipe
19+
name: org.openrewrite.java.testing.junit.JUnit6BestPractices
20+
displayName: JUnit 6 best practices
21+
description: Applies best practices to tests.
22+
tags:
23+
- testing
24+
- junit
25+
recipeList:
26+
- org.openrewrite.java.testing.junit6.JUnit5to6Migration
27+
- org.openrewrite.java.testing.junit.JupiterBestPractices
28+
1729
---
1830
type: specs.openrewrite.org/v1beta/recipe
1931
name: org.openrewrite.java.testing.junit6.JUnit5to6Migration

0 commit comments

Comments
 (0)