From 862884b33009e64b3c25487abde8bcbaf3244d54 Mon Sep 17 00:00:00 2001 From: Anatolii Kmetiuk Date: Fri, 5 Dec 2025 18:55:33 +0900 Subject: [PATCH] Fix #8345: forked test execution doesn't access main resources Fixes issue where tests running in forked mode (Test / fork := true) cannot access resources from src/main/resources, while non-forked execution works correctly. Root cause: Context classloader not set: tests using Thread.currentThread().getContextClassLoader() couldn't find resources because the context classloader wasn't set to the URLClassLoader with the classpath Solution: Set context classloader in ForkTestMain.runTests() to the URLClassLoader containing the test classpath --- worker/src/main/java/sbt/internal/worker1/ForkTestMain.java | 1 + 1 file changed, 1 insertion(+) diff --git a/worker/src/main/java/sbt/internal/worker1/ForkTestMain.java b/worker/src/main/java/sbt/internal/worker1/ForkTestMain.java index 1a63d1312..a362d3a66 100644 --- a/worker/src/main/java/sbt/internal/worker1/ForkTestMain.java +++ b/worker/src/main/java/sbt/internal/worker1/ForkTestMain.java @@ -325,6 +325,7 @@ public class ForkTestMain { } private void runTests(TestInfo info, ClassLoader classLoader) throws Exception { + Thread.currentThread().setContextClassLoader(classLoader); final ExecutorService executor = executorService(info.parallel); final TaskDef[] tests = info.taskDefs.toArray(new TaskDef[] {}); final int nFrameworks = info.testRunners.size();