Skip to content

Instantly share code, notes, and snippets.

@weaverryan weaverryan/FeatureContext.php Secret
Created Apr 30, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.