Run multiple selected test methods in a single JVM (#1836)#1862
Merged
wenytang-ms merged 10 commits intomainfrom May 8, 2026
Merged
Run multiple selected test methods in a single JVM (#1836)#1862wenytang-ms merged 10 commits intomainfrom
wenytang-ms merged 10 commits intomainfrom
Conversation
When several test methods of the same class are selected in the Test Explorer, vscode-java-test currently launches one JVM per method, which makes Spring-style tests (where each JVM rebuilds the ApplicationContext in @BeforeAll) extremely slow. Group methods of the same class into one launch and rely on the new 'Class:method' line format supported by the bundled Eclipse JDT JUnit runtime so that all selected methods are discovered inside a single JVM, sharing per-class @BeforeAll/@afterall lifecycle and any cached fixture (e.g. Spring ApplicationContext). Methods restricted to a single invocation (uniqueId) keep their own launch, since the underlying protocol carries at most one uniqueId per JVM.
Contributor
Author
|
depends on eclipse-jdt/eclipse.jdt.ui#2975 |
Upstream eclipse.jdt.ui#2975 ships the new multi-method dispatch in org.eclipse.jdt.junit.runtime 3.8.100. Replace the placeholder threshold so the capability gate falls back to the legacy per-method launch path when run against older JDT-LS versions.
There was a problem hiding this comment.
Pull request overview
This PR improves performance when running multiple selected test methods from the same class by batching them into a single JVM launch (to reuse per-class lifecycle and cached fixtures like Spring’s ApplicationContext). It also adds a compatibility fallback: when the bundled Eclipse JDT JUnit runtime is too old to support the new multi-method Class:method line format, the extension silently retries by launching each method in its own JVM.
Changes:
- Batch method-level selections by parent class (while keeping
uniqueId-restricted invocations isolated) and exportmergeTestMethodsfor unit testing. - Add a TypeScript-side marker-based detection to silently fall back to per-method launches on legacy JDT-LS.
- Add Java-side detection of JUnit runtime capability/version and emit a marked error to trigger the fallback; write multi-method
Class:methodentries to-testNameFile.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/suite/testController.mergeTestMethods.test.ts | Adds unit tests covering method batching, class upgrade, and uniqueId isolation. |
| src/controller/testController.ts | Implements method batching logic, adds silent fallback retry flow, and introduces isolated per-item launch helper. |
| src/constants.ts | Introduces the shared marker prefix constant used to detect legacy multi-method support. |
| java-extension/.../JUnitLaunchUtils.java | Adds runtime bundle version detection and the marker constant on the Java side. |
| java-extension/.../JUnitLaunchConfigurationDelegate.java | Uses -testNameFile for multi-method launches and throws a marked error when unsupported. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chagong
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When several test methods of the same class are selected in the Test Explorer, vscode-java-test currently launches one JVM per method, which makes Spring-style tests (where each JVM rebuilds the ApplicationContext in @BeforeAll) extremely slow.
Group methods of the same class into one launch and rely on the new 'Class:method' line format supported by the bundled Eclipse JDT JUnit runtime so that all selected methods are discovered inside a single JVM, sharing per-class @BeforeAll/@afterall lifecycle and any cached fixture (e.g. Spring ApplicationContext).
Methods restricted to a single invocation (uniqueId) keep their own launch, since the underlying protocol carries at most one uniqueId per JVM.