Considering test complexity
When programming, you tend to reach for abstractions to simplify code and reduce complexity. Since automated testing is just another form of programming, there is a natural tendency to use the same approach when writing tests. However, with abstraction comes indirection, and often complexity. For example, you may have three tests that do similar things, like in the following code snippet:
describe Foo do it "should have bar return a Bar instance" do _(Foo.new.bar).must_be_kind_of(Bar) end it "should have baz return a Baz instance" do _(Foo.new.baz).must_be_kind_of(Baz) end it "should have quux return a Quux instance" do _(Foo.new.quux).must_be_kind_of(Quux) end end
The programmer's natural inclination is to see the pattern and create an abstraction for it:
describe Foo...