Repository navigation
Conversation
Prepares reusing the display form of object arguments.
Step::releaseArguments() replaces object arguments with the text they are displayed as, so the objects can be garbage collected while the step is still printed the same way, e.g. in the failure summary at the end of the run. If converting an object fails, its class name is used. Objects nested in array arguments are replaced by their decoded JSON, which is displayed the same way. Scenario::releaseStepArguments() does this for all recorded steps and their meta steps; Executor also drops its closure.
Codeception keeps every finished test until the suite ends, including the arguments of its recorded steps. Objects passed to steps, e.g. Doctrine entities or closures, stay in memory together with everything they reference (entity managers, service containers), so memory and garbage collection time grow with every test. With `settings: release_step_arguments: true`, the steps' object arguments are released once a test has finished and all TEST_END listeners have run. Step output in reports is unchanged. The setting is disabled by default because extensions might read the raw arguments of finished tests. See Codeception/module-doctrine#15
Runs a suite with the setting enabled and disabled and checks whether the finished tests' steps still hold the objects passed to them, and that the failure summary still shows the released arguments.
W0rma
force-pushed
the
release-step-arguments
branch
from
November 9, 2026 14:13
8653c2d to
0d7d190
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codeception keeps every finished test until the suite ends, including the arguments of its recorded steps. Objects passed to
$I->…, such as Doctrine entities or closures, stay in memory for the whole run, together witheverything they reference (entity managers, service containers). Memory use and garbage-collection time grow with every test. See Codeception/module-doctrine#15.
With the new setting, object arguments are replaced by the text Codeception displays for them once a test has finished and all
TEST_ENDlisteners have run:Step output stays the same, including the failure summary printed at the end of the run. The setting is off by default, because extensions might read the raw arguments of finished tests.
In a Symfony/Doctrine functional suite with about 800 tests, enabling it reduced run time from 3:51 to 2:51 and peak memory from 583 MB to 163 MB.
Changes
Step::stringifyObject()is extracted fromstringifyArgument()so the release can reuse itStep::releaseArguments()andScenario::releaseStepArguments()release the recorded steps and their meta steps;Executoralso drops its closureConfigurationthroughSuiteManagerandSuitetoTest::realRun(), the same way asreport_useless_testsBehaviour notes
__toString(), is computed when the test finishes, for passing tests too. Before, it was only computed when a step was printed. If the conversionthrows, the class name is used.
This PR was prepared with the help of AI.