public function failScreenshots(AfterStepScope $scope)
{
if (!$scope->getTestResult()->isPassed()) {
$makeScreenshot = false;
$suiteName = urlencode(str_replace(' ', '_', $scope->getSuite()->getName()));
$featureName = urlencode(str_replace(' ', '_', $scope->getFeature()->getTitle()));
if ($background = $this->getBackground($scope)) {
$makeScreenshot = $scope->getFeature()->hasTag('javascript');
$scenarioName = 'background';
} else {
$scenario = $this->getScenario($scope);
$makeScreenshot = $scope->getFeature()->hasTag('javascript') || $scenario->hasTag('javascript');
$scenarioName = urlencode(str_replace(' ', '_', $scenario->getTitle()));
}
if ($makeScreenshot) {
$filename = sprintf('fail_%s_%s_%s.png', time(), $suiteName, $featureName, $scenarioName);
$this->saveScreenshot($filename, $this->screenshotDir);
}
}
}