Codeception / Codeception

Full-stack testing PHP framework
http://codeception.com
MIT License
4.75k stars 1.3k forks source link

Gherkin parser #6389

Open ciaranmcnulty opened 2 years ago

ciaranmcnulty commented 2 years ago

Hi,

I wanted to draw your attention to cucumber/gherkin, which I recently built within the cucumber org

The plan is to eventually replace behat/gherkin in Behat with this parser. Probably as a stepping stone, behat/gherkin will become a compatibility layer that depends on the new parser.

You may want to jump the queue and depend on it directly ;)

It has a nice concept called a Pickle, which is basically a list of steps (i.e. things like scenario outlines, backgrounds are all totally flattened)

$parser = new GherkinParser(
    includeSource: false, // don't provide file + contents 
    includeGherkinDocument: false, // don't provide ASTs
    includePickles: true, // do include pickles
);

foreach ($parser->parseString($url, $contents) as $message)
{
    foreach ($message->pickle?->steps ?? [] as $step) {
        $step->text; // e.g. 'Given I have a pickle'
        $step->tags; // any tags that were on the scenario, rule, feature...
    }
}

Hit me up if you want to talk through it

Naktibalda commented 2 years ago

Setting lower bound of supported PHP versions at 8.1 is a bit extreme. We could use it in Codeception 5 if it supported PHP 8.0.