Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel execution definitions of tests are ignored #849

Closed
tam4s opened this issue Mar 13, 2013 · 3 comments
Closed

Parallel execution definitions of tests are ignored #849

tam4s opened this issue Mar 13, 2013 · 3 comments

Comments

@tam4s
Copy link

tam4s commented Mar 13, 2013

Play ignores SBT test configuration settings like parallelExecution in Test := true or test grouping, or defined limits like Tags.limit(Tags.Test, 3).

It's not clear (especially not for a Java developer) and undocumented how to execute tests parallel, even if it's possible somehow. Here is an example Build.scala that defines the tests running in multiple JVMs & multiple threads, but all the tests running in a single JVM in a single thread instead.

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {
    val appName         = "testTest"
    val appVersion      = "1.0-SNAPSHOT"

    val testThreads = 8

    def groupByFirst(tests: Seq[TestDefinition]) =
      tests groupBy (_.name(0)) map {
        case (letter, tests) => new Tests.Group(letter.toString, tests, Tests.SubProcess(Seq("-Dfirst.letter"+letter)))
      } toSeq;

    val appDependencies = Seq(
      javaCore,
    )

    val main = play.Project(appName, appVersion, appDependencies).settings(
      concurrentRestrictions in Global := Seq(
        Tags.limit(Tags.ForkedTestGroup, testThreads),
        Tags.limit(Tags.Test, testThreads),
        Tags.limit(Tags.CPU, testThreads),
        Tags.limit(Tags.Compile, testThreads),
        Tags.limitAll(testThreads),
        Tags.limitUntagged(testThreads)),
      parallelExecution in Test := true,
      testGrouping <<= definedTests in Test map groupByFirst
    )
}

I use JUnit as my testing framework.

I put this line into each tests to test whether the tests run in parallel or not:

System.out.println(String.format("process id: %s thread id: %s", ManagementFactory.getRuntimeMXBean()
    .getName(), Thread.currentThread().getId()));

I understand that certain tests cannot be run parallel (E.g. more than one TestServer in a single JVM or more than one TestServer in multiple JVMs that listens on the same port) but it doesn't mean that parallel execution should be disabled for all kind of tests.

@Gissues:{"order":35.89743589743585,"status":"backlog"}

@jroper
Copy link
Member

jroper commented Oct 15, 2013

In Play 2.1.x, we introduced forking tests being enabled by default, this was to solve some classloader leaks we were having caused by third party libraries for people that run console for a long time and execute the tests many times. The SBT documentation on forked tests:

http://www.scala-sbt.org/0.12.3/docs/Detailed-Topics/Testing

Says that all tests in a particular fork group are run in serial, but you can configure multiple groups to fork multiple JVMs.

Alternatively, you can:

fork in Test := false,
parallelExecution in Test := true

And this will run the tests in the SBT JVM in parallel.

@jroper jroper closed this as completed Oct 15, 2013
@nsphung
Copy link

nsphung commented Feb 3, 2014

It seems

fork in Test := false
parallelExecution in Test := true

parameters in build.sbt are ignored in Play 2.2.1

@axblueblader
Copy link

Hello have anyone got it to work, I've searched and tried all the settings still cannot configure parallel test execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants