2017 © Pedro Peláez
 

behat-extension behat-slack-extension

A behat extension for sending files from behat to slack

image

priotas/behat-slack-extension

A behat extension for sending files from behat to slack

  • Tuesday, April 25, 2017
  • by madflow
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,607 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 16 % Grown

The README.md

Build Status, (*1)

Installation

composer require --dev priotas/behat-slack-extension, (*2)

Configuration

behat.yml

profile_name:
    extensions:
        Priotas\Behat\SlackExtension:
            slackToken: "xoxb-0000000000-xxxxxxxxxxxxxxxxxxxxxxxx"
            slackChannel: "XXXXXXXXX"

Environment Variable

export BEHAT_PARAMS='{"extensions" : {"Priotas\\Behat\\SlackExtension" : {"slackToken" : "xoxb-0000000000-xxxxxxxxxxxxxxxxxxxxxxxx", "slackChannel": "XXXXXXXXX"}}}'

Usage

/**
 * @AfterStep
 */
public function takeScreenshotAfterFailedStep(Behat\Behat\Hook\Scope\AfterStepScope $scope)
{
    /** Behat\Behat\Tester\Result\StepResult $result */
    $result = $scope->getTestResult();
    if (!$result->isPassed()) {

        $driver = $this->getSession()->getDriver();
        if ($driver instanceof \Behat\Mink\Driver\Selenium2Driver) {
            $driver->resizeWindow(1024, 768);

            $featureName = basename($scope->getFeature()->getFile(), '.feature');
            $stepText = $featureName . '.' . $this->scenarioName . '.' . $scope->getStep()->getText();
            $fileTitle = 'behat_screenshot_' . preg_replace("#[^a-zA-Z0-9\._-]#", '', $stepText);
            $fileName = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $fileTitle . '.png';
            $screenshot = $driver->getScreenshot();
            file_put_contents($fileName, $screenshot);

            print "Screenshot for '{$stepText}' placed in {$fileName}\n";

            if (isset($this->slackChannel)) {
                print "Uploading Screenshot to Slack...\n";
                $this->slackChannel->upload($fileName, $fileTitle, $stepText);
            }
        }
    }
}

The Versions

25/04 2017

dev-master

9999999-dev

A behat extension for sending files from behat to slack

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

25/04 2017

1.0

1.0.0.0

A behat extension for sending files from behat to slack

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires