diff --git a/CHANGELOG.md b/CHANGELOG.md index 86452d120..cfd9a6e86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ Magento Functional Testing Framework Changelog ================================================ +4.3.2 +--------- +### Enhancements +* 'bootstrap' argument added to indicate that no additional background processes will be run and the jobs complete in the foreground process. + +### Fixes +* Fixed serialization of weakmap exception thrown for every internal exception after codeception upgrade. +* Fixed suites no longer separated by MFTF Suite. + 4.3.1 --------- ### Fixes diff --git a/composer.json b/composer.json index 26199a504..96105c4b0 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/magento2-functional-testing-framework", "description": "Magento2 Functional Testing Framework", "type": "library", - "version": "4.3.1", + "version": "4.3.2", "license": "AGPL-3.0", "keywords": ["magento", "automation", "functional", "testing"], "config": { diff --git a/composer.lock b/composer.lock index 8131637d3..ec7e440cd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1cfdd64e0e61b92650826ed6b7378188", + "content-hash": "b3c3ad8cbe0e410841d4c61f9cd36a55", "packages": [ { "name": "allure-framework/allure-codeception", diff --git a/src/Magento/FunctionalTestingFramework/Allure/AllureHelper.php b/src/Magento/FunctionalTestingFramework/Allure/AllureHelper.php index 8f7699ed0..6e6498e62 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/AllureHelper.php +++ b/src/Magento/FunctionalTestingFramework/Allure/AllureHelper.php @@ -23,7 +23,11 @@ class AllureHelper public static function addAttachmentToCurrentStep($data, $caption): void { if (!is_string($data)) { - $data = serialize($data); + try { + $data = serialize($data); + } catch (\Exception $exception) { + throw new \Exception($data->getMessage()); + } } if (@file_exists($data) && is_file($data)) { Allure::attachmentFile($caption, $data); diff --git a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php index 309f72070..5f850a403 100644 --- a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php +++ b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php @@ -8,10 +8,13 @@ use Codeception\Events; use Codeception\Step; +use Codeception\Test\Test; use Magento\FunctionalTestingFramework\Allure\AllureHelper; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; +use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler; use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; use Qameta\Allure\Allure; +use Qameta\Allure\AllureLifecycleInterface; use Qameta\Allure\Model\StepResult; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; @@ -158,6 +161,68 @@ function (TestResult $testResult) { $this->getFormattedSteps($testResult); } ); + + $this->addTestsInSuites($lifecycle, $cest); + } + + /** + * Function to add test under the suites. + * + * @param object $lifecycle + * @param object $cest + * + * @return void + */ + private function addTestsInSuites($lifecycle, $cest): void + { + $groupName = null; + if ($this->options['groups'] !== null) { + $group = $this->options['groups'][0]; + $groupName = $this->sanitizeGroupName($group); + } + $lifecycle->updateTest( + function (TestResult $testResult) use ($groupName, $cest) { + $labels = $testResult->getLabels(); + foreach ($labels as $label) { + if ($groupName !== null && $label->getName() === "parentSuite") { + $label->setValue(sprintf('%s\%s', $label->getValue(), $groupName)); + } + if ($label->getName() === "package") { + $className = $cest->getReportFields()['class']; + $className = preg_replace('{_[0-9]*_G}', '', $className); + $label->setValue($className); + } + } + } + ); + } + + /** + * Function which santizes any group names changed by the framework for execution in order to consolidate reporting. + * + * @param string $group + * @return string + */ + private function sanitizeGroupName($group): string + { + $suiteNames = array_keys(SuiteObjectHandler::getInstance()->getAllObjects()); + $exactMatch = in_array($group, $suiteNames); + + // if this is an existing suite name we dont' need to worry about changing it + if ($exactMatch || strpos($group, "_") === false) { + return $group; + } + + // if we can't find this group in the generated suites we have to assume that the group was split for generation + $groupNameSplit = explode("_", $group); + array_pop($groupNameSplit); + array_pop($groupNameSplit); + $originalName = implode("_", $groupNameSplit); + + // confirm our original name is one of the existing suite names otherwise just return the original group name + $originalName = in_array($originalName, $suiteNames) ? $originalName : $group; + + return $originalName; } /** diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 54fecf7de..f2580deaf 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -1033,6 +1033,10 @@ private function executeCronjobs($cronGroups, $timeout, $arguments): string { $cronGroups = array_filter($cronGroups); + if (isset($cronGroups[0]) && !isset($cronGroups[1])) { + $arguments .= ' --bootstrap=standaloneProcessStarted=1'; + } + $waitFor = $this->getCronWait($cronGroups); if ($waitFor) {