【问题标题】:How do you run only a single Spec2 specification with SBT?如何使用 SBT 只运行一个 Spec2 规范?
【发布时间】:2012-12-10 17:49:54
【问题描述】:

如果您在 SBT 项目中定义了 2 个测试:

class Spec1 extends Specification {
  def is =
    "Tests for specification 1" ^
      p ^
      "Test case 1" ! todo ^
      end
}

class Spec2 extends Specification {
  def is =
    "Tests for specification 2" ^
      p ^
      "Test case 2" ! todo ^
      end
}

然后从 SBT 内部运行 test 将执行这两个测试。只运行其中一项测试的最简单方法是什么?

【问题讨论】:

    标签: scala specs2


    【解决方案1】:

    使用test-only sbt 命令。

    sbt> test-only com.example.MySpec
    

    您甚至可以使用通配符来运行一系列测试。 见How to execute tests that match a regular expression only?

    【讨论】:

    • 如果您不想先输入sbt shell,可执行文件只需要一个参数,因此您必须将整个命令用引号括起来。在这里,sbt "test-only com.example.MySpec"sbt "test-only *MySpec"
    猜你喜欢
    • 2015-10-24
    • 2017-04-02
    • 1970-01-01
    • 2015-09-04
    • 1970-01-01
    • 2014-01-31
    • 2015-08-03
    • 1970-01-01
    • 2019-11-18
    相关资源
    最近更新 更多