GithubHelp home page GithubHelp logo

stof / behat-screenshot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elvetemedve/behat-screenshot

0.0 3.0 0.0 63 KB

This is an extension for Behat which provides debugging functionality by taking a screenshot of failed tests.

License: MIT License

PHP 82.64% Gherkin 17.36%

behat-screenshot's Introduction

Behat-ScreenshotExtension

License Latest Stable Version Scrutinizer Code Quality Build Status Build Status HHVM Status

Behat-ScreenshotExtension helps you debug Behat scenarios by taking screenshot of the failing steps.

By default the extension takes the screenshot and save it to the preconfigured directory (by default it will save the image to the default temporary system directory).

Also the extenstion allows you to specify an image driver which can upload the image to a host, in this case you will see the image url in the terminal right after the failing step. See available image drivers below.

You can also create your own image driver easily, for more information see this section.

Installation

Install by adding to your composer.json:

composer require --dev bex/behat-screenshot

Configuration

Enable the extension in behat.yml like this:

default:
  extensions:
    Bex\Behat\ScreenshotExtension: ~

You can configure the screenshot directory like this:

default:
  extensions:
    Bex\Behat\ScreenshotExtension:
      image_drivers:
        local:
          screenshot_directory: /your/desired/path/for/screenshots

If you are using another image driver you can enable it like this:

default:
  extensions:
    Bex\Behat\ScreenshotExtension:
      active_image_drivers: customdriver
      image_drivers: # this node and the driver subnodes are optional, if you remove it then the driver's default values will be used
        customdriver:
          #... custom driver config goes here ...

You can even enable more than one image driver at once:

default:
  extensions:
    Bex\Behat\ScreenshotExtension:
      active_image_drivers: [local, customdriver]
      image_drivers:
        local:
          #... local driver config goes here ...
        customdriver:
          #... custom driver config goes here ...

You can disable the extension by removing from the behat.yml or you can disable it for a profile by using the enabled parameter, e.g.:

ci:
  extensions:
    Bex\Behat\ScreenshotExtension:
      enabled: false

Usage

When you run behat and a step fails then the extension will automatically take the screenshot and you will see the filepath or the image URL of the screenshot (based on the configured image driver). So you will see something like this:

  Scenario:                           # features/feature.feature:2
    Given I have a step               # FeatureContext::passingStep()
    When I have a failing step        # FeatureContext::failingStep()
      Error (Exception)
Screenshot has been taken. Open image at /tmp/behat-screenshot/i_have_a_failing_step.png
    Then I should have a skipped step # FeatureContext::skippedStep()

Available Image Drivers

How to create your own image driver

  1. Implement the Bex\Behat\ScreenshotExtension\Driver\ImageDriverInterface
  2. Put your class under the Bex\Behat\ScreenshotExtension\Driver namespace

Thats it!

See example here: https://github.com/tkotosz/behat-screenshot-image-driver-dummy

behat-screenshot's People

Contributors

elvetemedve avatar scrutinizer-auto-fixer avatar

Watchers

 avatar  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.