【问题标题】:Run a single test suite from build.sbt从 build.sbt 运行单个测试套件
【发布时间】:2016-05-12 09:25:13
【问题描述】:

我有一个多模块项目,目前在打包过程中通过一个任务运行测试 -

val testALL = taskKey[Unit]("Test ALL Modules")

testALL := {
  (test in Test in module_A).value
  (test in Test in module_B).value
  (test in Test in module_C).value
}

现在,我已将每个模块中的所有测试合并到一个顶级 ScalaTest 套件中。所以对于每个模块只想运行这个单一的顶级套件(命名为“blah.moduleA.TestSuite”等等)。一直在尝试在我的 build.sbt 中使用 testOnly 和 testFilter 来在每个模块中只运行这个单一的套件,但无法获得正确的语法。谁能告诉我该怎么做?

【问题讨论】:

    标签: scala sbt scalatest


    【解决方案1】:

    testOnly 是一个InputKey[Unit]。您希望将其转为 Task[Unit] 以便能够直接为给定的测试套件运行它。

    你可以这样实现:

    lazy val foo = taskKey[Unit]("...")
    foo := (testOnly in Test).fullInput("hello").value
    

    在 sbt 的文档中:Preapplying input in sbt

    【讨论】:

    • 感谢您的回复,我了解了如何使用 InputKey。但是由于某种我还不明白的原因,fullInput 不起作用。并试图找出为什么我发现了this SO 问题,该问题建议使用 toTask() 并且该问题非常有效!
    猜你喜欢
    • 2016-11-24
    • 2010-12-03
    • 2012-02-17
    • 2014-03-25
    • 2017-05-22
    • 2020-05-14
    • 2018-02-03
    • 2019-11-24
    • 1970-01-01
    相关资源
    最近更新 更多