Skip to content

MQE-1672: AllureAdapter does not output BROKEN test steps #396

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

Merged
merged 5 commits into from
Jul 26, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler;
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;
use \Magento\FunctionalTestingFramework\Util\TestGenerator;
use Yandex\Allure\Adapter\Model\Status;
use Yandex\Allure\Adapter\Model\Step;
use Yandex\Allure\Codeception\AllureCodeception;
use Yandex\Allure\Adapter\Event\StepStartedEvent;
use Yandex\Allure\Adapter\Event\StepFinishedEvent;
use Yandex\Allure\Adapter\Event\StepFailedEvent;
use Yandex\Allure\Adapter\Event\TestCaseFailedEvent;
use Yandex\Allure\Adapter\Event\TestCaseFinishedEvent;
use Yandex\Allure\Adapter\Event\TestCaseBrokenEvent;
use Codeception\Event\FailEvent;
use Codeception\Event\SuiteEvent;
use Codeception\Event\StepEvent;
Expand Down Expand Up @@ -187,10 +189,37 @@ public function testIncomplete(FailEvent $failEvent)
$this->getLifecycle()->fire($event->withException($e)->withMessage($message));
}

/**
* Override of parent method. Adds in steps for hard PHP Errors if they arrise.
*
* @param FailEvent $failEvent
* @return void
*/
public function testError(FailEvent $failEvent)
{
$event = new TestCaseBrokenEvent();
$e = $failEvent->getFail();
$message = $e->getMessage();

// Create new step with an error for Allure
$failStep = new Step();
$failStep->setName("ERROR");
$failStep->setTitle($message);
$failStep->setStatus(Status::BROKEN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the BROKEN status accurate?

Copy link
Contributor Author

@KevinBKozan KevinBKozan Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, yes. Class Status only has mappings for FAILED BROKEN PASSED CANCELED PENDING, so I think it makes sense.

Also, refer to AllureCodeception.php ln 339, you'll see two functions testError() and testFail().

  • testError() => hard error in test, like a fatal PHP error
  • testFail() => exception thrown in the test cause a true failure (not an error)

Based on that delinitation and mapping to Codeception's existing hooks I think it makes sense for this to be Status::BROKEN

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.


// Retrieve Allure Steps and add in the new BROKEN step
$rootStep = $this->getLifecycle()->getStepStorage()->pollLast();
$rootStep->addStep($failStep);
$this->getLifecycle()->getStepStorage()->put($rootStep);

$this->getLifecycle()->fire($event->withException($e)->withMessage($message));
}

/**
* Override of parent method, polls stepStorage for testcase and formats it according to actionGroup nesting.
*
* @return void
* @SuppressWarnings(PHPMD)
*/
public function testEnd()
{
Expand All @@ -207,6 +236,13 @@ public function testEnd()
}
// if actionGroup flag, start nesting
if (strpos($step->getName(), ActionGroupObject::ACTION_GROUP_CONTEXT_START) !== false) {
if ($actionGroupStepContainer !== null) {
//actionGroup still being nested, need to close out and finish it.
$formattedSteps[] = $actionGroupStepContainer;
$actionGroupStepContainer = null;
$actionGroupStepKey = null;
}

$step->setName(str_replace(ActionGroupObject::ACTION_GROUP_CONTEXT_START, '', $step->getName()));
$actionGroupStepContainer = $step;

Expand Down