이렇게 테스트를하고 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