Django BDD & Aloe

Elad Silberring

What Is BDD?

BDD is a development process providing shared tools to different teams by implementing tests using "plain text sentences" (Gherkin syntax ) which are translated into code.

Feature: Test account app functionality
    Given we have 1 user named: homer@dough.com
    And user is active

    Scenario: test user login
        Given I access the site with default user at url "account/login/"
        Then I should see that tab number "1" is active
        And I wait "1" seconds
        Then I should see "homer@dough.com" in the "username" container by id

cons

pros

  • Define the business problem you want to solve 
  • No explicit dictionary
  • Duplicated examples
  • Contains a large number of steps
  • Introduces a common language understood by all clients
  • Discovers what should happen when… unusual situations

OK, I got the point now how do I add it in django?

foo.feature:

This is the file with our "plain text", Files ending with 'feature' extension means it written in gherkins

steps.py

This is our python (Rules!) file which we will write our code translation for the gherkin text

definitions:

Scenario - This is the test itself with its title, Each scenario will usually have the key words given, and, when and then.

Feature - This is the place to describe what you are testing and possibly what assumptions you have before testing (this can also be done in the Background )

Background - any assumptions you have before testing, IMOP this can be left out of the framework as most projects do this in the feature

example!

Django BDD & Aloe

By Elad Silberring

Django BDD & Aloe

  • 1,197