Noteworthy in Version 1.2.7

Summary:

Support Gherkin v6 Grammar

Grammar changes:

  • Rule concept added to better correspond to Example Mapping concepts
  • Add aliases for Scenario and Scenario Outline (for similar reasons)

A Rule (or: business rule) allows to group multiple Scenario(s)/Example(s):

# -- RULE GRAMMAR PSEUDO-CODE:
@tag1 @tag2
Rule: Optional Rule Title...
    Description?        #< CARDINALITY: 0..1 (optional)
    Background?         #< CARDINALITY: 0..1 (optional)
    Scenario*           #< CARDINALITY: 0..N (many)
    ScenarioOutline*    #< CARDINALITY: 0..N (many)

Gherkin v6 keyword aliases:

| Concept          | Preferred Keyword | Alias(es)          |
| Scenario         | Example           | Scenario           |
| Scenario Outline | Scenario Outline  | Scenario Template  |

Example:

# -- FILE: features/example_with_rules.feature
# USING: Gherkin v6
Feature: With Rules

  Background: Feature.Background
    Given feature background step_1

  Rule: Rule_1
    Background: Rule_1.Background
      Given rule_1 background step_1

    Example: Rule_1.Example_1
      Given rule_1 scenario_1 step_1

  Rule: Rule_2

    Example: Rule_2.Example_1
      Given rule_2 scenario_1 step_1

  Rule: Rule_3
    Background: Rule_3.EmptyBackground
    Example: Rule_3.Example_1
      Given rule_3 scenario_1 step_1

Overview of the Example Mapping concepts:

Cucumber: `Example Mapping`_

Tag-Expressions v2

cucumber-tag-expressions are now supported and superceed the old-style tag-expressions (which are deprecating). cucumber-tag-expressions are much more readible and flexible to select tags on command-line.

# -- SIMPLE TAG-EXPRESSION EXAMPLES:
@a and @b
@a or  @b
not @a

# -- MORE TAG-EXPRESSION EXAMPLES:
# HINT: Boolean expressions can be grouped with parenthesis.
@a and not @b
(@a or @b) and not @c

Example:

# -- SELECT-BY-TAG-EXPRESSION (with tag-expressions v2):
# Sellect all features / scenarios with both "@foo" and "@bar" tags.
$ behave --tags="@foo and @bar" features/

Tag Matching with Tag-Expressions

The new tag-expressions also support partial string/tag matching with wildcards.

# -- FILE: features/one.feature
Feature: Alice

  @foo.one
  Scenario: Alice.1
    ...

  @foo.two
  Scenario: Alice.2
    ...

  @bar
  Scenario: Alice.3
    ...

The following command-line will select all features / scenarios with tags that start with “@foo.”:

$ behave -f plain --tags="@foo.*" features/one.feature
Feature: Alice

  Scenario: Alice.1
    ...

  Scenario: Alice.2
    ...

# -- HINT: Only Alice.1 and Alice.2 are matched (not: Alice.3).

Hint

  • Filename matching wildcards are supported. See fnmatch (Unix style filename matching).
  • The tag matching functionality is an extension to cucumber-tag-expressions.