I'm going though default settings (https://drupal.org/project/drupalextension) and I can't run basic black-box feature

LOCALHOST:/var/www/sandbox/drupal/behat $ bin/behat -v
@api
Feature: DrupalContext
  In order to prove the Drupal context is working properly
  As a developer
  I need to use the step definitions of this context

         
                            
  [InvalidArgumentException]         
  Driver "drush" is not registered. 

                                     

Exception trace:
 () at /var/www/sandbox/drupal/behat/vendor/drupal/drupal-extension/src/Drupal/Drupal.php:85
 Drupal\Drupal->setDefaultDriverName() at /var/www/sandbox/drupal/behat/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/Initializer/DrupalAwareInitializer.php:121
 Drupal\DrupalExtension\Context\Initializer\DrupalAwareInitializer->prepareDefaultDrupalDriver() at n/a:n/a
 call_user_func() at /var/www/sandbox/drupal/behat/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php:164
 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at /var/www/sandbox/drupal/behat/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php:53
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /var/www/sandbox/drupal/behat/vendor/behat/behat/src/Behat/Behat/Tester/ScenarioTester.php:69
 Behat\Behat\Tester\ScenarioTester->visit() at /var/www/sandbox/drupal/behat/vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php:42
 Behat\Gherkin\Node\AbstractNode->accept() at /var/www/sandbox/drupal/behat/vendor/behat/behat/src/Behat/Behat/Tester/FeatureTester.php:88
 Behat\Behat\Tester\FeatureTester->visit() at /var/www/sandbox/drupal/behat/vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php:42
 Behat\Gherkin\Node\AbstractNode->accept() at /var/www/sandbox/drupal/behat/vendor/behat/behat/src/Behat/Behat/Console/Command/BehatCommand.php:150
 Behat\Behat\Console\Command\BehatCommand->runFeatures() at /var/www/sandbox/drupal/behat/vendor/behat/behat/src/Behat/Behat/Console/Command/BehatCommand.php:128
 Behat\Behat\Console\Command\BehatCommand->execute() at /var/www/sandbox/drupal/behat/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
 Symfony\Component\Console\Command\Command->run() at /var/www/sandbox/drupal/behat/vendor/symfony/console/Symfony/Component/Console/Application.php:897
 Symfony\Component\Console\Application->doRunCommand() at /var/www/sandbox/drupal/behat/vendor/symfony/console/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at /var/www/sandbox/drupal/behat/vendor/behat/behat/src/Behat/Behat/Console/BehatApplication.php:68
 Behat\Behat\Console\BehatApplication->doRun() at /var/www/sandbox/drupal/behat/vendor/symfony/console/Symfony/Component/Console/Application.php:121
 Symfony\Component\Console\Application->run() at /var/www/sandbox/drupal/behat/vendor/behat/behat/bin/behat:32

Comments

greggles’s picture

I think I've had this problem when I didn't yet run "composer install" and/or didn't run behat --init.

Can you also post the contents of your composer.json and behat.yml file?

jhedstrom’s picture

Status: Active » Postponed (maintainer needs more info)
eliza411’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing after 1 year with no follow-up. Feel free to re-open with the requested information if this is still relevant.

joelpittet’s picture

Status: Closed (cannot reproduce) » Active

I'm seeing this as well.

Composer is installed, composer.json is installed, behat --init has been run.

/Users/joel/Sites/site/behat/behat.yml

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Behat\MinkExtension:
      goutte: ~
      selenium2: ~
      base_url: http://site.dev
    Drupal\DrupalExtension:
      blackbox: ~

/opt/drupalextension/composer.json

{
  "require": {
    "drupal/drupal-extension": "~3.0"
},
  "config": {
    "bin-dir": "bin/"
  }
}
joelpittet’s picture

Status: Active » Closed (works as designed)

Was missing

      api_driver: 'drush'
      drush:
        alias: 'em.dev'
default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Behat\MinkExtension:
      goutte: ~
      selenium2: ~
      base_url: http://eminence.dev
    Drupal\DrupalExtension:
      blackbox: ~
      api_driver: 'drush'
      drush:
        alias: 'myalias'

mark.labrecque’s picture

This fixed it for me! Thanks @joelpittet

greggles’s picture

Regarding #5/#6: I think it's optional to add the api_driver: 'drush' piece, but at least setting an alias that will work from the directory where the behat tests are run. Setting the api_driver will set that for all api tests and the drush driver is not as fast/feature-rich as the Drupal API driver. I solved this problem today by creating a working drush alias and then modifying my behat.yml like so:

      api_driver: 'drupal'
      drush:
        alias: 'workingdrushalias.dev'
      drupal:
        drupal_root: '/path/to/docroot/'