2017 © Pedro Peláez
 

behat-extension behat-failurehook-extension

Exposes stuff when a test fails

image

fonsecas72/behat-failurehook-extension

Exposes stuff when a test fails

  • Friday, August 12, 2016
  • by fonsecas72
  • Repository
  • 1 Watchers
  • 1 Stars
  • 23,748 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

behat-failurehook-extension

This behat extension will trigger actions when your test failed that you can use e.g. to take a screenshot, save the html content, or something more specific as it allows you to add your own thing., (*1)

How your behat.yml should look like:, (*2)

default:
    extensions:
        Fonsecas72\FailureExpoExtension:
            expounds:
                - Features\FailureHooks\MySQLDumpExpound

You should not need anything else to make it work., (*3)

Adding your own hooks:

E.g. of a hook:, (*4)

<?php

namespace Features\FailureHooks;

class MySQLDumpExpound extends \Fonsecas72\FailureExpoExtension\Expounds\Expound
{
    public function expose()
    {
        $fs = new \Symfony\Component\Filesystem\Filesystem();
        $destination = 'build/'.$this->description;
        $fs->mkdir($destination);
        shell_exec('mysqldump -uuser -ppass db > '.$destination.'/dbdump.sql');
        echo PHP_EOL.'| MysqlDump captured ~> '.$destination.'/dbdump.sql';
    }
}

How it works

Your failure-hook should extend \Fonsecas72\FailureExpoExtension\Expounds\Expound and implement expose method. This method will be called when a failure occurs. Failure-hook extension will then expose a special "description" property that identifies the failing scenairo., (*5)

The Versions

12/08 2016

dev-master

9999999-dev

Exposes stuff when a test fails

  Sources   Download

Apache2

by Hugo Fonseca

debug screenshot

12/08 2016

1.0.1

1.0.1.0

Exposes stuff when a test fails

  Sources   Download

Apache2

by Hugo Fonseca

debug screenshot