6060STEP_PARAM_RE = re .compile (r"\<(.+?)\>" )
6161COMMENT_RE = re .compile (r'(^|(?<=\s))#' )
6262
63+ TYPES_WITH_DESCRIPTIONS = [types .FEATURE , types .SCENARIO , types .SCENARIO_OUTLINE ]
64+
6365
6466def get_step_type (line ):
6567 """Detect step type by the beginning of the line.
@@ -291,7 +293,8 @@ def __init__(self, basedir, filename, encoding="utf-8", strict_gherkin=True):
291293 multiline_step = False
292294 stripped_line = line .strip ()
293295 clean_line = strip_comments (line )
294- if not clean_line and (not prev_mode or prev_mode not in types .FEATURE ):
296+ if not clean_line and (not prev_mode or prev_mode not in TYPES_WITH_DESCRIPTIONS ):
297+ # Blank lines are included in feature and scenario descriptions
295298 continue
296299 mode = get_step_type (clean_line ) or mode
297300
@@ -340,6 +343,13 @@ def __init__(self, basedir, filename, encoding="utf-8", strict_gherkin=True):
340343 # Remove Feature, Given, When, Then, And
341344 keyword , parsed_line = parse_line (clean_line )
342345 if mode in [types .SCENARIO , types .SCENARIO_OUTLINE ]:
346+ # Lines between the scenario declaration
347+ # and the scenario's first step line
348+ # are considered part of the scenario description.
349+ if scenario and not keyword :
350+ scenario .add_description_line (parsed_line )
351+ continue
352+
343353 tags = get_tags (prev_line )
344354 self .scenarios [parsed_line ] = scenario = Scenario (self , parsed_line , line_number , tags = tags )
345355 elif mode == types .BACKGROUND :
@@ -435,6 +445,7 @@ def __init__(self, feature, name, line_number, example_converters=None, tags=Non
435445 self .tags = tags or set ()
436446 self .failed = False
437447 self .test_function = None
448+ self ._description_lines = []
438449
439450 def add_step (self , step ):
440451 """Add step to the scenario.
@@ -456,6 +467,22 @@ def steps(self):
456467 result .extend (self ._steps )
457468 return result
458469
470+ def add_description_line (self , description_line ):
471+ """Add a description line to the scenario.
472+
473+ :param str description_line:
474+ """
475+ self ._description_lines .append (description_line )
476+
477+ @property
478+ def description (self ):
479+ """Get the scenario's description.
480+
481+ :return: The scenario description
482+ """
483+ return u"\n " .join (self ._description_lines ).strip ()
484+
485+
459486 @property
460487 def params (self ):
461488 """Get parameter names.
0 commit comments