Skip to content

Commit f8f6281

Browse files
committed
Deprecate junit-vintage-engine to clarify its purpose
1 parent 8388b2f commit f8f6281

File tree

16 files changed

+102
-33
lines changed

16 files changed

+102
-33
lines changed

documentation/documentation.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ tasks {
165165
args.addAll("--config=junit.platform.reporting.open.xml.enabled=true")
166166
args.addAll("--config=junit.platform.output.capture.stdout=true")
167167
args.addAll("--config=junit.platform.output.capture.stderr=true")
168-
args.addAll("--config=junit.platform.discovery.issue.severity.critical=info")
168+
args.addAll("--config=junit.platform.discovery.issue.severity.critical=warn")
169169
outputs.dir(consoleLauncherTestReportsDir)
170170
argumentProviders.add(CommandLineArgumentProvider {
171171
listOf(
@@ -202,6 +202,7 @@ tasks {
202202
(options as JUnitPlatformOptions).apply {
203203
includeEngines("junit-vintage")
204204
includeTags("timeout")
205+
systemProperty("junit.platform.discovery.issue.severity.critical", "warn")
205206
}
206207
}
207208

documentation/src/docs/asciidoc/release-notes/release-notes-6.0.0-M1.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ repository on GitHub.
132132
[[release-notes-6.0.0-M1-junit-vintage-deprecations-and-breaking-changes]]
133133
==== Deprecations and Breaking Changes
134134

135-
* ❓
135+
* The JUnit Vintage engine is now deprecated and will report an INFO level discovery issue
136+
when it finds at least one JUnit 4 test class. For now, the intent of the deprecation is
137+
not to signal removal in the next major version but to clarify the intended purpose of
138+
the engine. It should only be used temporarily while migrating tests to JUnit Jupiter or
139+
another testing framework with native JUnit Platform support.
136140

137141
[[release-notes-6.0.0-M1-junit-vintage-new-features-and-improvements]]
138142
==== New Features and Improvements

junit-vintage-engine/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @provides org.junit.platform.engine.TestEngine The {@code VintageTestEngine}
1717
* runs JUnit 3 and 4 based tests on the platform.
1818
*/
19+
@SuppressWarnings("deprecation")
1920
module org.junit.vintage.engine {
2021

2122
requires static org.apiguardian.api;

junit-vintage-engine/src/main/java/org/junit/vintage/engine/Constants.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@
1010

1111
package org.junit.vintage.engine;
1212

13+
import static org.apiguardian.api.API.Status.DEPRECATED;
1314
import static org.apiguardian.api.API.Status.EXPERIMENTAL;
14-
import static org.apiguardian.api.API.Status.STABLE;
1515

1616
import org.apiguardian.api.API;
1717

1818
/**
1919
* Collection of constants related to the {@link VintageTestEngine}.
2020
*
21-
* @since 5.12
21+
* @deprecated Should only be used temporarily while migrating tests to JUnit
22+
* Jupiter or another testing framework with native JUnit Platform support
2223
*/
23-
@API(status = STABLE, since = "5.12")
24+
@Deprecated(since = "6.0")
25+
@API(status = DEPRECATED, since = "6.0")
2426
public final class Constants {
2527

2628
/**

junit-vintage-engine/src/main/java/org/junit/vintage/engine/VintageTestEngine.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
package org.junit.vintage.engine;
1212

13-
import static org.apiguardian.api.API.Status.INTERNAL;
13+
import static org.apiguardian.api.API.Status.DEPRECATED;
1414
import static org.junit.platform.engine.TestExecutionResult.successful;
1515
import static org.junit.vintage.engine.descriptor.VintageTestDescriptor.ENGINE_ID;
1616

@@ -31,8 +31,11 @@
3131
* The JUnit Vintage {@link TestEngine}.
3232
*
3333
* @since 4.12
34+
* @deprecated Should only be used temporarily while migrating tests to JUnit
35+
* Jupiter or another testing framework with native JUnit Platform support
3436
*/
35-
@API(status = INTERNAL, since = "4.12")
37+
@Deprecated(since = "6.0")
38+
@API(status = DEPRECATED, since = "6.0")
3639
public final class VintageTestEngine implements TestEngine {
3740

3841
@Override

junit-vintage-engine/src/main/java/org/junit/vintage/engine/discovery/VintageDiscoverer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import org.apiguardian.api.API;
1616
import org.junit.platform.commons.support.scanning.ClassFilter;
17+
import org.junit.platform.engine.DiscoveryIssue;
1718
import org.junit.platform.engine.EngineDiscoveryRequest;
1819
import org.junit.platform.engine.TestDescriptor;
1920
import org.junit.platform.engine.UniqueId;
@@ -45,6 +46,13 @@ public VintageEngineDescriptor discover(EngineDiscoveryRequest discoveryRequest,
4546
RunnerTestDescriptor runnerTestDescriptor = (RunnerTestDescriptor) testDescriptor;
4647
postProcessor.applyFiltersAndCreateDescendants(runnerTestDescriptor);
4748
}
49+
if (!engineDescriptor.getChildren().isEmpty()) {
50+
var issue = DiscoveryIssue.create(DiscoveryIssue.Severity.INFO, //
51+
"The JUnit Vintage engine is deprecated and should only be " //
52+
+ "used temporarily while migrating tests to JUnit Jupiter or another testing " //
53+
+ "framework with native JUnit Platform support.");
54+
discoveryRequest.getDiscoveryListener().issueEncountered(uniqueId, issue);
55+
}
4856
return engineDescriptor;
4957
}
5058

junit-vintage-engine/src/main/java/org/junit/vintage/engine/execution/VintageExecutor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
import static java.util.Objects.requireNonNullElse;
1414
import static org.apiguardian.api.API.Status.INTERNAL;
15-
import static org.junit.vintage.engine.Constants.PARALLEL_CLASS_EXECUTION;
16-
import static org.junit.vintage.engine.Constants.PARALLEL_EXECUTION_ENABLED;
17-
import static org.junit.vintage.engine.Constants.PARALLEL_METHOD_EXECUTION;
18-
import static org.junit.vintage.engine.Constants.PARALLEL_POOL_SIZE;
1915

2016
import java.util.ArrayList;
2117
import java.util.Iterator;
@@ -34,12 +30,14 @@
3430
import org.junit.platform.engine.EngineExecutionListener;
3531
import org.junit.platform.engine.ExecutionRequest;
3632
import org.junit.platform.engine.TestDescriptor;
33+
import org.junit.vintage.engine.Constants;
3734
import org.junit.vintage.engine.descriptor.RunnerTestDescriptor;
3835
import org.junit.vintage.engine.descriptor.VintageEngineDescriptor;
3936

4037
/**
4138
* @since 5.12
4239
*/
40+
@SuppressWarnings({ "deprecation", "RedundantSuppression" })
4341
@API(status = INTERNAL, since = "5.12")
4442
public class VintageExecutor {
4543

@@ -62,9 +60,11 @@ public VintageExecutor(VintageEngineDescriptor engineDescriptor, EngineExecution
6260
this.engineExecutionListener = engineExecutionListener;
6361
this.request = request;
6462
this.parallelExecutionEnabled = request.getConfigurationParameters().getBoolean(
65-
PARALLEL_EXECUTION_ENABLED).orElse(false);
66-
this.classes = request.getConfigurationParameters().getBoolean(PARALLEL_CLASS_EXECUTION).orElse(false);
67-
this.methods = request.getConfigurationParameters().getBoolean(PARALLEL_METHOD_EXECUTION).orElse(false);
63+
Constants.PARALLEL_EXECUTION_ENABLED).orElse(false);
64+
this.classes = request.getConfigurationParameters().getBoolean(Constants.PARALLEL_CLASS_EXECUTION).orElse(
65+
false);
66+
this.methods = request.getConfigurationParameters().getBoolean(Constants.PARALLEL_METHOD_EXECUTION).orElse(
67+
false);
6868
}
6969

7070
public void executeAllChildren() {
@@ -110,7 +110,7 @@ private boolean executeInParallel() {
110110
}
111111

112112
private int getThreadPoolSize() {
113-
Optional<String> optionalPoolSize = request.getConfigurationParameters().get(PARALLEL_POOL_SIZE);
113+
Optional<String> optionalPoolSize = request.getConfigurationParameters().get(Constants.PARALLEL_POOL_SIZE);
114114
if (optionalPoolSize.isPresent()) {
115115
try {
116116
int poolSize = Integer.parseInt(optionalPoolSize.get());

junit-vintage-engine/src/test/java/org/junit/vintage/engine/JUnit4ParameterizedTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ private void executeTests(DiscoverySelector selector) {
6363
request()
6464
.selectors(selector)
6565
.filters(includeEngines("junit-vintage"))
66+
.enableImplicitConfigurationParameters(false)
6667
.build()
6768
);
6869
// @formatter:on

junit-vintage-engine/src/test/java/org/junit/vintage/engine/VintageLauncherIntegrationTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult
280280
}
281281

282282
private LauncherDiscoveryRequest toRequest(LauncherDiscoveryRequestBuilder requestBuilder) {
283-
return requestBuilder.filters(includeEngines(ENGINE_ID)).build();
283+
return requestBuilder.filters(includeEngines(ENGINE_ID)) //
284+
.enableImplicitConfigurationParameters(false) //
285+
.build();
284286
}
285287

286288
}

junit-vintage-engine/src/test/java/org/junit/vintage/engine/VintageTestEngineBasicTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*
2121
* @since 4.12
2222
*/
23+
@SuppressWarnings("deprecation")
2324
class VintageTestEngineBasicTests {
2425

2526
private final VintageTestEngine vintage = new VintageTestEngine();

0 commit comments

Comments
 (0)