【问题标题】:sbt testOnly runs multiple testssbt testOnly 运行多个测试
【发布时间】:2020-07-01 18:51:20
【问题描述】:

当我跑步时:

sbt testOnly com.blablabla.A

我得到以下输出:

[error] Failed: Total 19, Failed 6, Errors 0, Passed 13, Ignored 6
[error] Failed tests:
[error]         com.blablabla.A
[error]         com.blablabla.B
[error]         com.blablabla.C
[error] (test:testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 13 s, completed Jul 1, 2020 12:35:08 PM

为什么?

我只想测试A。

【问题讨论】:

    标签: scala unit-testing sbt


    【解决方案1】:

    原因

    sbt testOnly com.blablabla.A
    

    不起作用是因为这里 sbt 在batch mode 中运行,这意味着它将每个 空格分隔 值视为一个单独的命令并尝试按顺序执行它们。例如,它将testOnly 视为一个命令,然后将com.blablabla.A 视为下一个命令

    sbt    testOnly      com.blablabla.A
              |                  |
          1st command      2nd command
    

    解决方案是将带有参数的命令用引号括起来

    sbt    clean        compile     "testOnly       TestA TestB"
             |            |             |                |
        1st command   2nd command    3rd command    args to 3rd command
    

    【讨论】:

      【解决方案2】:

      试试

      sbt "testOnly com.blablabla.A"
      

      【讨论】:

      • 将其拆分为两个命令(即sbt(进入 SBT 控制台)和testOnly com.blablabla.A(运行此测试))也可以。
      猜你喜欢
      • 2023-03-20
      • 1970-01-01
      • 2018-02-12
      • 2018-11-15
      • 1970-01-01
      • 2014-07-26
      • 2015-03-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多