このようなテストを行い、where句データテーブルを再利用可能なブロックに抽出できますか?Spock:再利用可能なデータテーブル
@Unroll
void "test that doSomething with #a and #b does not fail"(String a, String b) {
when:
doSomethingWithAandB(a, b)
then:
notThrown(Exception)
where:
a | b
"foo" | "bar"
"foo" | "baz"
"foo" | "foo"
}
このような何か(擬似コード):
@Unroll
void "test that doSomethingElse with #a and #b does not fail"(String a, String b) {
when:
doSomethingElseWithAandB(a, b)
then:
notThrown(Exception)
where:
dataTable()
}
def dataTable(a, b) { // this is now reusable in multiple tests
a | b
"foo" | "bar"
"foo" | "baz"
"foo" | "foo"
}
こちらをご覧ください:https://stackoverflow.com/questions/26156544/using-spock-data-table-for-filling-objects – Opal