![](/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.