考虑以下Suites
,其中包含几个嵌套的Suite
package example
import org.scalatest.{DoNotDiscover, Suites}
import org.scalatest.funsuite.AnyFunSuite
@DoNotDiscover
class NestedSuite1 extends AnyFunSuite {
test("A") {}
test("B") {}
}
@DoNotDiscover
class NestedSuite2 extends AnyFunSuite {
test("A") {}
test("B") {}
}
class ContainingSuite extends Suites(
new NestedSuite1,
new NestedSuite2
)
如何具体执行,例如,通过B
测试NestedSuite2
中的ContainingSuite
?注意,我不是故意的
Test/runMain org.scalatest.tools.Runner -o -s example.NestedSuite2 -t B
因为它绕过ContainingSuite
。相反,我追求类似
Test/runMain org.scalatest.tools.Runner -o -s example.ContainingSuite -i example.NestedSuite2 -t B
同时执行A
的{{1}}和B
NestedSuite2
与类似的预期输出相反
sbt:scalatest-seed-3.2.0> Test/runMain org.scalatest.tools.Runner -o -s example.ContainingSuite -i example.NestedSuite2 -t B
[info] running org.scalatest.tools.Runner -o -s example.ContainingSuite -i example.NestedSuite2 -t B
Run starting. Expected test count is: 2
NestedSuite1:
NestedSuite2:
- A
- B
Run completed in 72 milliseconds.
Total number of tests run: 2
Suites: completed 3, aborted 0
Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
Selecting suites and tests记录NestedSuite1:
NestedSuite2:
- B
Run completed ...
,-s
和-i
运行者参数,如下所示
-t
将用于指定ScalaTest可以实例化的类 直接包含包含一个无参数公共构造函数的套件, 和-s
将用于选择所需的嵌套套件...-i
参数允许通过其(完整的)测试名称选择测试... 如果-t
或-t
之后的-s
,则仅适用于 确定套件。
请注意,我正在使用由-i
插入的Test/runMain org.scalatest.tools.Runner
,因为当前它与testOnly
批注一起not工作。