Reputation: 1225
On an environment with
I'm not able to run tests in the same class in a parallel because it looks like SBT will run in a parallel way every class, not the test in the same class.
e.g.
TestA
in qa.parallelism package
. This class contains two tests called test1
and test2
.TestB
in qa.parallelism package
that contains a test called test1
.if I run
testOnly qa.parallelism.*
by log I understand that TestA.test1 and TestB.test1 was executed simultaneously,
but if I run
testOnly qa.parallelism.TestA
that contains two tests (test1
and test2
), I understand that test2
will be executed at the end of test1
.
Is there a way to run simultaneously every test of a single class or I should create a class for every single test?
Thanks.
Upvotes: 5
Views: 1812
Reputation: 48410
ParallelTestExecution
docs state default ScalaTest behaviour is to:
...run different suites in parallel, but the tests of any one suite sequentially.
However, mixing in ParallelTestExecution
trait enables tests within the same class to be run in parallel. For example,
import org.scalatest.{FlatSpec, Matchers, ParallelTestExecution}
class HelloSpec extends FlatSpec with Matchers with ParallelTestExecution {
"The Hello object" should "say hello 1" in {
println("1")
Hello.greeting should be ("hello")
}
it should "say hello 2" in {
println("2")
Hello.greeting should be ("hello")
}
it should "say hello 3" in {
println("3")
Hello.greeting should be ("hello")
}
}
outputs different orderings of printlns on different sbt test
executions.
Upvotes: 3