![](/img/trans.png)
[英]How can i use redisService inside a spock test i need to cleanup the redis database for setup and cleanup
[英]Spock: test name and outcome in setup() cleanup() methods
我想知道是否有可能在Spock测试的生命周期方法中提供以下数据:
我问的原因是,我希望将这些元数据发送到数据接收器,而无需触摸每个测试。
谢谢! 马丁
在setup()
尝试this.specificationContext.iterationInfo.name
。 不确定是否有效。 一般而言, specificationContext
是我要查找此类数据的地方。
从蛋白石的答案更新:
现在是(Spock 1.1) specificationContext.currentIteration.name
作为记录,您还可以使用
@Rule
TestName testName = new org.junit.rules.TestName()
...
println "name: $testName.methodName"
...但是似乎没有意义。
对于另一个问题,获得结果:我找不到从Spock的SpecificationContext
中获得此结果的方法。
我快速浏览了org.junit.rules.TestWatcher
...但是使用Spock似乎无法检测到失败的测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.