Behaviour 0.1a4
Behaviour Driven Development in Python
Behaviour provides a language suitable for Behaviour Driven Development (BDD), as opposed to post-coding unit testing. It operates as a facade over Python's unit testing framework.
What is Behaviour Driven Development?
BDD is a derivative of Test Driven Development (TDD), evolving out of the observed adoption-life-cycle for TDD:
- A developer starts using a unit testing framework (like unittest.py).
- The developer becomes more confident in the quality of his work.
- They realize that writing the tests first lets them concentrate on writing the code they needs.
- The developer notices that the tests document the code.
- Writing tests first helps the developer to design the API for their code.
- The developer realizes that TDD is about defining behaviour rather than testing.
- The developer adopts mocking as a fundamental approach to support component interactions.
BDD supports the progression through that life-cycle, particularly the last three steps.
BDD supports this transition is by providing an appropriate language. Frameworks for BDD talk about either specifications (e.g., RSpec for Ruby, NSpec for C#.NET) or behaviours (e.g., JBehave for Java, NBehave for .NET).
For more information on BDD, see:
- Introducing BDD by Dan North;
- A New Look at Test-Driven Development by Dave Astels;
What does Behaviour do for Me?
Behaviour allows you to say things like:
class verifyUserSpecification( behaviour.Behaviour ):
def setUp( self ):
self.user = User( "Mark Dancer" )
def verifyInitialUserNameIsNameInConstructor( self ):
self.shouldBeEqual( self.user.name, "Mark Dancer" )
def verifyInitialUserHasNoLanguages( self ):
self.shouldBeEmpty( self.user.languages )
This has no more expressive power than what is offered by unittest:
class testUser( unittest.TestCase ):
def setUp( self ):
self.user = User( "Mark Dancer ")
def testName( self ):
self.failUnlessEqual( self.user.name, "Mark Dancer" )
def testLanguages( self ):
self.failUnless( self.user.languages = [] )
What it does offer is an alternative set of semantics.
With the semantics of unittest, we are testing a piece of code that we have already written.
With Behaviour, we are writing a specification for the piece of code we are about to write. It is much clearer with BDD that the specification is written before the code.
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| Behaviour-0.1a4-py2.5.egg (md5) | Python Egg | 2.5 | 2007-12-22 22:48:23 | 44KB | 358 |
| Behaviour-0.1a4.zip (md5) | Source | 2007-12-22 22:48:18 | 49KB | 227 | |
| Behaviour-0.1a4.tar.gz (md5) | Source | 2007-12-22 22:48:14 | 28KB | 262 | |
- Author: Mark Dancer <mark dancer at pobox com>
- Keywords: behaviour driven development design unit test testing unittest
-
Categories
- Development Status :: 3 - Alpha
- Environment :: Console
- Intended Audience :: Developers
- License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
- Operating System :: MacOS :: MacOS X
- Operating System :: Microsoft :: Windows
- Operating System :: OS Independent
- Operating System :: Unix
- Programming Language :: Python
- Topic :: Software Development :: Testing
- Package Index Owner: Aelfric
- DOAP record: Behaviour-0.1a4.xml
Log in to rate this package.
