Given the Behat rule file "local/more_rules/tests/behat/behat_local_core_rules.php" and the generator file "local/more_rules/tests/generator/lib.php".
The rules class is build with
class behat_local_more_rules extends behat_base {}
The generator class is build with
class local_more_rules_generator extends testing_data_generator {}
To be able to call the generator methods I need the reference to the generator class. In "lib/tests/behat/behat_data_generators.php" I found the line that gets the datagenerator
$this->datagenerator = testing_util::get_data_generator();
When I call the same line in my rules script I get an error. My solution for now is to hard code the connection to the generator with
require_once(__DIR__.'/../generator/lib.php');
$this->generator = new local_more_rules_generator();
This code works but I hope there might be a more general solution.