9

How to get a list of test cases (fully qualified names) under current project?

The environment is Scala 2.10.2, Sbt 0.12.3 and scalatest 1.9.1

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420

1 Answers1

11

(definedTests in Test) returns sbt.TestDefinition.

val printTests = taskKey[Unit]("something")

printTests := {
  val tests = (definedTests in Test).value
  tests map { t =>
    println(t.name)
  }
}

The above is in sbt 0.13 syntax, but the idea should be same in sbt 0.12.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
  • 3
    Thanks for the answer but I am not sure how to use it. Can I use this from the SBT command prompt or does it need to be in a configuration file? Personally, I would like the former. – Ashley Aitken Jun 18 '18 at 02:49