Describe the bug
When running tests via MCP, JVM options configured in build.sbt under Test / javaOptions are silently ignored, causing test failures that don't occur when running via bloop, sbt, or the editor UI (DAP).
The MCP test path in McpTestRunner.runTests() constructs ScalaTestSuites with hardcoded empty JVM options:
// McpTestRunner.scala
val testSuites = new b.ScalaTestSuites(
List(testSelection).asJava,
Nil.asJava, // jvmOptions β always empty
Nil.asJava, // environmentVariables β always empty
)
It then creates a TestSuiteDebugAdapter and runs the test directly inside Metals, completely bypassing the build server. TestSuiteDebugAdapter.run() forks the JVM using only testClasses.getJvmOptions(), which is the empty list above.
This contrasts with the DAP path, which calls DebugProvider.startDebugSession(). That method checks buildServer.isDebuggingProvider || buildServer.isSbt and β for both bloop and sbt β forwards the debug session request to the build server. The build server then handles test execution with full knowledge of Test / javaOptions from the build definition.
Two separate issues:
McpTestRunner doesn't call JvmOpts.fromWorkspaceOrEnvForTest(workspace), so even .test-jvmopts, TEST_JVM_OPTS, .jvmopts, and JVM_OPTS are ignored. The DAP path reads these via DebugDiscovery.createScalaTestSuites() and DebugProvider.startTestSuite().
- More fundamentally, because the MCP path bypasses the build server entirely,
Test / javaOptions defined in build.sbt can never be picked up β regardless of whether bloop or sbt is the build server.
Expected behavior
Tests run via MCP should respect the same JVM options as when run via the editor UI or directly via the build tool.
Operating system
macOS
Editor/Extension
Nvim (nvim-metals)
Version of Metals
Latest snapshot
Scala version/s
All
Extra context or search terms
No response
Describe the bug
When running tests via MCP, JVM options configured in
build.sbtunderTest / javaOptionsare silently ignored, causing test failures that don't occur when running via bloop, sbt, or the editor UI (DAP).The MCP test path in
McpTestRunner.runTests()constructsScalaTestSuiteswith hardcoded empty JVM options:It then creates a
TestSuiteDebugAdapterand runs the test directly inside Metals, completely bypassing the build server.TestSuiteDebugAdapter.run()forks the JVM using onlytestClasses.getJvmOptions(), which is the empty list above.This contrasts with the DAP path, which calls
DebugProvider.startDebugSession(). That method checksbuildServer.isDebuggingProvider || buildServer.isSbtand β for both bloop and sbt β forwards the debug session request to the build server. The build server then handles test execution with full knowledge ofTest / javaOptionsfrom the build definition.Two separate issues:
McpTestRunnerdoesn't callJvmOpts.fromWorkspaceOrEnvForTest(workspace), so even .test-jvmopts, TEST_JVM_OPTS, .jvmopts, and JVM_OPTS are ignored. The DAP path reads these viaDebugDiscovery.createScalaTestSuites()andDebugProvider.startTestSuite().Test / javaOptionsdefined in build.sbt can never be picked up β regardless of whether bloop or sbt is the build server.Expected behavior
Tests run via MCP should respect the same JVM options as when run via the editor UI or directly via the build tool.
Operating system
macOS
Editor/Extension
Nvim (nvim-metals)
Version of Metals
Latest snapshot
Scala version/s
All
Extra context or search terms
No response