Skip to content

Commit 817214c

Browse files
committed
MQE-2086: Reduce amount of attachments in Allure reports
- Implemented new VERBOSE_ARTIFACTS FLAG
1 parent 8fb1025 commit 817214c

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

dev/tests/functional/standalone_bootstrap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
defined('WAIT_TIMEOUT') || define('WAIT_TIMEOUT', 30);
5454
$env->setEnvironmentVariable('WAIT_TIMEOUT', WAIT_TIMEOUT);
5555

56+
defined('VERBOSE_ARTIFACTS') || define('VERBOSE_ARTIFACTS', false);
57+
$env->setEnvironmentVariable('VERBOSE_ARTIFACTS', VERBOSE_ARTIFACTS);
58+
5659
try {
5760
new DateTimeZone(DEFAULT_TIMEZONE);
5861
} catch (\Exception $e) {

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

Lines changed: 10 additions & 0 deletions
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\Provider;
1314
use Yandex\Allure\Adapter\Model\Status;
1415
use Yandex\Allure\Adapter\Model\Step;
1516
use Yandex\Allure\Codeception\AllureCodeception;
@@ -250,13 +251,22 @@ public function testError(FailEvent $failEvent)
250251
*/
251252
public function testEnd()
252253
{
254+
// Peek top of testCaseStorage to check of failure
255+
$testFailed = $this->getLifecycle()->getTestCaseStorage()->get()->getFailure();
253256
// Pops top of stepStorage, need to add it back in after processing
254257
$rootStep = $this->getLifecycle()->getStepStorage()->pollLast();
255258
$formattedSteps = [];
256259
$actionGroupStepContainer = null;
257260

258261
$actionGroupStepKey = null;
259262
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+
}
260270
$stepKey = str_replace($actionGroupStepKey, '', $step->getName());
261271
if ($stepKey !== '[]' && $stepKey !== null) {
262272
$step->setName($stepKey);

src/Magento/FunctionalTestingFramework/_bootstrap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
defined('WAIT_TIMEOUT') || define('WAIT_TIMEOUT', 30);
5454
$env->setEnvironmentVariable('WAIT_TIMEOUT', WAIT_TIMEOUT);
5555

56+
defined('VERBOSE_ARTIFACTS') || define('VERBOSE_ARTIFACTS', false);
57+
$env->setEnvironmentVariable('VERBOSE_ARTIFACTS', VERBOSE_ARTIFACTS);
58+
5659
try {
5760
new DateTimeZone(DEFAULT_TIMEZONE);
5861
} catch (\Exception $e) {

0 commit comments

Comments
 (0)