3.2. Step - 02 : Run with undefined steps

As of now, we only have the test specifications as defined earlier.

# 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'

When we run behave, it would have nothing to test actually, but still let’s run it:

behave  --no-timings --no-source

As you can see, it has already tried to run few tests, but shows that few have filed, and we have undefined steps.

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'


Failing scenarios:
  features/simple-addition.feature:7  Addition of single digit numbers
  features/simple-addition.feature:12  Addition of double digit numbers

0 features passed, 1 failed, 0 skipped
0 scenarios passed, 2 failed, 0 skipped
0 steps passed, 0 failed, 0 skipped, 6 undefined
Took 0m0.000s

And it also gives us some kind of hint what we have to do and what is missing:


You can implement step definitions for undefined steps with these snippets:

@given(u'I have \'1\' and \'3\'')
def step_impl(context):
    raise NotImplementedError(u'STEP: Given I have \'1\' and \'3\'')


@when(u'I add them')
def step_impl(context):
    raise NotImplementedError(u'STEP: When I add them')


@then(u'The result must be \'4\'')
def step_impl(context):
    raise NotImplementedError(u'STEP: Then The result must be \'4\'')


@given(u'I have \'70\' and \'29\'')
def step_impl(context):
    raise NotImplementedError(u'STEP: Given I have \'70\' and \'29\'')


@then(u'The result must be \'99\'')
def step_impl(context):
    raise NotImplementedError(u'STEP: Then The result must be \'99\'')