Skip to content

Commit 5b84ddc

Browse files
committed
MQE-2094: Test failure re-run error for extn builds
sanitized testClass label for split group runs
1 parent e45c5e5 commit 5b84ddc

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,11 @@ public function testError(FailEvent $failEvent)
259259
*/
260260
public function testEnd(TestEvent $testEvent)
261261
{
262+
$test = $this->getLifecycle()->getTestCaseStorage()->get();
263+
// update testClass label to consolidate re-try reporting
264+
$this->formatAllureTestClassName($test);
262265
// Peek top of testCaseStorage to check of failure
263-
$testFailed = $this->getLifecycle()->getTestCaseStorage()->get()->getFailure();
266+
$testFailed = $test->getFailure();
264267
// Pops top of stepStorage, need to add it back in after processing
265268
$rootStep = $this->getLifecycle()->getStepStorage()->pollLast();
266269
$formattedSteps = [];
@@ -402,4 +405,43 @@ private function removeAttachments($step, $testFailed)
402405
}
403406
}
404407
}
408+
409+
/**
410+
* Format testClass label to consolidate re-try reporting for groups split for parallel execution
411+
* @param TestCase $test
412+
* @return void
413+
*/
414+
private function formatAllureTestClassName($test)
415+
{
416+
if ($this->getGroup() !== null) {
417+
foreach ($test->getLabels() as $name => $label) {
418+
if ($label->getName() == 'testClass') {
419+
$originalTestClass = $this->sanitizeTestClassLabel($label->getValue());
420+
call_user_func(\Closure::bind(
421+
function () use ($label, $originalTestClass) {
422+
$label->value = $originalTestClass;
423+
},
424+
null,
425+
$label
426+
));
427+
break;
428+
}
429+
}
430+
}
431+
}
432+
433+
/**
434+
* Function which sanitizes testClass label for split group runs
435+
* @param string $testClass
436+
* @return string
437+
*/
438+
private function sanitizeTestClassLabel($testClass)
439+
{
440+
$originalTestClass = $testClass;
441+
$originalGroupName = $this->sanitizeGroupName($this->getGroup());
442+
if ($originalGroupName !== $this->getGroup()) {
443+
$originalTestClass = str_replace($this->getGroup(), $originalGroupName, $testClass);
444+
}
445+
return $originalTestClass;
446+
}
405447
}

0 commit comments

Comments
 (0)