【发布时间】:2013-07-12 07:01:13
【问题描述】:
以下是我的课程。
class Spec1 {
def is = {
function1 ^
function2 ^
function3 ^
end
}
def function1 = {
println("Spec1")
}
def function2 = {
Thread.sleep(120000)
println("sleeping-Spec1")
}
def function3 = {
println("Spec1")
}
}
class Spec2 {
def is = {
function1 ^
function2 ^
function3 ^
end
}
def function1 = {
println("Spec2")
}
def function2 = {
println("Spec2")
}
def function3 = {
println("Spec2")
}
}
class MasterSpec {
def is = {
Step(setup) ^ new Spec1 ^ new Spec2 ^ Step(teardown)
}
def setup = {
setup code
}
def teardown = {
teardown code
}
}
从 sbt 提示符我运行 test-only MasterSpec
预期输出:- 打印语句将随机打印。因为默认情况下 sbt 并行运行规范。输出应该看起来像这样。
Spec2
Spec1
Spec1
Spec2
sleeping-Spec1
Spec2
实际输出:- 打印语句是有序的。
Spec1
sleeping-Spec1
Spec1
Spec2
Spec2
Spec2`
当我在个别规范中从 MasterSpec 复制设置和拆卸方法并运行 test-only Spec1 Spec2 时,我能够并行运行它们。为什么test-only MasterSpec 不并行运行测试?有没有办法可以从 MasterSpec 并行运行这些规范?
【问题讨论】: