How can I get this" /> How can I get this" /> How can I get this"/>

How can I get list of all the tests in a test class implemented using ScalaTest?

172 Views Asked by At

Like we have a test report containing information like

 <testcase classname="ABC" name="should fulfill some condition" time="12.22">

How can I get this information in another test class? For example, Suppose we have a Test Class One which has some tests implemented using Scala Test. How can get the list of all tests with description implemented in Class One in another test class Two?

1

There are 1 best solutions below

1
Jasper-M On BEST ANSWER

You can call testNames to get a set of all tests.

scala> class FooSpec extends AnyFlatSpec {
     |   "foo" should "do thing" in { }
     |   it should "do something else" in { }
     | }
class FooSpec

scala> new FooSpec().testNames
val res1: Set[String] = TreeSet(foo should do thing, foo should do something else)