如何按顺序运行规范 [英] How to run specifications sequentially

查看:41
本文介绍了如何按顺序运行规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一些与数据库互操作的规范.

I want to create few specifications that interoperate with database.

class DocumentSpec extends mutable.Specification with BeforeAfterExample {
  sequential

  def before() = {createDB()}
  def after() = {dropDB()}

  // examples
  // ...
}

在每个示例之前和之后创建和删除数据库(按顺序执行).Everithing 按预期工作,直到只有一个规范适用于数据库.由于规范是并行执行的,它们会相互干扰并失败.

Database is created and dropped before and after every example (which is executed sequentially). Everithing works as expected until there is only one spec that works with database. Because specifications are executed parallel, they interfere and fail.

我希望我能够通过指示 specs2 依次运行带有副作用的测试,同时保持无副作用的测试并行运行来避免这种情况.可能吗?

I hope that I'm able to avoid this by instructing specs2 to run tests with side effects sequentially while keeping side effect free tests to run in parallel. Is it possible?

推荐答案

我想您正在使用 SBT?如果是这样,请查看文档:http://www.scala-sbt.org/release/docs/Detailed-Topics/Parallel-Execution

I suppose you are using SBT? If so, check the documentation: http://www.scala-sbt.org/release/docs/Detailed-Topics/Parallel-Execution

相关的 SBT 设置是 parallelExecution.将此添加到您的项目定义中:

The relevant SBT setting is parallelExecution. Add this to your project definition:

parallelExecution in Test := false

这篇关于如何按顺序运行规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆