Skip to content

Collection of Behat step definitions

Notifications You must be signed in to change notification settings

steveworley/behat-steps

 
 

Repository files navigation

Behat Steps

Collection of Behat steps for Drupal development.

CircleCI Latest Stable Version Total Downloads License

Why traits?

Usually, such packages implement own Drupal driver with several contexts, service containers and a lot of other useful architectural structures. But for this simple library, using traits helps to lower entry barrier for usage, maintenance and support. This package may later be refactored to use proper architecture.

Installation

composer require --dev integratedexperts/behat-steps

Usage

In FeatureContext.php:

<?php

use Drupal\DrupalExtension\Context\DrupalContext;
use IntegratedExperts\BehatSteps\D7\ContentTrait;
use IntegratedExperts\BehatSteps\D7\DomainTrait;
use IntegratedExperts\BehatSteps\D7\EmailTrait;
use IntegratedExperts\BehatSteps\D7\OverrideTrait;
use IntegratedExperts\BehatSteps\D7\ParagraphsTrait;
use IntegratedExperts\BehatSteps\D7\UserTrait;
use IntegratedExperts\BehatSteps\D7\VariableTrait;
use IntegratedExperts\BehatSteps\D7\WatchdogTrait;
use IntegratedExperts\BehatSteps\D8\MediaTrait;
use IntegratedExperts\BehatSteps\DateTrait;
use IntegratedExperts\BehatSteps\Field;
use IntegratedExperts\BehatSteps\FieldTrait;
use IntegratedExperts\BehatSteps\LinkTrait;
use IntegratedExperts\BehatSteps\PathTrait;
use IntegratedExperts\BehatSteps\ResponseTrait;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends DrupalContext {

  use ContentTrait;
  use DomainTrait;
  use EmailTrait;
  use MediaTrait;
  use OverrideTrait;
  use ParagraphsTrait;
  use PathTrait;
  use UserTrait;
  use VariableTrait;
  use WatchdogTrait;
  use DateTrait;
  use FieldTrait;
  use LinkTrait;
  use PathTrait;
  use ResponseTrait;

}

Development

Local environment setup

  1. Make sure that you have make, composer, Docker and Pygmy installed.
  2. Checkout project repo
  3. Set the version of Drupal to run test against in .env.local file: DRUPAL_VERSION = 7
  4. pygmy up
  5. make build

Behat tests

  • Run all tests: make test-behat
  • Run all scenarios in specific feature file: make test-behat -- path/to/file
  • Run all scenarios tagged with @wip tag: make test-behat -- --tags=wip

To debug tests from CLI:

  1. SSH into CLI container: docker-compose -p behatsteps exec cli sh

  2. ./xdebug.sh vendor/bin/behat -p d7 path/to/file

    IMPORTANT: When running tests directly, always specify profile for the version of Drupal your are running:

    vendor/bin/behat -p d7
    

    or

    vendor/bin/behat -p d8
    

About

Collection of Behat step definitions

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 87.2%
  • Gherkin 9.6%
  • Makefile 3.1%
  • Shell 0.1%