简体   繁体   中英

Run a single test suite from build.sbt

I have a multi-module project and currently run tests during packaging by a task which reads -

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
}

Now, I have consolidated all tests in each module into a single top-level ScalaTest Suite. So for each module want to only run this single top-level suite (named say "blah.moduleA.TestSuite" and so on). Have been trying to use testOnly and testFilter in my build.sbt to run just this single suite in each module but cant get the syntax right. Can someone please tell me how to do this?

testOnly is an InputKey[Unit] . You want to turn it in a Task[Unit] to be able to run it directly for a given test suite.

You can achieve this this way:

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

In sbt's documentation: Preapplying input in sbt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM