How to fork the jvm for each test in sbt

前端 未结 2 1669
[愿得一人]
[愿得一人] 2021-01-11 13:24

I am working with some classes that (for some reason) can only be used once within a single VM. My test cases work if I run them individually (fork := true) ena

2条回答
  •  执念已碎
    2021-01-11 14:00

    It turns out this is fairly easy to achieve. The documentation is sufficient and can be found at Testing - Forking tests

    // Define a method to group tests, in my case a single test per group
    def singleTests(tests: Seq[TestDefinition]) =
      tests map { test =>
        new Group(
          name = test.name,
          tests = Seq(test),
          runPolicy = SubProcess(javaOptions = Seq.empty[String]))
      }
    
    // Add the following to the `Project` settings
    testGrouping in Test <<= definedTests in Test map singleTests
    

提交回复
热议问题