Skip to content

Run multiple selected test methods in a single JVM (#1836)#1862

Merged
wenytang-ms merged 10 commits intomainfrom
feat/multi-method-launch
May 8, 2026
Merged

Run multiple selected test methods in a single JVM (#1836)#1862
wenytang-ms merged 10 commits intomainfrom
feat/multi-method-launch

Conversation

@wenytang-ms
Copy link
Copy Markdown
Contributor

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.

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.
@wenytang-ms
Copy link
Copy Markdown
Contributor Author

depends on eclipse-jdt/eclipse.jdt.ui#2975

@wenytang-ms wenytang-ms marked this pull request as draft May 7, 2026 03:24
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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 export mergeTestMethods for 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:method entries 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.

Comment thread src/controller/testController.ts Outdated
Comment thread test/suite/testController.mergeTestMethods.test.ts Outdated
Comment thread src/controller/testController.ts Outdated
@wenytang-ms wenytang-ms marked this pull request as ready for review May 8, 2026 03:08
@wenytang-ms wenytang-ms merged commit 7f34806 into main May 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants