Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshot is not attached when testing outline scenarios. #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions src/Formatter/BehatHTMLFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
use Behat\Behat\EventDispatcher\Event\BeforeFeatureTested;
use Behat\Behat\EventDispatcher\Event\BeforeOutlineTested;
use Behat\Behat\EventDispatcher\Event\BeforeScenarioTested;
use Behat\Behat\EventDispatcher\Event\ExampleTested;
use Behat\Behat\EventDispatcher\Event\FeatureTested;
use Behat\Behat\EventDispatcher\Event\OutlineTested;
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
use Behat\Behat\EventDispatcher\Event\StepTested;
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Tester\Result\ExecutedStepResult;
use Behat\Behat\Tester\Result\StepResult;
Expand All @@ -18,6 +23,8 @@
use Behat\Testwork\EventDispatcher\Event\AfterSuiteTested;
use Behat\Testwork\EventDispatcher\Event\BeforeExerciseCompleted;
use Behat\Testwork\EventDispatcher\Event\BeforeSuiteTested;
use Behat\Testwork\EventDispatcher\Event\ExerciseCompleted;
use Behat\Testwork\EventDispatcher\Event\SuiteTested;
use Behat\Testwork\Output\Formatter;
use Behat\Testwork\Output\Printer\OutputPrinter;
use emuse\BehatHTMLFormatter\Classes\Feature;
Expand Down Expand Up @@ -197,17 +204,19 @@ public function __construct($name, $renderer, $filename, $print_args, $print_out
public static function getSubscribedEvents()
{
return array(
'tester.exercise_completed.before' => 'onBeforeExercise',
'tester.exercise_completed.after' => 'onAfterExercise',
'tester.suite_tested.before' => 'onBeforeSuiteTested',
'tester.suite_tested.after' => 'onAfterSuiteTested',
'tester.feature_tested.before' => 'onBeforeFeatureTested',
'tester.feature_tested.after' => 'onAfterFeatureTested',
'tester.scenario_tested.before' => 'onBeforeScenarioTested',
'tester.scenario_tested.after' => 'onAfterScenarioTested',
'tester.outline_tested.before' => 'onBeforeOutlineTested',
'tester.outline_tested.after' => 'onAfterOutlineTested',
'tester.step_tested.after' => 'onAfterStepTested',
ExerciseCompleted::BEFORE => 'onBeforeExercise',
ExerciseCompleted::AFTER => 'onAfterExercise',
SuiteTested::BEFORE => 'onBeforeSuiteTested',
SuiteTested::AFTER => 'onAfterSuiteTested',
FeatureTested::BEFORE => 'onBeforeFeatureTested',
FeatureTested::AFTER => 'onAfterFeatureTested',
ExampleTested::BEFORE => 'onBeforeScenarioTested',
ExampleTested::AFTER => 'onAfterScenarioTested',
ScenarioTested::BEFORE => 'onBeforeScenarioTested',
ScenarioTested::AFTER => 'onAfterScenarioTested',
OutlineTested::BEFORE => 'onBeforeOutlineTested',
OutlineTested::AFTER => 'onAfterOutlineTested',
StepTested::AFTER => 'onAfterStepTested',
);
}

Expand Down Expand Up @@ -547,23 +556,6 @@ public function onBeforeOutlineTested(BeforeOutlineTested $event)
*/
public function onAfterOutlineTested(AfterOutlineTested $event)
{
$scenarioPassed = $event->getTestResult()->isPassed();

if ($scenarioPassed) {
$this->passedScenarios[] = $this->currentScenario;
$this->currentFeature->addPassedScenario();
$this->currentScenario->setPassed(true);
} elseif (StepResult::PENDING == $event->getTestResult()->getResultCode()) {
$this->pendingScenarios[] = $this->currentScenario;
$this->currentFeature->addPendingScenario();
$this->currentScenario->setPending(true);
} else {
$this->failedScenarios[] = $this->currentScenario;
$this->currentFeature->addFailedScenario();
$this->currentScenario->setPassed(false);
$this->currentScenario->setPending(false);
}

$this->currentScenario->setLoopCount(sizeof($event->getTestResult()));
$this->currentFeature->addScenario($this->currentScenario);

Expand Down