From: James Britt Date: 2008-08-03T15:26:31+09:00 Subject: Re: unit testing advice David A. Black wrote: > Hi -- > > On Sun, 3 Aug 2008, James Britt wrote: > >> Isn't the idea of TDD and BDD that you discover what classes and >> method are needed by writing the tests first? So there *should* be no >> model in place prior to writing the test; the initial failure of the >> test is what drive the creation of the model. > > That may be the ideal for some people, but not for me when I'm > modeling a domain and especially when I'm working out a database > schema. I don't consider unit tests to have superseded the other tools > that support those activities, including blank pieces of paper and > index cards and so on. I guess you could write unit tests for a Rails > app before creating the models, if you mocked up the objects' > attributes, their associated objects, and so on (since there would > presumably be no database yet), and then rename your files so they > don't get clobbered when you generate the test files... but it seems > like it would be terribly arduous, with no real gain, and I don't > think I've ever seen anyone do it. http://www.infoq.com/interviews/Dave-Astels-and-Steven-Baker# Quote: I guess you don't use the Rails code generation then. Steven: No, not at all. I use TDD to generate code manually. So you don't even do model generation with Rails? Steven: Not at all. Especially when I'm pairing with somebody who's never used Rails before or who has never done TDD before I find it especially important not to rely on the generator to give me test stubs, to give me things that I should know or that I should be providing for myself. When the failings specifications tell me that I need it, because that would be contradicting what I'm trying to teach. -- James Britt www.happycamperstudios.com - Wicked Cool Coding www.jamesbritt.com - Playing with Better Toys www.ruby-doc.org - Ruby Help & Documentation www.rubystuff.com - The Ruby Store for Ruby Stuff