I am tagging the scenario with @api to use the drush driver and the first few steps work but adding the new users fails.
Looking at Drupal\DrupalExtension\Context\DrupalContext::createUsers() it would appear to be an issue in the drush driver ....

So .. Questions:

  1. What's going wrong?
  2. How do I get more diagnostics from the drush driver?
[@Iains-MBP BABuild]$ bin/behat 
@d8 @api
Feature: DrupalContext
  In order to prove the Drupal context is working properly for Drupal 8
  As a developer
  I need to use the step definitions of this context

  Scenario: Create and log in as a user                               # features/content/admin.feature:7
    Given I am logged in as a user with the "authenticated user" role # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
    When I click "My account"                                         # Drupal\DrupalExtension\Context\MinkContext::assertClick()
    Then I should see the text "Member for"                           # Drupal\DrupalExtension\Context\MinkContext::assertTextVisible()

  Scenario: Target links within table rows                            # features/content/admin.feature:12
    Given I am logged in as a user with the "administrator" role      # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
    When I am at "admin/structure/types"                              # Drupal\DrupalExtension\Context\MinkContext::assertAtPath()
    And I click "Manage fields" in the "Article" row                  # Drupal\DrupalExtension\Context\DrupalContext::assertClickInTableRow()
    Then I should be on "admin/structure/types/manage/article/fields" # Drupal\DrupalExtension\Context\MinkContext::assertPageAddress()
    And I should see the link "Add field"                             # Drupal\DrupalExtension\Context\MinkContext::assertLinkVisible()

  Scenario: Create users with roles                                  # features/content/admin.feature:19
    Given users:                                                     # Drupal\DrupalExtension\Context\DrupalContext::createUsers()
      | name     | mail             | roles         |
      | Joe User | joe@example.com  | Administrator |
      | Jane Doe | jane@example.com |               |
      (RuntimeException)
    And I am logged in as a user with the "administrator" role       # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
    When I visit "admin/people"                                      # Drupal\DrupalExtension\Context\MinkContext::assertAtPath()
    Then I should see the text "Administrator" in the "Joe User" row # Drupal\DrupalExtension\Context\DrupalContext::assertTextInTableRow()

--- Failed scenarios:

    features/content/admin.feature:19

3 scenarios (2 passed, 1 failed)
12 steps (8 passed, 1 failed, 3 skipped)
0m10.10s (16.64Mb)

Comments

iainH created an issue. See original summary.

iainH’s picture

Here's my 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://dev.bradford-abbas.uk
    Drupal\DrupalExtension:
      blackbox: ~
      api_driver: 'drush' 
      drush:
        alias: 'vagrant-badev.bradford-abbas.uk'

and my features/bootstrap/FeatureContext.php:

<?php

use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {

  /**
   * Initializes context.
   *
   * Every scenario gets its own context instance.
   * You can also pass arbitrary arguments to the
   * context constructor through behat.yml.
   */
  public function __construct() {
  }

}

and my features/content/admin.feature:

@d8 @api
Feature: DrupalContext
  In order to prove the Drupal context is working properly for Drupal 8
  As a developer
  I need to use the step definitions of this context

  Scenario: Create and log in as a user
    Given I am logged in as a user with the "authenticated user" role
    When I click "My account"
    Then I should see the text "Member for"

  Scenario: Target links within table rows
    Given I am logged in as a user with the "administrator" role
    When I am at "admin/structure/types"
    And I click "Manage fields" in the "Article" row
    Then I should be on "admin/structure/types/manage/article/fields"
    And I should see the link "Add field"

  Scenario: Create users with roles
    Given users:
    | name     | mail             | roles          |
    | Joe User | joe@example.com  | Administrator  |
    | Jane Doe | jane@example.com |                |
    And I am logged in as a user with the "administrator" role
    When I visit "admin/people"
    Then I should see the text "Administrator" in the "Joe User" row
iainH’s picture

Title: Help with failing "Given users:" » "Given users:" failing with drush driver
Component: Miscellaneous » Code
Category: Support request » Bug report
Issue summary: View changes

Given users: has a default step definition (re bin/behat -dl) that should work per the vendor tests.

greggles’s picture

Category: Bug report » Support request

It's a bit late now, but I found this when searching for a similar issue, so here's some ideas:

1. Did you read #2144025: Driver "drush" is not registered? That is similar and has some advice.
2. Did you try adding a 'drupal_root' entry?
3. Did you try using an ' api_driver: 'drupal'' ?

This seems to me mostly like a support issue. The steps work as long as the environment is properly configured. Getting that configuration is not easy and documentation and error messages could definitely be improved to help make it easier to get configuration right.