Re: TDD web site/app

Phlip <[email protected]> Thu, 12 Feb 2009 12:12:44 -0800
Newsgroups gmane.comp.programming.test-driven-development,gmane.comp.programming.test-first-user-interfaces
Message-ID <[email protected]>
Mark Levison wrote:

>> - test the model in isolation from the controllers & view
> 
> So you would Mock the controllers and the views in this case?

If you look up an MVC diagram, the Model only has inbound arrows. Or the 
equivalent. To TDD the Model you simply ignore the controllers and views, 
because MVC requires them to decouple.

>> - TDD new back-end features from the bottom up, not top-down
> 
> Bottom up? How do you do that? Don't you normally Test Drive from the top
> down? Building only what you need along the way?

Anything the user can do to the Model thru the Views and Controllers, a unit 
test can do the same way, bypassing them. Get a list, select an item, update it, 
etc. So bottom-up should be just as good as top down.

Top-down is also part of TDD's algorithm generation concepts...

>> - abstract relationships, such as has-many, into accessors on records
> 
> I'm even more confused. Hopefully the example will cover both.

In ActiveRecord:

class Order < ActiveRecord::Base
   has_many :line_items
end

That's enough to find a table in the database called 'orders', find another 
table called 'line_items', find their field 'order_id', and use it to populate 
an array of LineItem model objects. The SQL is all hidden inside this, stretched 
out among the declarations and conventions.

>> - test from a pool of example models ("fixtures") that mix-and-match
>> business rules
> 
> Are you saying use sufficient sample data to exercise the paths through the
> business rules.

TDD will give you that. Rails makes it easy by letting you declare these pools 
of records in your versioned source, _not_ in your database instance.

-- 
   Phlip


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/testdrivendevelopment/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/testdrivendevelopment/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/