Search the web
Sign In
New User? Sign Up
TestFirstUserInterfaces
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: TDD web site/app   Message List  
Reply | Forward Message #1028 of 1051 |
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



Thu Feb 12, 2009 8:12 pm

phlipcpp
Offline Offline
Send Email Send Email

Forward
Message #1028 of 1051 |
Expand Messages Author Sort by Date

... 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...
Phlip
phlipcpp
Offline Send Email
Feb 12, 2009
8:12 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help