apache / apache/maven-surefire

[SUREFIRE-1864] Excessive use of discover by the JUnitPlatformProvider

Open
#3,000 0 comments 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Leonard Brünings](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=leonard84)** opened **[SUREFIRE-1864](https://issues.apache.org/jira/browse/SUREFIRE-1864?redirect=false)** and commented

This issue is derived from https://github.com/spockframework/spock/issues/1240

The current implementation of the `JUnitPlatformProvider` together with its helper classes, especially `TestPlanScannerFilter` first make a separate discover call for each class and then another discovery request by calling execute with another `LauncherDiscoveryRequest` instead of reusing the `TestPlan` returned by a previous discovery.

 

The issue here, is that engines have to compute many things during the discovery that are then simply discarded and need to be recomputed again.

To improve this, surefire should call `org.junit.platform.launcher.core.DefaultLauncher#discover(org.junit.platform.launcher.LauncherDiscoveryRequest)` first with **all** the classes and then use the returned `TestPlan` to execute it instead of recomputing in by calling  `org.junit.platform.launcher.core.DefaultLauncher#execute(org.junit.platform.launcher.TestPlan, org.junit.platform.launcher.TestExecutionListener...)`

instead of `org.junit.platform.launcher.core.DefaultLauncher#execute(org.junit.platform.launcher.LauncherDiscoveryRequest, org.junit.platform.launcher.TestExecutionListener...)`

Alternatively, it could forego a separate discovery and only call `org.junit.platform.launcher.core.DefaultLauncher#execute(org.junit.platform.launcher.LauncherDiscoveryRequest, org.junit.platform.launcher.TestExecutionListener...)`

---

**Affects:** 3.0.0-M5

3 votes, 4 watchers

Contributor guide

Open the contributing guide

Research direction

Start with JUnitPlatformProvider and its TestPlanScannerFilter helper, then trace how DefaultLauncher discovery and execution requests are built. Compare the separate per-class discover calls with the later execute call and determine whether the returned TestPlan can be reused or discovery can be avoided. Done means eliminating the redundant engine discovery while preserving execution behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing-qa
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.