BDD using Lettuce

Writing Beautiful Tests that Last

By Amit Sethi / @dusual

BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.

- Dan North

Let's come to this definition, later

Tests are the requirements

  1. How are requirements created in your organization?
  2. User Stories.
  3. Can we have a DSL that can be understood by the PMs as well as your application

                 Feature: Manipulate strings
                   In order to have some fun
                   As a programming beginner
                   I want to manipulate strings
                 
                 Scenario: Uppercased strings
                   Given I have the string "lettuce leaves"
                   When I put it in upper case
                   Then I see the string is "LETTUCE LEAVES"
                                  

                from lettuce import *
                @step('I have the string "(.*)"')
                def have_the_string(step, string):
                    world.string = string
                
                @step
                def i_put_it_in_upper_case(step):
                    world.string = world.string.upper()
                
                @step
                def see_the_string_is(step, expected):
                    '''I see the string is "(.*)"'''
                    assert world.string == expected, 
                        "Got %s" % world.string
                                  

Some of our own examples

Ok, wise guy, how do you thing these last

  1. Setup Cost?
  2. The Business Guy gets them, can contribute to them.
  3. Coverage?? Its all about coverage
  4. Testing the app as a whole
  5. Automate and connect to your CI a process that you would be doing manually

Using different webdrivers and remote webdrivers

Saucelabs / BrowserStack

THE END