3.8. Step - 08 : Catalog of documented stepsΒΆ

If we have added more documentation in features/steps/*.py, e.g.

# features/steps/steps_addition.py

"""
Addition of numbers
=====================

Depends on libmath to do addition.

"""

from behave import given, when, then

@given(u"I have '{num1:d}' and '{num2:d}'")
def given_i_have(context, num1, num2):
    """ We store num1 and num2 to context.math

    Inputs:
        - num1 : Any number
        - num2 : Any number

    """
    context.math.doStoreNum1Num2(num1, num2)


@when(u"I add them")
def when_i_add(context):
    """ We add num1 and num2 of context.math """
    context.math.doAdd()

@then(u"The result must be '{value:d}'")
def then_the_result_must_be(context, value):
    """ We ensure expected value matches in context.math """
    actual_value = context.math.getValue()
    assert value == actual_value, "Expected %d got %d"%(value, actual_value)

behave shows the catalog with documentation with this command:

behave --no-color --format steps.catalog --dry-run --no-summary

The catalog looks as below:

Given I have '{num1:d}' and '{num2:d}'
  Location: features/steps/steps_addition.py:13
    We store num1 and num2 to context.math
    
    Inputs:
        - num1 : Any number
        - num2 : Any number

When I add them
  Location: features/steps/steps_addition.py:25
    We add num1 and num2 of context.math

Then The result must be '{value:d}'
  Location: features/steps/steps_addition.py:30
    We ensure expected value matches in context.math