我有一个扩展org.scalatest.junit.JUnitSuite的类.本课程有一些测试.我不希望这些测试并行运行.
I have a class which extends org.scalatest.junit.JUnitSuite. This class has a couple of tests. I do not want these tests to run in parallel.
我知道Specs2有多么简单(用Specification扩展类,并在类内添加一行sequential),如下所示:如何顺序运行规范.
I know how simple it is with Specs2 (extend the class with Specification and add a single line sequential inside the class) as shown here: How to run specifications sequentially.
我不想通过设置来更改Build文件: parallelExecution in Test := false 我也不想使用标签按顺序运行特定的测试文件.
I do not want to alter the Build file by setting: parallelExecution in Test := false nor I want to use tags to run specific test files sequentially.
我想要的是一种确保班级内的所有测试顺序运行的方式. ScalaTest有可能吗?任何示例测试/模板都值得赞赏.
All I want is a way to make sure that all tests inside my class run sequentially. Is this possible with ScalaTest ? Any sample test/template is appreciated.
一个快速的Google搜索使我注意到了这一点: doc.scalatest/2.0/index.html#org.scalatest.Sequential
A quick google search pointed me to this: doc.scalatest/2.0/index.html#org.scalatest.Sequential
就我所进行的几次测试而言,我认为创建StepSuite完全是过头了.我不完全确定这是否适合我的案子!
Just for the couple of tests I have, I think it is a total overkill to create StepSuites. I am not completely sure if that's the way to go about with my case!
推荐答案org.scalatest.ParallelTestExecution 的文档说
ScalaTest并行运行测试套件的正常方法是并行运行不同的套件,但顺序运行任何一个套件的测试.
ScalaTest's normal approach for running suites of tests in parallel is to run different suites in parallel, but the tests of any one suite sequentially.
如果您的测试在一个套件中,那么看起来您无需执行任何操作即可获得所需的结果.
So it looks like you don't have to do anything to get your what you want, if your tests are in a single suite.
更多推荐
如何在ScalaTest中按顺序在类中运行测试?
发布评论