I saw an example in ROR for testing some domain class:
context "Validations" do
[:city, :zip, :street].each do |attr|
it "must have a #{attr}" do
a = Address.new
a.should_not be_valid
a.errors.on(attr).should_not be_nil
end
end
end
It creates tests on the fly with different values an different names… It’s kind interesting, but… can I do this with spock or jUnit?
Thanks a lot
Using Spock:
If there is more than one data variable, table syntax is more convenient: