Skip to main content

Behaviour Driven Development in Python

Project description

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:

  1. A developer starts using a unit testing framework (like unittest.py).

  2. The developer becomes more confident in the quality of his work.

  3. They realize that writing the tests first lets them concentrate on writing the code they needs.

  4. The developer notices that the tests document the code.

  5. Writing tests first helps the developer to design the API for their code.

  6. The developer realizes that TDD is about defining behaviour rather than testing.

  7. 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:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

Behaviour-0.1a4.zip (50.2 kB view details)

Uploaded Source

Behaviour-0.1a4.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Behaviour-0.1a4-py2.5.egg (46.0 kB view details)

Uploaded Egg

File details

Details for the file Behaviour-0.1a4.zip.

File metadata

  • Download URL: Behaviour-0.1a4.zip
  • Upload date:
  • Size: 50.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Behaviour-0.1a4.zip
Algorithm Hash digest
SHA256 995efd251a1f073efd48bbaad53e1cc08411cd1f31e2ffc9c54ae08b892c3bec
MD5 546de2b06eeee22d872c55eb09283eff
BLAKE2b-256 35233b5b8116652b4719dc9aa0fabd9b70494578f3de720a8f3682b98d9080e8

See more details on using hashes here.

File details

Details for the file Behaviour-0.1a4.tar.gz.

File metadata

  • Download URL: Behaviour-0.1a4.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Behaviour-0.1a4.tar.gz
Algorithm Hash digest
SHA256 4099f9f7e06f0be554c3fde11000d0e55bd82576cd6cac267eb504032e987eb8
MD5 b3ea2a873f40f1c95150abb9947cc4e4
BLAKE2b-256 59ed5075dee1e932d7ac493bf85b2e11e5923fb422836aa7730314ab80d1f825

See more details on using hashes here.

File details

Details for the file Behaviour-0.1a4-py2.5.egg.

File metadata

  • Download URL: Behaviour-0.1a4-py2.5.egg
  • Upload date:
  • Size: 46.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Behaviour-0.1a4-py2.5.egg
Algorithm Hash digest
SHA256 4df17b2d18f4afde839d462a4718364b800b68856b7393449982bcc82bbf6d9e
MD5 b01953165ff1b2ab09e67ee2cef8e112
BLAKE2b-256 6806b3dc8aebacd67451e056b2f40bdda989d523c0b98864f69942e159b9724c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page