Reputation: 1071
How can I get the name of the currently running uTest test case?
During the test case I usually use println(...) or log.debug(...) to print and check various values. At the beginning of the test case I print the name of the test case.
I can always do this:
object MyTests extends TestSuite
def tests = TestSuite {
"MyTest01" - {
println("MyTest01 starting ***************************************************")
val x = Thing.doComplexCalc
println("x = " + x )
val y = AnotherThing.doSomethingMore( x )
println("y = " + y )
assert(y=="mysterious output")
}
}
}
In this (extremely simplified) example "MyTest01" is duplicated. What I'm looking for is a way to remove the duplication, e.g. like this:
object MyTests extends TestSuite
def tests = TestSuite {
"MyTest01" - {
println(getTest().name + " starting ***************************************************")
val x = Thing.doComplexCalc
println("x = " + x )
val y = AnotherThing.doSomethingMore( x )
println("y = " + y )
assert(y=="mysterious output")
}
}
}
Test name is available from tests.toSeq().name but how to know what case is running especially if they are run parallel using sbt.
Upvotes: 1
Views: 139
Reputation: 6094
import utest._
...
val name = implicitly[utest.framework.TestPath].value
Upvotes: 1
Reputation: 15802
It's not available right now. There's an open issue to make it so
https://github.com/lihaoyi/utest/issues/71
Upvotes: 0