Using Spock:
class Validations extends Specification {
def "must have a #attr"() {
def a = new Address()
expect:
!a.valid
a.errors.on(attr) != null
where:
attr << ["city", "zip", "street"]
}
}
If there is more than one data variable, the table syntax is more convenient:
...
where:
attr1 | attr2
"city" | ...
"zip" | ...
"street" | ...
source
share