Aleksandras
Aleksandras

Reputation: 109

Is there a way to display a list of all custom step-definitions in terminal?

I'm struggling to find a way of displaying all custom step-definitions in terminal in the same way the "behat -dl" does this for MinkContext and its pre-defined steps. Is there some kind of a way to make all custom-declared steps to be be displayed as well? Here's how my FeatureContext.php header looks like so you'd get a better view of the way my steps are being stored.

MyCustomContext.php:

use Behat\Behat\Context\CustomSnippetAcceptingContext;
use Drupal\DrupalExtension\Context\MinkContext as MinkContext;

class MyCustomContext extends MinkContext implements CustomSnippetAcceptingContext

Upvotes: 0

Views: 248

Answers (1)

Lindsay Macvean
Lindsay Macvean

Reputation: 248

Full disclosure: I work with Alex so had access to his source code.

The answer is actually to alter the behat.yml file to the following:

default:
  paths:
    features: %paths.base%/features/
    bootstrap: %paths.base%/features/bootstrap 
  contexts:
    # - Drupal\DrupalExtension\Context\DrupalContext
    # - Drupal\DrupalExtension\Context\MessageContext
    - InvotraWebContext

The key was to reference the bootstrap location so that behat loads the php files with custom contexts in them, then add the class name (InvotraWebContext) of the custom context into the 'contexts' values. I also had to comment out the existing custom contexts which are actually parent classes of the custom context we actually want to reference (otherwise behat gets confused about duplicate steps).

The final step is to run

bin/behat -dl

Upvotes: 1

Related Questions