mirror of https://github.com/sbt/sbt.git
Merge pull request #8402 from anatoliykmetyuk/fix/forked-test-resources-access
Fix #8345: forked test execution doesn't access main resources
This commit is contained in:
commit
507d221048
|
|
@ -0,0 +1,6 @@
|
|||
val scalatest = "org.scalatest" %% "scalatest" % "3.2.19"
|
||||
|
||||
scalaVersion := "3.7.3"
|
||||
Test / fork := true
|
||||
libraryDependencies += scalatest % Test
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
test resource content
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import org.scalatest.funsuite.AnyFunSuite
|
||||
|
||||
class ResourceTest extends AnyFunSuite {
|
||||
test("access main resource from forked test") {
|
||||
val loader = Thread.currentThread().getContextClassLoader()
|
||||
val resource = loader.getResource("foo")
|
||||
assert(resource != null, "Resource 'foo' from src/main/resources should be accessible in forked test execution")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
> test
|
||||
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue