Skip to content

Commit

Permalink
[TASK] Consecutive tests do not fail on left over instance
Browse files Browse the repository at this point in the history
When a test uses GeneralUtility::addInstance() to add
(non-singleton) instances, and if that test does not
consume all those instances, it fails.

The patch adds a call to clean up left over instances.
This way, tests executed afterwards start clean again
and don't fail as side-effect as well anymore.

Releases: main
  • Loading branch information
lolli42 committed Mar 27, 2023
1 parent 04add64 commit d47606e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Classes/Core/Unit/UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ protected function tearDown(): void
}
}
}
if (!empty($notCleanInstances)) {
// Reset instance list (including singletons & container) to not let all further tests fail
GeneralUtility::purgeInstances();
}
// Let the test fail if there were instances left and give some message on why it fails
self::assertEquals(
[],
Expand Down

0 comments on commit d47606e

Please sign in to comment.