Given we want to design the django polls application, sequentially how do we go about doing the BDD

31 views
Skip to first unread message

noobplusplus

unread,
Sep 20, 2012, 11:19:19 PM9/20/12
to lettuc...@googlegroups.com
Lets say I want to develop the django polls application. If I go about doing TDD, the way I would go about is:

  1. Write test for models, then make the tests pass.
  2. Write test for forms, then make them pass.
  3. Write test for views, then make them pass.
  4. Write any other test for custom template tags and middlewares, and make them pass. 
  5. Keep on writing integration tests progressively, since the time I start writing views. 
If I write BDD, what would be a good sequence to follow?
In case I do BDD do I *not* write unittests? 
How does unittesting come around BDD?

Also, I have read people talking about, using Selenium alongside. I already write integration test using selenium, how does it fit into the BDD scenario?

Please, let me know.
Thanks!

Janghwan Kim

unread,
Sep 21, 2012, 10:59:05 PM9/21/12
to lettuc...@googlegroups.com
I remember reading about "BDD style" in The Rspec Book
It was interesting to see that it goes to the 'opposite direction' of what I have been thinking.

BDD is about writing specs(a.k.a test) first from a user point of view rather than the programmer.

It roughly goes like this:
  1. Write spec for a feature(or a scenario), and see it fail.  [user view]
  2. Think how to make a view, write a spec, see it fail.
  3. Now write code for view (specs pass, now you have non functioning HTML page)
  4. Think how make it function, write spec for controllers, see it fail.
  5. Write code for controller (pass, now you have functioning HTML page without data)
  6. Think how to manage data, write spec for model, see it fail.   [programmer view]
  7. Write code for model and see it pass.
  8. Now a feature spec will pass.
  9. Continue to next feature.
The steps may be omitted or expanded per case.

Given that the core concepts of BDD and TDD are not different, it doesn't matter to do unittest in BDD style.
I think the whole thing about BDD is to encourage the programmer to think of writing a spec first, rather than "implement a test after the code".

Selenium, Rspec and Lettuce will play a role in the first step: a user-level spec (or a feature) that guarantees working.
You can write a feature with lettuce, run with selenium to ensure the integration of the whole feature.

Somewhat debatable, but nice to keep in mind what the philosophy of BDD is for.
Reply all
Reply to author
Forward
0 new messages