0

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?

Bharadwaj
  • 1,361
  • 1
  • 9
  • 24

1 Answers1

1

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

Martin
  • 1,868
  • 1
  • 15
  • 20
  • Thanks to your response I understood how to use InputKey. But for some reason I dont understand yet, fullInput did not work. And trying to find why I found [this](http://stackoverflow.com/questions/35863430/custom-sbt-task-to-run-tests-by-tag) SO question which suggested using toTask() and that one worked perfectly! – Bharadwaj May 13 '16 at 05:29