拥有Play
项目,我想并行运行以下测试:
package tests
import org.scalatest.{ParallelTestExecution, FeatureSpec}
class MyParallelTestSpec extends FeatureSpec with ParallelTestExecution {
feature("My Feature") {
scenario("Scenario 1") {
println("Scenario 1.1")
Thread.sleep(3000)
println("Scenario 1.2")
}
scenario("Scenario 2") {
println("Scenario 2")
}
scenario("Scenario 3") {
println("Scenario 3.1")
Thread.sleep(4000)
println("Scenario 3.2")
}
scenario("Scenario 4") {
println("Scenario 4")
}
scenario("Scenario 5") {
println("Scenario 5")
}
scenario("Scenario 6") {
println("Scenario 6")
}
}
}
在functionatests
中打开的项目的IntelliJ
模块中,我在build.sbt
显式并行执行测试中定义:parallelExecution in Test := true
。
当我在终端中运行时:sbt "functionaltest/main:testOnly tests.MyParallelTestSpec"
它确实并行运行但是因这些错误而失败:
[info] Compiling 1 Scala source to /Users/francisk.baptista/Documents/Google/dataservices/functionaltest/target/scala-2.10/main-classes...
Scenario 6
Scenario 1.1
Scenario 3.1
Scenario 2
Scenario 4
Scenario 5
Reporter completed abruptly with an exception after receiving event: SuiteCompleted(Ordinal(0, 4, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(40),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-3,1444495674366).
java.lang.IllegalStateException: Expected SuiteStarting for completion event: SuiteCompleted(Ordinal(0, 4, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(40),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-3,1444495674366) in the head of suite events, but we got no suite event at all
at org.scalatest.tools.HtmlReporter.apply(HtmlReporter.scala:948)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:240)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:239)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.DispatchReporter$Propagator.run(DispatchReporter.scala:239)
at java.lang.Thread.run(Thread.java:745)
Reporter completed abruptly with an exception after receiving event: SuiteCompleted(Ordinal(0, 8, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(41),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-7,1444495674366).
java.lang.IllegalStateException: Expected SuiteStarting for completion event: SuiteCompleted(Ordinal(0, 8, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(41),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-7,1444495674366) in the head of suite events, but we got no suite event at all
at org.scalatest.tools.HtmlReporter.apply(HtmlReporter.scala:948)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:240)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:239)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.DispatchReporter$Propagator.run(DispatchReporter.scala:239)
at java.lang.Thread.run(Thread.java:745)
Reporter completed abruptly with an exception after receiving event: SuiteCompleted(Ordinal(0, 6, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(41),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-8,1444495674366).
java.lang.IllegalStateException: Expected SuiteStarting for completion event: SuiteCompleted(Ordinal(0, 6, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(41),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-8,1444495674366) in the head of suite events, but we got no suite event at all
at org.scalatest.tools.HtmlReporter.apply(HtmlReporter.scala:948)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:240)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:239)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.DispatchReporter$Propagator.run(DispatchReporter.scala:239)
at java.lang.Thread.run(Thread.java:745)
Scenario 1.2
Reporter completed abruptly with an exception after receiving event: SuiteCompleted(Ordinal(0, 3, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(3039),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-5,1444495677364).
java.lang.IllegalStateException: Expected SuiteStarting for completion event: SuiteCompleted(Ordinal(0, 3, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(3039),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-5,1444495677364) in the head of suite events, but we got no suite event at all
at org.scalatest.tools.HtmlReporter.apply(HtmlReporter.scala:948)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:240)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:239)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.DispatchReporter$Propagator.run(DispatchReporter.scala:239)
at java.lang.Thread.run(Thread.java:745)
Scenario 3.2
Reporter completed abruptly with an exception after receiving event: SuiteCompleted(Ordinal(0, 5, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(4040),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-4,1444495678365).
java.lang.IllegalStateException: Expected SuiteStarting for completion event: SuiteCompleted(Ordinal(0, 5, 3),DistributedTestRunnerSuite,org.scalatest.tools.DistributedTestRunnerSuite,Some(org.scalatest.tools.DistributedTestRunnerSuite),Some(4040),Some(MotionToSuppress),Some(TopOfClass(org.scalatest.tools.DistributedTestRunnerSuite)),None,None,pool-4-thread-4,1444495678365) in the head of suite events, but we got no suite event at all
at org.scalatest.tools.HtmlReporter.apply(HtmlReporter.scala:948)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:240)
at org.scalatest.DispatchReporter$Propagator$$anonfun$run$1.apply(DispatchReporter.scala:239)
at scala.collection.immutable.List.foreach(List.scala:318)
at org.scalatest.DispatchReporter$Propagator.run(DispatchReporter.scala:239)
at java.lang.Thread.run(Thread.java:745)
[info] Run completed in 4 seconds, 586 milliseconds.
[info] Total number of tests run: 6
[info] Suites: completed 7, aborted 0
[info] Tests: succeeded 6, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 17 s, completed Oct 10, 2015 5:47:58 PM
如何摆脱这些错误并正常执行测试?