views:

4512

answers:

6

Which are the most advanced frameworks and tools there are available for python for practicing Behavior Driven Development? Especially finding similar tools as rspec and mocha for ruby would be great.

+1  A: 

I am probably completely missing the point, but what I retained of the original BDD paper was that BDD was just TDD repackaged to emphasize some best practices.

If my interpretation is correct, you can get a BDD framework just by renaming methods around in any xUnit implementation. So just go ahead and use the standard library's unittest.

EDIT: A quick google turned up a Behaviour module in the Cheese Shop. Further searching for BDD there did not find anything else.

ddaa
TDD really is the revolutionizing practice in a totally different scale than BDD. Still I've come to appreciate way of writing test-drivenly in BDD style.
JtR
+5  A: 

Ian Bicking recommends using doctest for behavior driven design:

I personally tend to use nose and voidspace mock in a behavior driven design style. Specifically, the spec plugin for nose is excellent for BDD.

Ryan
Andrew Bennetts recently wrote a couple of post about why he thinks doctest are abused. http://andrew.puzzling.org/diary/2008/October/23/narrative-tests http://andrew.puzzling.org/diary/2008/October/24/more-doctest-problems
ddaa
I think doctest actually is more aligned with the philosophy of BDD, when you treat it as it was intended: you start writing about the software, and then intersperse that with examples that also form tests. It's been described as "document driven development" as well -- the point is to focus on outward describable functionality, not internal units of work. I think tradition xUnit *is* horrible at doing that.
ianb
+2  A: 

The Pyccuracy project is an effort to provide a domain-specific language for BDD in Python.

Unlike doctest, which works at the API level, it encodes higher-level operations such as loading a web page and submitting a form. I haven't used it but it looks somewhat promising if that is what you're looking for.

+1  A: 

I like Pyccuracy a lot. I'm implementing it on a mid sized project these days.

refack
+3  A: 

Lettuce means to be a cucumber-like tool for python: http://lettuce.it/

You can grab the source at github.com/gabrielfalcao/lettuce

+2  A: 

I recommend you to use Pyramid.
It's a set of tools developed to help programmers in the practice of BDD and TDD. It is basically composed by: pycukes, specloud, ludibrio and should-dsl.

Should-dsl will give you RSpec-like expectations.

Everything you can do with RSpec expectation API, should-dsl does too.

You can grab the last version here: http://github.com/rodrigomanhaes/should-dsl/tree/matchers-as-functions

Specloud helps you on running BDD-like unittests. You can install it by doing

pip install specloud

Ludibrio is a library for test doubles (Mocks, Stubs and Dummies). Install it via

pip install ludibrio

And PyCukes is the main tool for BDD. It will run the Scenarios, etc. Again,

pip install pycukes

For more info please read the tools documentation at PyPi.

Douglas Camata