Skip to content

Commit bf9e183

Browse files
committed
Report tests as skipped in dry-run mode
Reporting them as successful seems misleading
1 parent ed8038c commit bf9e183

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

documentation/src/docs/asciidoc/user-guide/advanced-topics/launcher-api.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,6 @@ When running tests via the `{Launcher}` API, you can enable _dry-run mode_ by se
272272
`junit.platform.execution.dryRun.enabled` <<running-tests-config-params,
273273
configuration parameter>> to `true`. In this mode, the `{Launcher}` will not actually
274274
execute any tests but will notify registered `{TestExecutionListener}` instances as if all
275-
tests had been executed successfully. This can be useful to test changes in the
276-
configuration of a build or to verify a listener is called as expected without having to
277-
wait for all tests to be executed.
275+
tests had been skipped and their containers had been successful. This can be useful to
276+
test changes in the configuration of a build or to verify a listener is called as expected
277+
without having to wait for all tests to be executed.

junit-platform-launcher/src/main/java/org/junit/platform/launcher/LauncherConstants.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ public class LauncherConstants {
153153
*
154154
* <p>When dry-run mode is enabled, no tests will be executed. Instead, all
155155
* registered {@link TestExecutionListener TestExecutionListeners} will
156-
* receive started/finished events for all test descriptors that are part
157-
* of the discovered {@link TestPlan}. All tests will be reported as
158-
* successful. This can be useful to test changes in the configuration of a
159-
* build or to verify a listener is called as expected without having to
160-
* wait for all tests to be executed.
156+
* receive events for all test descriptors that are part of the discovered
157+
* {@link TestPlan}. All containers will be reported as successful and all
158+
* tests as skipped. This can be useful to test changes in the configuration
159+
* of a build or to verify a listener is called as expected without having
160+
* to wait for all tests to be executed.
161161
*
162162
* <p>Value must be either {@code true} or {@code false}; defaults to {@code false}.
163163
*/

junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/EngineExecutionOrchestrator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ public void preVisitContainer(TestIdentifier testIdentifier) {
110110
@Override
111111
public void visit(TestIdentifier testIdentifier) {
112112
if (!testIdentifier.isContainer()) {
113-
listener.executionStarted(testIdentifier);
114-
listener.executionFinished(testIdentifier, TestExecutionResult.successful());
113+
listener.executionSkipped(testIdentifier, "JUnit Platform dry-run mode is enabled");
115114
}
116115
}
117116

platform-tests/src/test/java/org/junit/platform/launcher/core/DefaultLauncherTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,7 @@ void dryRunModeReportsEventsForAllTestsButDoesNotExecuteThem() {
646646
inOrder.verify(listener).testPlanExecutionStarted(any());
647647
inOrder.verify(listener).executionStarted(TestIdentifier.from(engine.getEngineDescriptor()));
648648
inOrder.verify(listener).executionStarted(TestIdentifier.from(container));
649-
inOrder.verify(listener).executionStarted(TestIdentifier.from(test));
650-
inOrder.verify(listener).executionFinished(TestIdentifier.from(test), successful());
649+
inOrder.verify(listener).executionSkipped(TestIdentifier.from(test), "JUnit Platform dry-run mode is enabled");
651650
inOrder.verify(listener).executionFinished(TestIdentifier.from(container), successful());
652651
inOrder.verify(listener).executionFinished(TestIdentifier.from(engine.getEngineDescriptor()), successful());
653652
inOrder.verify(listener).testPlanExecutionFinished(any());

0 commit comments

Comments
 (0)