Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 在Spock测试中根据输入创建组合_Unit Testing_Groovy_Spock - Fatal编程技术网

Unit testing 在Spock测试中根据输入创建组合

Unit testing 在Spock测试中根据输入创建组合,unit-testing,groovy,spock,Unit Testing,Groovy,Spock,在我的Spock测试中,这是我当前的where块 where: [A,B,C] << [ ["A1","B1","C1"], ["A1","B1","C2"], ] 其中: [A,B,C]这里有一个解决方案: where: [A, B, C] << [[["A1","B1"]],["C1","C2"]].combinations()*.flatten() 其中: [A,B

在我的Spock测试中,这是我当前的where块

where:
        [A,B,C] << 
        [
            ["A1","B1","C1"],
            ["A1","B1","C2"],
        ]
其中:
[A,B,C]这里有一个解决方案:

where:
[A, B, C] << [[["A1","B1"]],["C1","C2"]].combinations()*.flatten()
其中:

[A,B,C]你需要这样的东西:

where:
    [A, B, C] << [
        ['a1', 'a2', 'a3'],
        ['b1', 'b3'],
        ['c1']
    ].combinations()
其中:

谢谢彼得,这正是我想要的。但我能说什么呢。在这个组合之后,在[A,B,C]处执行此操作。您可以使用
+
添加两个表达式/集合,或者将
[“C1”,“C2”]
更改为
[“C1”,“C2”,“C3”,“C4”]
。可能是时候移动

where:
    [A, B, C] << [
        ['a1', 'a2', 'a3'],
        ['b1', 'b3'],
        ['c1']
    ].combinations()