如何在ScalaTest中按顺序在类中运行测试?

编程入门 行业动态 更新时间:2024-10-25 10:34:08
本文介绍了如何在ScalaTest中按顺序在类中运行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个扩展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中按顺序在类中运行测试?

本文发布于:2023-11-25 05:50:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628567.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类中   顺序   测试   如何在   ScalaTest

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!