Features, Scenarios and Steps

Feature

class aloe.parser.Feature

A complete Gherkin feature.

Features can either be constructed from_file() or from_string().

description

The description of the feature (the text that comes directly under the feature).

dialect

The Gherkin dialect for the feature.

classmethod from_file(filename, language=None)

Parse a file or filename into a Feature.

classmethod from_string(string, language=None)

Parse a string into a Feature.

location

Location as ‘filename:line’

classmethod parse(string=None, filename=None, language=None)

Parse either a string or a file.

tags

Tags for a feature.

Tags are applied to a feature using the appropriate Gherkin syntax:

@tag1 @tag2
Feature: Eat leaves

Background

class aloe.parser.Background

The background of all Scenario in a Feature.

feature

The Feature this scenario belongs to.

location

Location as ‘filename:line’

Scenario

class aloe.parser.Scenario

A scenario within a Feature.

name

The name of this scenario.

feature

The Feature this scenario belongs to.

outlines

The examples for this scenario outline as a list of dicts mapping column name to value.

location

Location as ‘filename:line’

outlines_table

Return the scenario outline examples as a table.

tags

Tags for the feature and the scenario.

Step

class aloe.parser.Step

A single statement within a test.

A Scenario or Background is composed of multiple Step.

scenario

The Scenario this step belongs to (if inside a scenario).

background

The Background this step belongs to (if inside a background).

test

The instance of unittest.TestCase running the current test, or None if not currently in a test (e.g. in a each_feature() callback).

testclass

The unittest.TestCase used to run this test. Use test for the instance of the test case.

passed

The step passed (used in after and around).

failed

The step failed (used in after and around).

behave_as(sentence)

Execute another step.

Example:

self.behave_as("Given I am at the market")
given(sentence)

Execute another step.

Example:

self.given("I am at the market")
when(sentence)

Execute another step.

Example:

self.when("I buy two oranges")
then(sentence)

Execute another step.

Example:

self.then("I will be charged 60c")
container

The background or scenario that contains this step.

feature

The Feature this step is a part of.

hashes

Return the table attached to the step as an iterable of hashes, where the first row - the column headings - supplies keys for all the others.

e.g.:

Then I have fruit:
    | apples | oranges |
    | 0      | 2       |

Becomes:

({
    'apples': '0',
    'oranges': '2',
},)
keys

Return the first row of a table if this statement contains one.

location

Location as ‘filename:line’

multiline = None

A Gherkin multiline string with the appropriate indenting removed.

Then I have poem:
    """
    Glittering-Minded deathless Aphrodite,
    I beg you, Zeus’s daughter, weaver of snares,
    Don’t shatter my heart with fierce
    Pain, goddess,
    """
outline = None

If this step is a part of an outline, the reference to the outline.

parse_steps_from_string(string, **kwargs)

Parse a number of steps, returns an iterable of Step.

This is used by step.behave_as().

sentence = None

The sentence parsed for this step.

table = None

A Gherkin table as an iterable of rows, themselves iterables of cells.

e.g.:

Then I have fruit:
    | apples | oranges |
    | 0      | 2       |

Becomes:

(('apples', 'oranges'), ('0', '2'))