如何获得当前正在运行的uTest测试用例的名称?
在测试过程中,我通常使用println(.)或log.debug(.)打印和检查各种值。在测试用例的开头,我打印测试用例的名称。
我总是可以这样做的:
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")
}
}
}在这个(非常简化的)示例中,"MyTest01“被复制。我正在寻找的是一种消除复制的方法,例如:
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")
}
}
}测试名称可以从tests.toSeq().name中获得,但是如何知道什么情况正在运行,特别是如果它们是使用sbt并行运行的话。
发布于 2016-01-27 17:03:29
现在还没有。有个公开的问题要让它
发布于 2018-04-23 16:42:04
import utest._
...
val name = implicitly[utest.framework.TestPath].valuehttps://stackoverflow.com/questions/35041262
复制相似问题