public function showFailedStepResponse(AfterStepTested $event)
    {
        $testResult = $event->getTestResult();

        if (!$testResult instanceof ExceptionResult) {
            return;
        }

        if (!$testResult->getException() instanceof MinkException) {
            return;
        }

        if (null === $this->parameters['show_cmd']) {
            throw new \RuntimeException('Set "show_cmd" parameter in behat.yml to be able to open page in browser (ex.: "show_cmd: open %s")');
        }

        $filename = rtrim($this->parameters['show_tmp_dir'], DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.uniqid().'.html';
        file_put_contents($filename, $this->mink->getSession()->getPage()->getContent());
        system(sprintf($this->parameters['show_cmd'], escapeshellarg($filename)));
    }
public function showFailedStepResponse(AfterStepTested $event)
    {
        $testResult = $event->getTestResult();

        if (!$testResult instanceof ExceptionResult) {
            return;
        }

        if (!$testResult->getException() instanceof MinkException) {
            return;
        }

        if (null === $this->parameters['show_cmd']) {
            throw new \RuntimeException('Set "show_cmd" parameter in behat.yml to be able to open page in browser (ex.: "show_cmd: open %s")');
        }

        $filename = rtrim($this->parameters['show_tmp_dir'], DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.uniqid().'.html';
        file_put_contents($filename, $this->mink->getSession()->getPage()->getContent());
        system(sprintf($this->parameters['show_cmd'], escapeshellarg($filename)));
    }
public function showFailedStepResponse ( AfterStepTested $ event ) { $ testResult = $ event -> getTestResult ( ) ; if ( ! $ testResult instanceof ExceptionResult ) { return ; } if ( ! $ testResult -> getException ( ) instanceof MinkException ) { return ; } if ( null === $ this -> parameters [ 'show_cmd' ] ) { throw new \ RuntimeException ( 'Set "show_cmd" parameter in behat.yml to be able to open page in browser (ex.: "show_cmd: open %s")' ) ; } $ filename = rtrim ( $ this -> parameters [ 'show_tmp_dir' ] , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . uniqid ( ) . '.html' ; file_put_contents ( $ filename , $ this -> mink -> getSession ( ) -> getPage ( ) -> getContent ( ) ) ; system ( sprintf ( $ this -> parameters [ 'show_cmd' ] , escapeshellarg ( $ filename ) ) ) ; }
Shows last response of failed step with preconfigured command.

Configuration is based on `behat.yml`:

`show_auto` enable this listener (default to false)
`show_cmd` command to run (`open %s` to open default browser on Mac)
`show_tmp_dir` folder where to store temp files (default is system temp)

@param AfterStepTested $event

@throws \RuntimeException if show_cmd is not configured
Shows last response of failed step with preconfigured command .