vscode-java-test icon indicating copy to clipboard operation
vscode-java-test copied to clipboard

Testing view refreshes every time I run tests

Open TimKingtonFC opened this issue 6 months ago • 5 comments

I have a gradle-based Java project, and it has been working fine. Recently it started refreshing the testing view every time a test run completes. It takes five or so seconds to load. It briefly shows the message that there are no tests, then the subtree containing the test I just ran, and then the entire test tree. It's very annoying :)

I saw it on the current version, and I also tried pre-release 0.43.2025040304 and saw it there too. This is vscode 1.103.1.

build.gradle:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java application project to get you started.
 * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.8/userguide/building_java_projects.html in the Gradle documentation.
 */

plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
    id 'java'
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenLocal()
    mavenCentral()
}

dependencies {
    implementation 'com.microsoft.java:com.microsoft.java.debug.core:0.53.1'
    // Use JUnit Jupiter for testing.
	testImplementation('org.junit.jupiter:junit-jupiter:5.6.0')
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

}

// Apply a specific Java toolchain to ease working on different environments.
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(21)
    }
}

application {
    // Define the main class for the application.
    mainClass = 'gradle.test.App'
}

tasks.named('test') {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
	testLogging {
		events "passed", "skipped", "failed"
	}
}

TimKingtonFC avatar Aug 14 '25 13:08 TimKingtonFC

I looked at my settings.json, and I don't have any non-default settings related to testing except for golang.

TimKingtonFC avatar Aug 14 '25 14:08 TimKingtonFC

This is being triggered by something during the build or by saving source files maybe? - if I have a compile error, the test doesn't run, but the tree refreshes anyway.

TimKingtonFC avatar Aug 14 '25 15:08 TimKingtonFC

I am having the same issue for a gradle project and it also only recently started.

Version: 1.105.1 (user setup) Commit: 7d842fb85a0275a4a8e4d7e040d2625abbf7f084 Date: 2025-10-14T22:33:36.618Z Electron: 37.6.0 ElectronBuildId: 12502201 Chromium: 138.0.7204.251 Node.js: 22.19.0 V8: 13.8.258.32-electron.0 OS: Windows_NT x64 10.0.26100

Name: Test Runner for Java Id: vscjava.vscode-java-test Description: Run and debug JUnit or TestNG test cases. Version: 0.43.2 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test

The only error logged that I can see is:

!SESSION 2025-11-03 20:03:19.345 ----------------------------------------------- eclipse.buildId=unknown java.version=21.0.8 java.vendor=Eclipse Adoptium BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US Framework arguments: --pipe=/tmp/lsp-37cb961d130f50806ff5c5315981845e.sock Command-line arguments: -data /home/vscode/.vscode-server/data/User/workspaceStorage/df6951322be6947d19296dfdc090c8e6/redhat.java/ss_ws --pipe=/tmp/lsp-37cb961d130f50806ff5c5315981845e.sock

!ENTRY org.eclipse.osgi 4 0 2025-11-03 20:03:20.299 !MESSAGE Application error !STACK 1 java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini). at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:92) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:467) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:298) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:615) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:563) at org.eclipse.equinox.launcher.Main.run(Main.java:1415) at org.eclipse.equinox.launcher.Main.main(Main.java:1387)

bluecontainer avatar Nov 03 '25 20:11 bluecontainer

I was able to workaround the issue by changing the Java test profile of "Delegate Test to Gradle". I had never used that option before so something is broken in the default profile.

bluecontainer avatar Nov 04 '25 15:11 bluecontainer

Hi @TimKingtonFC, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

It isn’t currently possible to stop VS Code’s Java Test extension from fully rebuilding the Test Explorer tree after each run. Here are a few work-arounds and references:

• Disable auto-reveal of the Test Explorer when you run tests:

// in your settings.json
"testing.autoReveal": false       // built-in VS Code setting
// or for Java Test specifically:
"java.test.autoOpenTestView": false

• Run tests via the Gradle Tasks view (View → Terminal → Run Task → test) instead of the Test Explorer; that won’t trigger the Test Explorer’s full refresh.

• Keep an eye on the incremental-refresh work in the Java Test extension: – Test runners interfere with Java language server (incremental refresh planned): https://github.com/microsoft/vscode-java-test/issues/260#issuecomment-416135729

Other references with low confidence

• After rerunning a test, previously opened report should refresh – requests a better refresh experience for the report: https://github.com/microsoft/vscode-java-test/issues/132

• First time click to refresh Gradle Status will re-update the project – another full-refresh-on-click problem (Gradle extension): https://github.com/microsoft/vscode-gradle/issues/943

The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

github-actions[bot] avatar Nov 13 '25 04:11 github-actions[bot]