2016-09-26 30 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

不,展开只能访问您的数据驱动值(在哪里) –

相关问题