magento / magento/magento2-functional-testing-framework
Serialization of 'Closure' is not allowed
- Dominant language
- PHP
- Stars
- 154
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Description
We have started noticing failures in our test suite about a week ago, with no changes on our side. After investigation, we found the problem to have been caused by the release of v4.3.0 of the Magento functional testing framework. After downgrading to v4.2.1, the problem was resolved. Reporting the details here for reference.
### Preconditions
1. Magento 2.4.6
2. PHP 8.2
3. v4.3.0 of the framework
### Steps to reproduce
1. Implement an MFTF test which fails intentionally. Successful tests do not have this problem
2. Add the test in a test suite, with at least one more test after it
4.
### Expected result
1. The test should fail with a recorded screenshot
2. The next test should start
### Actual result
1. The test fails, and the entire test suite stops in its track, preventing allure reports from being generated. Example below:
```
[waitForFullScreenIframe] wait for element "//iframe[@name='acsFrame']",30
[saveScreenshot] save screenshot
[] [START AFTER HOOK]
[] [logoutStorefront] StorefrontCustomerLogoutActionGroup
[storefrontSignOut] am on page "customer/account/logout/"
[waitForSignOut] wait for page load 60
[END AFTER HOOK]
ERROR
--------------------------------------------------------------------------------
In AllureHelper.php line 26:
[Exception]
Serialization of 'Closure' is not allowed
Exception trace:
at vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/AllureHelper.php:26
serialize() at vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/AllureHelper.php:26
Magento\FunctionalTestingFramework\Allure\AllureHelper::addAttachmentToCurrentStep() at vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php:268
Magento\FunctionalTestingFramework\Extension\TestContextExtension->attachExceptionToAllure() at vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php:139
Magento\FunctionalTestingFramework\Extension\TestContextExtension->testEnd() at vendor/symfony/event-dispatcher/EventDispatcher.php:206
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() at vendor/symfony/event-dispatcher/EventDispatcher.php:56
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at vendor/codeception/codeception/src/Codeception/Test/Test.php:243
Codeception\Test\Test->realRun() at vendor/codeception/codeception/src/Codeception/Suite.php:130
Codeception\Suite->run() at vendor/codeception/codeception/src/Codeception/SuiteManager.php:148
Codeception\SuiteManager->run() at vendor/codeception/codeception/src/Codeception/Codecept.php:260
Codeception\Codecept->runSuite() at vendor/codeception/codeception/src/Codeception/Codecept.php:216
Codeception\Codecept->run() at vendor/codeception/codeception/src/Codeception/Command/Run.php:646
Codeception\Command\Run->runSuites() at vendor/codeception/codeception/src/Codeception/Command/Run.php:467
Codeception\Command\Run->execute() at vendor/symfony/console/Command/Command.php:298
Symfony\Component\Console\Command\Command->run() at vendor/symfony/console/Application.php:1040
Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Application.php:301
Symfony\Component\Console\Application->doRun() at vendor/symfony/console/Application.php:171
Symfony\Component\Console\Application->run() at vendor/codeception/codeception/src/Codeception/Application.php:112
Codeception\Application->run() at vendor/codeception/codeception/app.php:45
{closure}() at vendor/codeception/codeception/app.php:46
require() at vendor/codeception/codeception/codecept:7
include() at vendor/bin/codecept:120
```
Contributor guide
Research direction
Reproduce the intentional failing test with Magento 2.4.6, PHP 8.2, and framework v4.3.0, then inspect vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Allure/AllureHelper.php at line 26 and the TestContextExtension call sites. Compare behavior with v4.2.1. Done means the failure records a screenshot, the following test starts, and Allure reports are generated without the Closure serialization error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100