Skip to content

rule_sequence_interface Class Reference

Bill Moore edited this page Sep 20, 2024 · 5 revisions

rule_sequence_interface

Name Description
Class rule_sequence_interface Interface for rule-level context sequences.
get_rule() Gets a reference to the rule object.

Class rule_sequence_interface

interface class rule_sequence_interface extends pool_provider_interface;

Interface for rule-level context sequences.

The rule-level context sequences implement this interface. A user step definition sequence can access the current rule-level context sequence through its get_current_rule_sequence() function.

get_rule()

pure virtual function gherkin_pkg::rule get_rule();

Gets a reference to the rule object.

When Bathtub parses a rule in a Gherkin feature file, Bathtub creates a gherkin_pkg::rule object for it. The rule-level context sequence contains a reference to the rule object. A user step definition sequence can retrieve a reference to the rule object with the context sequence's implementation of this function, e.g.:

gherkin_pkg::rule my_rule = (get_current_rule_sequence() == null) ? null : get_current_rule_sequence().get_rule();

Rules are optional in Gherkin feature files, so it's a good practice to check if the rule is present by testing if the rule sequence reference is null.