Skip to content

Commit 1433e80

Browse files
committed
ACQE-4973 | Group test under suites
1 parent c5dff0b commit 1433e80

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

dev/.credentials

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
magento/MAGENTO_ADMIN_PASSWORD=Admin@123456

src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Codeception\Step;
1111
use Magento\FunctionalTestingFramework\Allure\AllureHelper;
1212
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
13+
use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler;
1314
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
1415
use Qameta\Allure\Allure;
1516
use Qameta\Allure\Model\StepResult;
@@ -158,6 +159,53 @@ function (TestResult $testResult) {
158159
$this->getFormattedSteps($testResult);
159160
}
160161
);
162+
163+
$group = null;
164+
if ($this->options['groups'] !== null) {
165+
$group = $this->options['groups'][0];
166+
}
167+
if ($group !== null) {
168+
$groupName = $this->sanitizeGroupName($group);
169+
$lifecycle->updateTest(
170+
function (TestResult $testResult) use ($groupName) {
171+
$labels = $testResult->getLabels();
172+
foreach ($labels as $label) {
173+
if ($label->getName() == "parentSuite") {
174+
$label->setValue(sprintf('%s\%s', $label->getValue(), $groupName));
175+
break;
176+
}
177+
}
178+
}
179+
);
180+
}
181+
}
182+
183+
/**
184+
* Function which santizes any group names changed by the framework for execution in order to consolidate reporting.
185+
*
186+
* @param string $group
187+
* @return string
188+
*/
189+
private function sanitizeGroupName($group): string
190+
{
191+
$suiteNames = array_keys(SuiteObjectHandler::getInstance()->getAllObjects());
192+
$exactMatch = in_array($group, $suiteNames);
193+
194+
// if this is an existing suite name we dont' need to worry about changing it
195+
if ($exactMatch || strpos($group, "_") === false) {
196+
return $group;
197+
}
198+
199+
// if we can't find this group in the generated suites we have to assume that the group was split for generation
200+
$groupNameSplit = explode("_", $group);
201+
array_pop($groupNameSplit);
202+
array_pop($groupNameSplit);
203+
$originalName = implode("_", $groupNameSplit);
204+
205+
// confirm our original name is one of the existing suite names otherwise just return the original group name
206+
$originalName = in_array($originalName, $suiteNames) ? $originalName : $group;
207+
208+
return $originalName;
161209
}
162210

163211
/**

0 commit comments

Comments
 (0)