GithubHelp home page GithubHelp logo

xurizaemon / behat-steps Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drevops/behat-steps

0.0 2.0 0.0 608 KB

Collection of Behat step definitions for Drupal

License: GNU General Public License v3.0

PHP 80.57% Gherkin 15.88% Shell 0.66% HTML 2.88%

behat-steps's Introduction

Behat Steps

Collection of Behat steps for Drupal

CircleCI GitHub release (latest by date) 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 drevops/behat-steps

Heads up! Version 1.5.0 requires adding custom repositories to your project and allowing patching!

Until upstream dependencies implement full support for Drupal 10, this project uses forked dependencies (maintained by DrevOps team). The follow-up release(s) of Behat Steps will have these reverted.

Add the following to your composer.json:

{
    "require-dev": {
        "drevops/behat-steps": "^1.5",
        "cweagans/composer-patches": "^1.7",
        "drupal/drupal-extension": "dev-feature/drupal-10 as 4.2.1-dev"
    },
    "repositories": {
        "drupal/drupal-driver": {
            "type": "vcs",
            "url": "https://github.com/drevops/DrupalDriver"
        },
        "drupal/drupal-extension": {
            "type": "vcs",
            "url": "https://github.com/drevops/drupalextension"
        }
    },
    "prefer-stable": true,
    "minimum-stability": "dev",
    "extra": {
        "enable-patching": true
    },
    "config": {
        "allow-plugins": {
            "cweagans/composer-patches": true
        }
    }   
}

Usage

Add required traits to FeatureContext.php (example):

<?php

use Drupal\DrupalExtension\Context\DrupalContext;
use DrevOps\BehatSteps\ContentTrait;

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

  use ContentTrait;

}

Exceptions

  • \Exception is thrown for all assertions.
  • \RuntimeException is thrown for any unfulfilled requirements within a step.

Available steps

Use behat -d l to list all available step definitions.

There are also several pre and post scenario hooks that perform data alterations and cleanup.

Skipping before scenario hooks

Some traits provide beforeScenario hook implementations. These can be disabled by adding behat-steps-skip:METHOD_NAME tag to your test.

For example, to skip beforeScenario hook from JsTrait, add @behat-steps-skip:jsBeforeScenarioInit tag to the feature.

Development

Local environment setup

  • Make sure that you have latest versions of all required software installed:
  • Make sure that all local web development services are shut down (Apache/Nginx, Mysql, MAMP etc).
  • Checkout project repository (in one of the supported Docker directories).
  • pygmy up
  • ahoy build for Drupal 9 build or DRUPAL_VERSION=7 ahoy build for Drupal 7.
  • Access built site at http://behat-steps.docker.amazee.io/

To develop for another Drupal version, run ahoy build again.

Use ahoy --help to see the list of available commands.

Apple M1 adjustments

Copy default.docker-compose.override.yml to docker-compose.override.yml.

Behat tests

After every ahoy build, a new installation of Drupal is created in build directory. This project uses fixture Drupal sites (sites with pre-defined configuration) in order to simplify testing (i.e., the test does not create a content type but rather uses a content type created from configuration during site installation).

  • Run all tests: ahoy test-bdd
  • Run all scenarios in specific feature file: ahoy test-bdd path/to/file
  • Run all scenarios tagged with @wip tag: ahoy test-bdd -- --tags=wip
  • Tests tagged with @d7 or @d9 will be run for Drupal 7 and Drupal 9 respectively.
  • Tests tagged with @d7 and @d9 are agnostic to Drupal version and will run for all versions.

To debug tests from CLI:

  • ahoy debug
  • Set breakpoint and run tests - your IDE will pickup incoming debug connection.

To update fixtures:

  • Make required changes in the installed fixture site
  • Run ahoy drush cex -y for Drupal 9 or ahoy drush fua -y for Drupal 7
  • Run ahoy update-fixtures for Drupal 9 or DRUPAL_VERSION=7 ahoy update-fixtures for Drupal 7 to export configuration changes from build directory to the fixtures directory.

For an end-to-end website DevOps setup, check out DrevOps - Build, Test, Deploy scripts for Drupal using Docker and CI/CD

behat-steps's People

Contributors

aieksandr avatar alexskrypnyk avatar joshua1234511 avatar jrfnl avatar piggito avatar richardgaunt avatar steveworley avatar xurizaemon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.