Skip to content

Commit 7315bcb

Browse files
authored
Merge branch 'MFTF3.0.0-RC2' into MQE-2080
2 parents 02d75ad + b79ec06 commit 7315bcb

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-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) {

docs/configuration.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,20 @@ Example:
299299
CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default
300300
```
301301

302+
### VERBOSE_ARTIFACTS
303+
304+
Determines if passed tests should still have all their Allure artifacts. These artifacts include `.txt` attachments for `dontSee` actions and `createData` actions.
305+
306+
If enabled, all tests will have all of their normal Allure artifacts.
307+
308+
If disabled, passed tests will have their Allure artifacts trimmed. Failed tests will still contain all their artifacts.
309+
310+
This is set `false` by default.
311+
312+
```conf
313+
VERBOSE_ARTIFACTS=true
314+
```
315+
302316
### ENABLE_BROWSER_LOG
303317

304318
Enables addition of browser logs to Allure steps

etc/config/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ MODULE_WHITELIST=Magento_Framework,ConfigurableProductWishlist,ConfigurableProdu
5959
#*** Default timeout for wait actions
6060
#WAIT_TIMEOUT=30
6161

62+
#*** Uncomment and set to enable all tests, regardless of passing status, to have all their Allure artifacts.
63+
#VERBOSE_ARTIFACTS=true
64+
6265
#*** Uncomment and set to enable browser log entries on actions in Allure. Blacklist is used to filter logs of a specific "source"
6366
#ENABLE_BROWSER_LOG=true
6467
#BROWSER_LOG_BLACKLIST=other

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;
1313
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
1414
use Magento\FunctionalTestingFramework\Util\TestGenerator;
15+
use Yandex\Allure\Adapter\Model\Failure;
16+
use Yandex\Allure\Adapter\Model\Provider;
1517
use Yandex\Allure\Adapter\Model\Status;
1618
use Yandex\Allure\Adapter\Model\Step;
1719
use Yandex\Allure\Adapter\Allure;
@@ -257,13 +259,16 @@ public function testError(FailEvent $failEvent)
257259
*/
258260
public function testEnd(TestEvent $testEvent)
259261
{
262+
// Peek top of testCaseStorage to check of failure
263+
$testFailed = $this->getLifecycle()->getTestCaseStorage()->get()->getFailure();
260264
// Pops top of stepStorage, need to add it back in after processing
261265
$rootStep = $this->getLifecycle()->getStepStorage()->pollLast();
262266
$formattedSteps = [];
263267
$actionGroupStepContainer = null;
264268

265269
$actionGroupStepKey = null;
266270
foreach ($rootStep->getSteps() as $step) {
271+
$this->removeAttachments($step, $testFailed);
267272
$stepKey = str_replace($actionGroupStepKey, '', $step->getName());
268273
if ($stepKey !== '[]' && $stepKey !== null) {
269274
$step->setName($stepKey);
@@ -380,4 +385,21 @@ private function retrieveStepKey($stepLine)
380385

381386
return $stepKey;
382387
}
388+
389+
/**
390+
* Removes attachments from step depending on MFTF configuration
391+
* @param Step $step
392+
* @param Failure $testFailed
393+
* @return void
394+
*/
395+
private function removeAttachments($step, $testFailed)
396+
{
397+
//Remove Attachments if verbose flag is not true AND test did not fail
398+
if (getenv('VERBOSE_ARTIFACTS') !== true && $testFailed === null) {
399+
foreach ($step->getAttachments() as $index => $attachment) {
400+
$step->removeAttachment($index);
401+
unlink(Provider::getOutputDirectory() . DIRECTORY_SEPARATOR . $attachment->getSource());
402+
}
403+
}
404+
}
383405
}

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)