Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dev/tests/functional/standalone_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
defined('WAIT_TIMEOUT') || define('WAIT_TIMEOUT', 30);
$env->setEnvironmentVariable('WAIT_TIMEOUT', WAIT_TIMEOUT);

defined('VERBOSE_ARTIFACTS') || define('VERBOSE_ARTIFACTS', false);
$env->setEnvironmentVariable('VERBOSE_ARTIFACTS', VERBOSE_ARTIFACTS);

try {
new DateTimeZone(DEFAULT_TIMEZONE);
} catch (\Exception $e) {
Expand Down
14 changes: 14 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,20 @@ Example:
CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default
```

### VERBOSE_ARTIFACTS

Determines if passed tests should still have all their Allure artifacts. These artifacts include `.txt` attachments for `dontSee` actions and `createData` actions.

If enabled, all tests will have all of their normal Allure artifacts.

If disabled, passed tests will have their Allure artifacts trimmed. Failed tests will still contain all their artifacts.

This is set `false` by default.

```conf
VERBOSE_ARTIFACTS=true
```

### ENABLE_BROWSER_LOG

Enables addition of browser logs to Allure steps
Expand Down
3 changes: 3 additions & 0 deletions etc/config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ MODULE_WHITELIST=Magento_Framework,ConfigurableProductWishlist,ConfigurableProdu
#*** Default timeout for wait actions
#WAIT_TIMEOUT=30

#*** Uncomment and set to enable all tests, regardless of passing status, to have all their Allure artifacts.
#VERBOSE_ARTIFACTS=true

#*** Uncomment and set to enable browser log entries on actions in Allure. Blacklist is used to filter logs of a specific "source"
#ENABLE_BROWSER_LOG=true
#BROWSER_LOG_BLACKLIST=other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
use Magento\FunctionalTestingFramework\Util\TestGenerator;
use Yandex\Allure\Adapter\Model\Failure;
use Yandex\Allure\Adapter\Model\Provider;
use Yandex\Allure\Adapter\Model\Status;
use Yandex\Allure\Adapter\Model\Step;
use Yandex\Allure\Adapter\Allure;
Expand Down Expand Up @@ -256,13 +258,16 @@ public function testError(FailEvent $failEvent)
*/
public function testEnd(TestEvent $testEvent)
{
// Peek top of testCaseStorage to check of failure
$testFailed = $this->getLifecycle()->getTestCaseStorage()->get()->getFailure();
// Pops top of stepStorage, need to add it back in after processing
$rootStep = $this->getLifecycle()->getStepStorage()->pollLast();
$formattedSteps = [];
$actionGroupStepContainer = null;

$actionGroupStepKey = null;
foreach ($rootStep->getSteps() as $step) {
$this->removeAttachments($step, $testFailed);
$stepKey = str_replace($actionGroupStepKey, '', $step->getName());
if ($stepKey !== '[]' && $stepKey !== null) {
$step->setName($stepKey);
Expand Down Expand Up @@ -379,4 +384,21 @@ private function retrieveStepKey($stepLine)

return $stepKey;
}

/**
* Removes attachments from step depending on MFTF configuration
* @param Step $step
* @param Failure $testFailed
* @return void
*/
private function removeAttachments($step, $testFailed)
{
//Remove Attachments if verbose flag is not true AND test did not fail
if (getenv('VERBOSE_ARTIFACTS') !== true && $testFailed === null) {
foreach ($step->getAttachments() as $index => $attachment) {
$step->removeAttachment($index);
unlink(Provider::getOutputDirectory() . DIRECTORY_SEPARATOR . $attachment->getSource());
}
}
}
}
3 changes: 3 additions & 0 deletions src/Magento/FunctionalTestingFramework/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
defined('WAIT_TIMEOUT') || define('WAIT_TIMEOUT', 30);
$env->setEnvironmentVariable('WAIT_TIMEOUT', WAIT_TIMEOUT);

defined('VERBOSE_ARTIFACTS') || define('VERBOSE_ARTIFACTS', false);
$env->setEnvironmentVariable('VERBOSE_ARTIFACTS', VERBOSE_ARTIFACTS);

try {
new DateTimeZone(DEFAULT_TIMEZONE);
} catch (\Exception $e) {
Expand Down