Skip to content

Commit 229b66e

Browse files
authored
Merge pull request #199 from magento/MQE-1181
MQE-1181
2 parents 2282911 + 28a5f17 commit 229b66e

File tree

9 files changed

+148
-74
lines changed

9 files changed

+148
-74
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Magento Functional Testing Framework Changelog
22
================================================
33

4+
2.3.4
5+
-----
6+
### Fixes
7+
* MagentoWebDriver overrides `parent::_after()` function and remaps to `runAfter()`, necessary to solve compatibility issues in Codeception `2.3.x`.
8+
49
2.3.3
510
-----
611
### Fixes

bin/mftf

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ try {
2929
try {
3030
$application = new Symfony\Component\Console\Application();
3131
$application->setName('Magento Functional Testing Framework CLI');
32-
$application->setVersion('2.3.0');
32+
$application->setVersion('2.3.4');
3333
/** @var \Magento\FunctionalTestingFramework\Console\CommandListInterface $commandList */
3434
$commandList = new \Magento\FunctionalTestingFramework\Console\CommandList;
3535
foreach ($commandList->getCommands() as $command) {

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/magento2-functional-testing-framework",
33
"description": "Magento2 Functional Testing Framework",
44
"type": "library",
5-
"version": "2.3.3",
5+
"version": "2.3.4",
66
"license": "AGPL-3.0",
77
"keywords": ["magento", "automation", "functional", "testing"],
88
"config": {

composer.lock

+48-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/verification/Resources/functionalSuiteHooks.txt

+25-8
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ class functionalSuiteHooks extends \Codeception\GroupObject
5959
$this->create = new DataPersistenceHandler($createThis, [], $createFields);
6060
$this->create->createEntity();
6161
$webDriver->see("John", msq("uniqueData") . "John");
62-
62+
6363
// reset configuration and close session
6464
$this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver')->_resetConfig();
6565
$webDriver->webDriver->close();
6666
$webDriver->webDriver = null;
67+
6768
} catch (\Exception $exception) {
6869
$this->preconditionFailure = $exception->getMessage();
6970
}
@@ -74,16 +75,37 @@ class functionalSuiteHooks extends \Codeception\GroupObject
7475

7576
public function _after(\Codeception\Event\TestEvent $e)
7677
{
77-
$this->executePostConditions();
78+
$this->executePostConditions($e);
7879
}
7980

8081

81-
private function executePostConditions()
82+
private function executePostConditions(\Codeception\Event\TestEvent $e)
8283
{
8384
if ($this->currentTestRun == $this->testCount) {
8485
print sprintf(self::$HOOK_EXECUTION_INIT, "after");
8586

8687
try {
88+
// Find out if Test in Suite failed, will cause potential failures in suite after
89+
$cest = $e->getTest();
90+
91+
//Access private TestResultObject to find stack and if there are any errors (as opposed to failures)
92+
$testResultObject = call_user_func(\Closure::bind(
93+
function () use ($cest) {
94+
return $cest->getTestResultObject();
95+
},
96+
$cest
97+
));
98+
$errors = $testResultObject->errors();
99+
100+
if (!empty($errors)) {
101+
foreach ($errors as $error) {
102+
if ($error->failedTest()->getTestMethod() == $cest->getName()) {
103+
// Do not attempt to run _after if failure was in the _after block
104+
// Try to run _after but catch exceptions to prevent them from overwriting original failure.
105+
print("LAST TEST IN SUITE FAILED, TEST AFTER MAY NOT BE SUCCESSFUL\n");
106+
}
107+
}
108+
}
87109
$webDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');
88110

89111
// close any open sessions
@@ -97,11 +119,6 @@ class functionalSuiteHooks extends \Codeception\GroupObject
97119
$webDriver->amOnPage("some.url");
98120
$webDriver->deleteEntityByUrl("deleteThis");
99121
$webDriver->see("John", msq("uniqueData") . "John");
100-
101-
// reset configuration and close session
102-
$this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver')->_resetConfig();
103-
$webDriver->webDriver->close();
104-
$webDriver->webDriver = null;
105122
} catch (\Exception $exception) {
106123
print $exception->getMessage();
107124
}

0 commit comments

Comments
 (0)