2016-09-26 16 views
1

如果我有以下斯波克測試:如何將我的where子句中的信息添加到我在Spock中的測試失敗中?

def "A should be smaller than B"() { 
     expect: "A is smaller than B" 
     A < B 

     where: "A and B take on the following values" 
     A|B|Path 
     5|6|/home 
     6|7|/home 
     7|5|/home/user 

我預計第三哪裏的情況下失敗,因爲7不小於5的HTML報告試驗失敗是足夠信息顯示什麼A的值和B是,但我也想知道在查看報告時的路徑。如何在測試失敗時獲取測試報告以包含有關路徑的信息?

回答

2

你可以這樣做:

@Unroll 
def "#A should be smaller than #B with #Path"() { 
    expect: "A is smaller than B" 
    A < B 

    where: "A and B take on the following values" 
    A|B|Path 
    5|6|/home 
    6|7|/home 
    7|5|/home/user 
} 
+0

謝謝!簡單的解決方案,我沒有意識到。這正是我在尋找 –

+0

這是否可能在where子句之外呢?我期待使用一個變量,沒有地方,它不工作。 –

+0

不,展開只能訪問您的數據驅動值(在哪裏) –

相關問題