Sijo Kg wrote:

>     Could anybody please tell me what these?BehaviouralDrivenDevelopment
> and TestDrivenDevelopment ? what are their pros and cons?

TDD means you never write new lines of code until you have a failing test case 
that expects the code to exist.

A test case follows the Assemble Activate Assert pattern.

    def test_case
      a = assemble()
      q = a.activate(41)
      assert{ q == 42 }
    end

All TestCases first Assemble the data resources they intend to use.

Then they Activate a target method. (Preferrably the one you name your real 
test 
case after!)

Then they Assert that some side-effect, from that method, is within tolerance.

You write one of those first, get it to fail for the correct reason, and only 
then write new production code to pass the test. Repeating this in tiny cycles 
helps you avoid endless debugging.

Behavior Driven Development is TDD reinvented to use a literate framework. By 
"literate" I mean you try to use the verbiage that your client uses when 
expressing your business rules as requirements and specifications. So the AAA 
pattern becomes:

   specify 'the assembled activator adds 1 to its input' do
     a = assemble()
     q = a.activate(41)
     q.should.equal 42
   end

After that grammatical transformation, most of the concepts are the same. When 
you BDD-first, and write failing specs before passing them with new code, you 
are essentially doing TDD.

 > And which is
> preferred by rails?

Either. All projects should have tests (or specs), but Rails makes them easier 
than some systems we could mention because Rails was invented using TDD. And 
BDD 
specs can use the same "mock objects" as the TDD to write the same kinds of 
tests.

BDD has a slight "con", compared to TDD, because you need tons of extra 
verbiage 
(.should, .should_not, etc.) to get anything done. The BDD system (such as 
test/spec) will provide them, but you must still use them, and they don't look 
very programmerly. BDD is for high-level tests.

TDD has a slight "con" over BDD, because you cannot easily nest test cases, so 
each one tests a variation of the other. BDD does that very well. TDD is for 
low-level tests.

Neither have any "con" over the alternative - Code And Fix. No project should 
ever not have unit tests, and I can think of a project that should not use 
test-first.

-- 
   Phlip


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to