3.1. Step - 01 : Initial structureΒΆ

To run behave, we need the following directory structure:

.
|-- features
|   |-- steps
|   |   `-- steps_addition.py
|   |-- environment.py
|   `-- simple-addition.feature
`-- libmath.py

The contents of the files as under for the time being.

  • libmath.py

    This is the file would eventually have the logic want to test. The contents of the file as as under.

    # libmath.py
    
    # Empty for time being
    
  • features/simple-addition.feature

    This file has the BDD Tests.

    # features/sample-addition.feature
    
    Feature: Simple Addition
    
        Showcase simple addition for the BDD Book.
    
        Scenario: Addition of single digit numbers
            Given I have '1' and '3'
            When I add them
            Then The result must be '4'
    
        Scenario: Addition of double digit numbers
            Given I have '70' and '29'
            When I add them
            Then The result must be '99'
    
  • features/environment.py

    This file would have (in later chapters) hooks/common implementation.

    # environment.py
    # Empty for time being
    
  • features/steps/steps_addition.py

    This file is mapping between features/simple-addition.feature and libmath.py. We will add implementation in this file, in later chapters.

    # features/steps/steps_addition.py
    # Empty for time being