Skip to content

Commit

Permalink
Report tests as skipped in dry-run mode
Browse files Browse the repository at this point in the history
Reporting them as successful seems misleading
  • Loading branch information
marcphilipp committed Jul 6, 2023
1 parent ed8038c commit bf9e183
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,6 @@ When running tests via the `{Launcher}` API, you can enable _dry-run mode_ by se
`junit.platform.execution.dryRun.enabled` <<running-tests-config-params,
configuration parameter>> to `true`. In this mode, the `{Launcher}` will not actually
execute any tests but will notify registered `{TestExecutionListener}` instances as if all
tests had been executed successfully. This can be useful to test changes in the
configuration of a build or to verify a listener is called as expected without having to
wait for all tests to be executed.
tests had been skipped and their containers had been successful. This can be useful to
test changes in the configuration of a build or to verify a listener is called as expected
without having to wait for all tests to be executed.
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ public class LauncherConstants {
*
* <p>When dry-run mode is enabled, no tests will be executed. Instead, all
* registered {@link TestExecutionListener TestExecutionListeners} will
* receive started/finished events for all test descriptors that are part
* of the discovered {@link TestPlan}. All tests will be reported as
* successful. This can be useful to test changes in the configuration of a
* build or to verify a listener is called as expected without having to
* wait for all tests to be executed.
* receive events for all test descriptors that are part of the discovered
* {@link TestPlan}. All containers will be reported as successful and all
* tests as skipped. This can be useful to test changes in the configuration
* of a build or to verify a listener is called as expected without having
* to wait for all tests to be executed.
*
* <p>Value must be either {@code true} or {@code false}; defaults to {@code false}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public void preVisitContainer(TestIdentifier testIdentifier) {
@Override
public void visit(TestIdentifier testIdentifier) {
if (!testIdentifier.isContainer()) {
listener.executionStarted(testIdentifier);
listener.executionFinished(testIdentifier, TestExecutionResult.successful());
listener.executionSkipped(testIdentifier, "JUnit Platform dry-run mode is enabled");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,7 @@ void dryRunModeReportsEventsForAllTestsButDoesNotExecuteThem() {
inOrder.verify(listener).testPlanExecutionStarted(any());
inOrder.verify(listener).executionStarted(TestIdentifier.from(engine.getEngineDescriptor()));
inOrder.verify(listener).executionStarted(TestIdentifier.from(container));
inOrder.verify(listener).executionStarted(TestIdentifier.from(test));
inOrder.verify(listener).executionFinished(TestIdentifier.from(test), successful());
inOrder.verify(listener).executionSkipped(TestIdentifier.from(test), "JUnit Platform dry-run mode is enabled");
inOrder.verify(listener).executionFinished(TestIdentifier.from(container), successful());
inOrder.verify(listener).executionFinished(TestIdentifier.from(engine.getEngineDescriptor()), successful());
inOrder.verify(listener).testPlanExecutionFinished(any());
Expand Down

0 comments on commit bf9e183

Please sign in to comment.