【问题标题】:sbt test-only specific testsbt test-only 特定测试
【发布时间】:2017-01-25 06:37:47
【问题描述】:

我有几个测试分布在几个班级。

我只想运行第一堂课的第一个测试:

班级是:

class Step1_PrimarySpec 

测试是:

  test("case1: Primary (in isolation) should properly register itself to the provided Arbiter")

我试过了:

sbt test-only Step1_PrimarySpec

和:

sbt test-only Step1_PrimarySpec 1

和:

 sbt test-only "*Step1_PrimarySpec 1"

和:

 sbt test-only "*Step1_PrimarySpec"

但是,所有这些命令都运行了整个测试套件。

那么我怎样才能只运行那个特定的测试呢?

【问题讨论】:

    标签: scala sbt


    【解决方案1】:

    您必须像这样将整个命令放在双引号中:

    sbt "test-only <test-name>"
    

    根据this 的回答,您应该将其驼峰化为testOnly 并使用-z 参数

    【讨论】:

    • sbt "只测试 org.path.to.test.testClassName"
    【解决方案2】:
    sbt "testOnly *Step1_PrimarySpec -- -z mytest"
    

    这将从名为Step1_PrimarySpec(不是文件)中运行名为mytest 的测试。

    通过使用*,测试运行程序使我们免于指定其完全限定的类名。即 org.path.to.Step1_PrimarySpec

    【讨论】:

    • 请注意,这是 ScalaTest 特有的。
    猜你喜欢
    • 1970-01-01
    • 2014-04-24
    • 2019-11-04
    • 1970-01-01
    • 2016-10-11
    • 2014-03-01
    • 1970-01-01
    • 2014-06-14
    • 1970-01-01
    相关资源
    最近更新 更多