'How to execute scala tests programmatically

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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gatear