Skip to content

Commit b84ced3

Browse files
committed
MQE-2086: Reduce amount of attachments in Allure reports
- Static check fixes
1 parent 817214c commit b84ced3

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

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

+19-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;
1111
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
1212
use Magento\FunctionalTestingFramework\Util\TestGenerator;
13+
use Yandex\Allure\Adapter\Model\Failure;
1314
use Yandex\Allure\Adapter\Model\Provider;
1415
use Yandex\Allure\Adapter\Model\Status;
1516
use Yandex\Allure\Adapter\Model\Step;
@@ -260,13 +261,7 @@ public function testEnd()
260261

261262
$actionGroupStepKey = null;
262263
foreach ($rootStep->getSteps() as $step) {
263-
//Remove Attachments if verbose flag is not true AND test did not fail
264-
if (getenv('VERBOSE_ARTIFACTS') !== true && $testFailed === null) {
265-
foreach ($step->getAttachments() as $index => $attachment) {
266-
$step->removeAttachment($index);
267-
unlink(Provider::getOutputDirectory() . DIRECTORY_SEPARATOR . $attachment->getSource());
268-
}
269-
}
264+
$this->removeAttachments($step, $testFailed);
270265
$stepKey = str_replace($actionGroupStepKey, '', $step->getName());
271266
if ($stepKey !== '[]' && $stepKey !== null) {
272267
$step->setName($stepKey);
@@ -364,4 +359,21 @@ private function retrieveStepKey($stepLine)
364359

365360
return $stepKey;
366361
}
362+
363+
/**
364+
* Removes attachments from step depending on MFTF configuration
365+
* @param Step $step
366+
* @param Failure $testFailed
367+
* @return void
368+
*/
369+
private function removeAttachments($step, $testFailed)
370+
{
371+
//Remove Attachments if verbose flag is not true AND test did not fail
372+
if (getenv('VERBOSE_ARTIFACTS') !== true && $testFailed === null) {
373+
foreach ($step->getAttachments() as $index => $attachment) {
374+
$step->removeAttachment($index);
375+
unlink(Provider::getOutputDirectory() . DIRECTORY_SEPARATOR . $attachment->getSource());
376+
}
377+
}
378+
}
367379
}

0 commit comments

Comments
 (0)