How to run tests in a class sequentially in ScalaTest?

橙三吉。 提交于 2021-02-07 02:59:51

问题


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.

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.

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.

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.

A quick google search pointed me to this: http://doc.scalatest.org/2.0/index.html#org.scalatest.Sequential

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!


回答1:


The doc for org.scalatest.ParallelTestExecution says

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.



来源:https://stackoverflow.com/questions/31463160/how-to-run-tests-in-a-class-sequentially-in-scalatest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!