如何将我的where子句中的信息添加到Spock中的测试失败中?

时间:2016-09-26 16:01:52

标签: unit-testing groovy spock

如果我有以下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的值是什么,但我也想知道路径是什么时候看报告。如何在测试失败时获取测试报告以包含有关路径的信息?

1 个答案:

答案 0 :(得分: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
}