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 unittetst, 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 Distribution

Behaviour-0.1a3.tar.gz (32.7 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.1a3-py2.5.egg (35.5 kB view details)

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for Behaviour-0.1a3.tar.gz
Algorithm Hash digest
SHA256 bec71392e9acd587ed9e6a630f3fe7d7fdd2a8f3c42ca7f0b6e250573ae4d8be
MD5 e30130cabe83d6e01c5cc74a50f1f6ec
BLAKE2b-256 c8bf9d9c41161972d98627c89b324cbfa4ae0dd93ff1e2e0adc12b5e8e121505

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for Behaviour-0.1a3-py2.5.egg
Algorithm Hash digest
SHA256 85ddc51fe98dca56df2f46d9b02e570f46507651cbf6dd5b1f3600a28c6d1e6c
MD5 45ee5bbe58cd24d4c9e5e17d74ecbaa5
BLAKE2b-256 44eb0cd7f3420940e8a8c3d9c66f6bf72b608b796810da8d0bf3d77051495652

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