-
Notifications
You must be signed in to change notification settings - Fork 78
/
junit5.yml
executable file
·331 lines (327 loc) · 13 KB
/
junit5.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#
# Copyright 2021 the original author or authors.
# <p>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# <p>
# https://www.apache.org/licenses/LICENSE-2.0
# <p>
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.JUnit5BestPractices
displayName: JUnit Jupiter best practices
description: Applies best practices to tests.
tags:
- testing
- junit
recipeList:
- org.openrewrite.java.testing.junit5.JUnit4to5Migration
- org.openrewrite.java.testing.junit5.StaticImports
- org.openrewrite.java.testing.junit5.CleanupAssertions
- org.openrewrite.java.testing.cleanup.RemoveTestPrefix
- org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
- org.openrewrite.java.testing.junit5.AddParameterizedTestAnnotation
- org.openrewrite.java.testing.junit5.RemoveDuplicateTestTemplates
- org.openrewrite.java.testing.junit5.RemoveTryCatchFailBlocks
- org.openrewrite.java.testing.junit5.LifecycleNonPrivate
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.StaticImports
displayName: Statically import JUnit Jupiter assertions
description: Always use a static import for assertion methods.
tags:
- testing
- junit
recipeList:
- org.openrewrite.java.UseStaticImport:
methodPattern: "org.junit.jupiter.api.Assertions *(..)"
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.JUnit4to5Migration
displayName: JUnit Jupiter migration from JUnit 4.x
description: Migrates JUnit 4.x tests to JUnit Jupiter.
tags:
- testing
- junit
recipeList:
- org.openrewrite.java.testing.junit5.UseWiremockExtension
- org.openrewrite.java.testing.junit5.IgnoreToDisabled
- org.openrewrite.java.testing.junit5.ThrowingRunnableToExecutable
- org.openrewrite.java.testing.junit5.RemoveObsoleteRunners:
obsoleteRunners:
- org.junit.runners.JUnit4
- org.junit.runners.BlockJUnit4ClassRunner
- org.openrewrite.maven.RemovePluginDependency:
pluginGroupId: org.apache.maven.plugins
pluginArtifactId: maven-surefire-plugin
groupId: org.apache.maven.surefire
artifactId: surefire-junit*
- org.openrewrite.java.testing.junit5.UpgradeSurefirePlugin
- org.openrewrite.java.testing.junit5.UseHamcrestAssertThat
- org.openrewrite.java.testing.junit5.MigrateAssumptions
- org.openrewrite.java.testing.junit5.UseMockitoExtension
- org.openrewrite.java.testing.junit5.UseTestMethodOrder
- org.openrewrite.java.testing.junit5.MigrateJUnitTestCase
- org.openrewrite.java.ChangeMethodName:
methodPattern: "org.junit.Assert assertEquals(.., Object[], Object[])"
newMethodName: assertArrayEquals
- org.openrewrite.java.testing.junit5.AssertToAssertions
- org.openrewrite.java.testing.junit5.CategoryToTag
- org.openrewrite.java.testing.junit5.CleanupJUnitImports
- org.openrewrite.java.testing.junit5.TemporaryFolderToTempDir
- org.openrewrite.java.testing.junit5.TempDirNonFinal
- org.openrewrite.java.testing.junit5.TestRuleToTestInfo
- org.openrewrite.java.testing.junit5.UpdateBeforeAfterAnnotations
- org.openrewrite.java.testing.junit5.UpdateTestAnnotation
- org.openrewrite.java.testing.junit5.AddMissingTestBeforeAfterAnnotations
- org.openrewrite.java.testing.junit5.ParameterizedRunnerToParameterized
- org.openrewrite.java.testing.junit5.JUnitParamsRunnerToParameterized
- org.openrewrite.java.testing.junit5.ExpectedExceptionToAssertThrows
- org.openrewrite.java.testing.junit5.UpdateMockWebServer
- org.openrewrite.java.testing.junit5.VertxUnitToVertxJunit5
- org.openrewrite.java.testing.junit5.EnclosedToNested
- org.openrewrite.java.testing.junit5.AddMissingNested
- org.openrewrite.java.testing.hamcrest.AddHamcrestIfUsed
- org.openrewrite.java.testing.junit5.UseXMLUnitLegacy
- org.openrewrite.java.dependencies.RemoveDependency:
groupId: junit
artifactId: junit
- org.openrewrite.maven.ExcludeDependency:
groupId: junit
artifactId: junit
# Workaround for https://github.com/testcontainers/testcontainers-java/issues/970:
- org.openrewrite.maven.RemoveExclusion:
groupId: org.testcontainers
artifactId: testcontainers
exclusionGroupId: junit
exclusionArtifactId: junit
# Similar for https://github.com/openrewrite/rewrite-testing-frameworks/issues/477
- org.openrewrite.maven.RemoveExclusion:
groupId: org.springframework.boot
artifactId: spring-boot-testcontainers
exclusionGroupId: junit
exclusionArtifactId: junit
- org.openrewrite.java.dependencies.RemoveDependency:
groupId: org.junit.vintage
artifactId: junit-vintage-engine
- org.openrewrite.maven.ExcludeDependency:
groupId: org.junit.vintage
artifactId: junit-vintage-engine
- org.openrewrite.java.testing.junit5.AddJupiterDependencies
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.junit.jupiter
artifactId: junit-jupiter-params
version: 5.x
onlyIfUsing: org.junit.jupiter.params.ParameterizedTest
acceptTransitive: true
scope: test
- org.openrewrite.java.dependencies.UpgradeDependencyVersion:
groupId: org.mockito
artifactId: "*"
newVersion: 3.x
overrideManagedVersion: false
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.mockito
artifactId: mockito-junit-jupiter
version: 3.x
onlyIfUsing: org.mockito..*
acceptTransitive: true
scope: test
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.apache.maven.plugins
artifactId: maven-surefire-plugin
newVersion: 3.1.x
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.apache.maven.plugins
artifactId: maven-failsafe-plugin
newVersion: 3.1.x
- org.openrewrite.java.testing.junit5.GradleUseJunitJupiter
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.UseHamcrestAssertThat
displayName: Use `MatcherAssert#assertThat(..)`
description: JUnit 4's `Assert#assertThat(..)` This method was deprecated in JUnit 4 and removed in JUnit Jupiter.
tags:
- testing
- junit
- hamcrest
recipeList:
- org.openrewrite.java.ChangeMethodTargetToStatic:
methodPattern: org.junit.Assert assertThat(..)
fullyQualifiedTargetTypeName: org.hamcrest.MatcherAssert
- org.openrewrite.java.UseStaticImport:
methodPattern: org.hamcrest.MatcherAssert assertThat(..)
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.MigrateAssumptions
displayName: Use `Assertions#assume*(..)` and Hamcrest's `MatcherAssume#assume*(..)`
description: Many of JUnit 4's `Assume#assume(..)` methods have no direct counterpart in JUnit 5 and require Hamcrest JUnit's `MatcherAssume`.
tags:
- testing
- junit
- hamcrest
recipeList:
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.hamcrest
artifactId: hamcrest-junit
version: 2.x
scope: test
onlyIfUsing: org.junit.Assume
acceptTransitive: true
- org.openrewrite.java.ChangeMethodTargetToStatic:
methodPattern: org.junit.Assume assumeThat(..)
fullyQualifiedTargetTypeName: org.hamcrest.junit.MatcherAssume
- org.openrewrite.java.ReorderMethodArguments:
methodPattern: org.junit.Assume assume*(String, boolean)
oldParameterNames:
- message
- assumption
newParameterNames:
- assumption
- message
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.junit.Assume
newFullyQualifiedTypeName: org.junit.jupiter.api.Assumptions
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.UseMockitoExtension
displayName: Use Mockito JUnit Jupiter extension
description: Migrate uses of `@RunWith(MockitoJUnitRunner.class)` (and similar annotations) to `@ExtendWith(MockitoExtension.class)`.
tags:
- testing
- junit
- mockito
recipeList:
- org.openrewrite.java.testing.mockito.Mockito1to4Migration
- org.openrewrite.java.testing.mockito.MockitoJUnitRunnerSilentToExtension
- org.openrewrite.java.testing.junit5.RunnerToExtension:
runners:
- org.mockito.runners.MockitoJUnitRunner
- org.mockito.junit.MockitoJUnitRunner
- org.mockito.runners.MockitoJUnit44Runner
- org.mockito.junit.MockitoJUnit44Runner
extension: org.mockito.junit.jupiter.MockitoExtension
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.IgnoreToDisabled
displayName: Use JUnit Jupiter `@Disabled`
description: Migrates JUnit 4.x `@Ignore` to JUnit Jupiter `@Disabled`.
tags:
- testing
- junit
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.junit.Ignore
newFullyQualifiedTypeName: org.junit.jupiter.api.Disabled
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.ThrowingRunnableToExecutable
displayName: Use JUnit Jupiter `Executable`
description: Migrates JUnit 4.x `ThrowingRunnable` to JUnit Jupiter `Executable`.
tags:
- testing
- junit
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.junit.function.ThrowingRunnable
newFullyQualifiedTypeName: org.junit.jupiter.api.function.Executable
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.VertxUnitToVertxJunit5
displayName: Use Vert.x JUnit 5 Extension
description: Migrates Vert.x `@RunWith` `VertxUnitRunner` to the JUnit Jupiter `@ExtendWith` `VertxExtension`.
tags:
- testing
- junit
recipeList:
- org.openrewrite.java.testing.junit5.RunnerToExtension:
runners:
- org.vertx.testtools.VertxUnitRunner
extension: org.vertx.testtools.VertxExtension
- org.openrewrite.java.dependencies.AddDependency:
groupId: io.vertx
artifactId: vertx-junit5
version: 4.x
onlyIfUsing: io.vertx.junit5.VertxExtension
acceptTransitive: true
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.UpgradeOkHttpMockWebServer
displayName: Use OkHttp 3 MockWebServer for JUnit 5
description: Migrates OkHttp 3 `MockWebServer` to enable JUnit Jupiter Extension support
tags:
- testing
- junit
- okhttp
recipeList:
- org.openrewrite.java.ChangePackage:
oldPackageName: okhttp3.mockwebserver
newPackageName: mockwebserver3
recursive: true
- org.openrewrite.java.dependencies.ChangeDependency:
oldGroupId: com.squareup.okhttp3
oldArtifactId: mockwebserver
newArtifactId: mockwebserver3-junit5
newVersion: 5.0.0-alpha.11
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.CleanupAssertions
displayName: Clean Up Assertions
description: Simplifies JUnit Jupiter assertions to their most-direct equivalents
tags:
- testing
- junit
recipeList:
- org.openrewrite.java.testing.cleanup.AssertTrueNegationToAssertFalse
- org.openrewrite.java.testing.cleanup.AssertFalseNegationToAssertTrue
- org.openrewrite.java.testing.cleanup.AssertTrueEqualsToAssertEquals
- org.openrewrite.java.testing.cleanup.AssertTrueComparisonToAssertEquals
- org.openrewrite.java.testing.cleanup.AssertFalseEqualsToAssertNotEquals
- org.openrewrite.java.testing.cleanup.AssertEqualsNullToAssertNull
- org.openrewrite.java.testing.cleanup.AssertFalseNullToAssertNotNull
- org.openrewrite.java.testing.cleanup.AssertEqualsBooleanToAssertBoolean
- org.openrewrite.java.testing.cleanup.AssertNotEqualsBooleanToAssertBoolean
- org.openrewrite.java.testing.cleanup.AssertionsArgumentOrder
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.UseXMLUnitLegacy
displayName: Use XMLUnit Legacy for JUnit 5
description: Migrates XMLUnit 1.x to XMLUnit legacy 2.x
tags:
- testing
- junit
- xmlunit
recipeList:
- org.openrewrite.java.dependencies.ChangeDependency:
oldGroupId: xmlunit
oldArtifactId: xmlunit
newGroupId: org.xmlunit
newArtifactId: xmlunit-legacy
newVersion: 2.x
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.junit5.UpgradeSurefirePlugin
displayName: Upgrade Surefire Plugin
description: Upgrades the Maven Surefire Plugin to the latest version if still using an older Maven version.
preconditions:
- org.openrewrite.java.search.HasBuildToolVersion:
type: Maven
version: 0.0.1-3.5.4
recipeList:
- org.openrewrite.maven.AddPlugin:
groupId: org.apache.maven.plugins
artifactId: maven-surefire-plugin
version: 3.2.5
- org.openrewrite.maven.AddPluginDependency:
pluginGroupId: org.apache.maven.plugins
pluginArtifactId: maven-surefire-plugin
groupId: org.junit.platform
artifactId: junit-platform-surefire-provider
version: 1.1.0