0

I've some integration tests written in Scala sbt which uses Junit5. I want to run the tests within the suite in parallel, however unable to do so.

This is how my code looks like:

trait IntegrationTestBase extends AnyFunSpec with Matchers with OptionValues with Inside
  with Inspectors with ScalaFutures with BeforeAndAfter with BeforeAndAfterAll with LazyLogging
@RunWith(classOf[JUnitRunner])
class TestClass extends IntegrationTestBase with ParallelTestExecution {
  override protected def beforeAll(): Unit = {
    super.beforeAll()
    ...
  }

  override protected def afterAll(): Unit = {
    super.afterAll()
    ...
  }

  describe("Test Group 1") {
    it("some test should pass") {
      ...
    }
  }

  describe("Test Group 2") {
    it("some different test should pass") {
      ...
    }
  }
}

Currently, Test Group 2 execution starts only after Test Group 1 is completed. I want the Test Group 1 and Test Group 2 to run in parallel. What am I missing here?

Tried adding this configuration in sbt file - Test / testForkedParallel := true but no change in result.

Also tried to configure the parallel execution guide from junit5 by creating the junit-platform.properties with configuration:

junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent

junit.jupiter.execution.parallel.config.strategy = fixed
junit.jupiter.execution.parallel.config.fixed.parallelism = 6

But this didn't work as well.

Anurag
  • 353
  • 3
  • 15
  • Does this answer your question? [Limit scalatest parallel execution thread number](https://stackoverflow.com/questions/45169343/limit-scalatest-parallel-execution-thread-number) – Gastón Schabas Jul 28 '23 at 13:29
  • @GastónSchabas It did not work. It started the tests in parallel but then the execution was kind of weird where it didn't wait for the `Thread.sleep(time)` and the test is also getting marked as Passed before even the execution got completed. – Anurag Jul 28 '23 at 17:54
  • I'm preferably looking for some native solution from Junit5 or Scala-test here. – Anurag Jul 28 '23 at 17:55
  • Does this answer your question? [Run ScalaTest tests in parallel](https://stackoverflow.com/questions/15752681/run-scalatest-tests-in-parallel) – stefanobaghino Jul 29 '23 at 06:06
  • tl;dr `testOptions in Test += Tests.Argument("-P")` should help – stefanobaghino Jul 29 '23 at 06:07
  • Tried this as well, no change. :/ – Anurag Jul 31 '23 at 15:55

0 Answers0