I'm looking for a way to execute scala tests (implemented in munit, but it could be also ScalaTest) programmatically. I want to perform more or less what sbt test
does out-of-the box inside my own scala code, without running sbt
(focusing on test discovery and execution and getting back a report).
I some something like this in mind:
object Test extends App {
val tests = TestDiscovery.discover("package.that.has.tests")
val reports = tests.foreach(test => test.execute())
// do something with the reports, maybe print to console
}
Is there any documentation related to this?
CodePudding user response:
Scala Test has execute()
and run()
.
In order to understand the impact of all the args it's worth looking at the Scala Test shell as well