Skip to content

Instantly share code, notes, and snippets.

@weaverryan
Created April 30, 2014 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weaverryan/f625a0d518f8d486eea5 to your computer and use it in GitHub Desktop.
Save weaverryan/f625a0d518f8d486eea5 to your computer and use it in GitHub Desktop.
Printing responses after every error
<?php
/**
* @AfterScenario
*/
public function printLastResponseOnError($scenarioEvent)
{
// reads print_error_debug from behat.yml
if (!$this->printOnDebug) {
return;
}
if ($scenarioEvent->getResult() != 0) {
// try to prevent it from dying if we error out before we have a request
$driver = $this->getSession()->getDriver();
$hasLastResponse = (!$driver instanceof GoutteDriver || $driver->getClient()->getRequest());
if ($hasLastResponse) {
$this->printLastResponse();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment