|
10 | 10 | use Codeception\Step;
|
11 | 11 | use Magento\FunctionalTestingFramework\Allure\AllureHelper;
|
12 | 12 | use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
|
| 13 | +use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler; |
13 | 14 | use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
|
14 | 15 | use Qameta\Allure\Allure;
|
15 | 16 | use Qameta\Allure\Model\StepResult;
|
@@ -158,6 +159,53 @@ function (TestResult $testResult) {
|
158 | 159 | $this->getFormattedSteps($testResult);
|
159 | 160 | }
|
160 | 161 | );
|
| 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; |
161 | 209 | }
|
162 | 210 |
|
163 | 211 | /**
|
|
0 commit comments