Spock – Testing Exceptions with Data Tables

The recommended solution is to have two methods: one that tests the good cases, and another that tests the bad cases. Then both methods can make use of data tables. Example: class SomeSpec extends Specification { class User { String userName } def ‘validate valid user'() { when: validateUser(user) then: noExceptionThrown() where: user << [ … Read more