From: Phlip Date: 2009-04-05T11:14:26+09:00 Subject: Re: [Ann] Verify, a very basic testing tool. Jeremy McAnally wrote: > Though, I do have a question/concern/confusion/something. I > completely and utterly fail to see the point of these new closure > obsessed frameworks or tools. Expensive setup is a design smell. That said, sometimes your setups are expensive. Consider this outline: describe 'frob_controller' do setup do @p_frobs = assemble_some_paid_up_frobs() end specify ... specify ... specify 'behaviors of paid-up frobs' describe 'delinquent frobs' setup do @d_frobs = assemble_some_delinquent_frobs() end specify 'how paid-up and delinquent frobs interact' do mess_with_both @p_frobs, @d_frobs end end end The first setup builds ideal frobs, and the specify blocks (elided) test them. The second setup is nested, so its specifications run with both setups. The nested specify blocks can use both kinds of frobs, together. You get this by directly illustrating how the concepts nest. You don't need to write each setup once and then somehow re-use it into various test suites. A 'def test_frob' is a legacy of Java and its block-free programming styles. Yet a test case is _not_ a method. You should not want to call it. Treating blocks of testing code as objects makes weaving them together easier. Contrast the "abstract test pattern", which Test::Unit::TestCase makes an absolute pain in the 'nads. It's probably just as much fun in Java... -- Phlip