【发布时间】:2014-10-13 03:46:42
【问题描述】:
我有一个很长的表格,对于其中的 3 个字段,我需要分别测试它们是否填写正确或错误,因为错误会导致非常不同的操作。但是编写这样的集成测试非常乏味且不干:
# Test 1
describe "test where field3 fails" do
before do
fill_in "field1", with: "passing info"
fill_in "field2", with: "passing info"
fill_in "field3", with: "not passing info"
...
end
it "should lead to an error specific to field3" do
...
end
end
# Test 2
describe "test where field2 fails" do
before do
fill_in "field1", with: "passing info"
fill_in "field2", with: "not passing info"
fill_in "field3", with: "passing info"
...
end
it "should lead to an error specific to field2" do
...
end
end
# Test 3
describe "test where field1 fails" do
before do
fill_in "field1", with: "not passing info"
fill_in "field2", with: "passing info"
fill_in "field3", with: "passing info"
...
end
it "should lead to an error specific to field1" do
...
end
end
【问题讨论】:
标签: testing ruby-on-rails-4 rspec capybara integration-testing