[MAGNOLIA-8267] ComponentsTestUtil causes failures with @MagnoliaRepositoryTest Created: 21/Dec/21  Updated: 17/Jan/22  Resolved: 17/Jan/22

Status: Closed
Project: Magnolia
Component/s: testing
Affects Version/s: None
Fix Version/s: 6.2.16

Type: Bug Priority: Neutral
Reporter: Michael Duerig Assignee: Michael Duerig
Resolution: Fixed Votes: 0
Labels: artt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MAGNOLIA-8188 Lightweight repository setup for tests Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Epic Link: Basic JUnit 5

 Description   

Steps to reproduce

Call ComponentsTestUtil.clear() in an @AfterEach method in a @MagnoliaRepositoryTest annotated test.

Expected results

All existing tests pass.

Actual results

All tests fail:

info.magnolia.objectfactory.MgnlInstantiationException: No concrete implementation defined for interface info.magnolia.context.SystemContext
at info.magnolia.test.mock.AbstractComponentProvider.getComponent(AbstractComponentProvider.java:157) ~[test-classes/:?]
at info.magnolia.objectfactory.Components.getComponent(Components.java:107) ~[classes/:?]
at info.magnolia.context.ContextFactory.getSystemContext(ContextFactory.java:63) ~[classes/:?]
at info.magnolia.context.MgnlContext.getSystemContext(MgnlContext.java:347) ~[classes/:?]
at info.magnolia.context.MgnlContext.release(MgnlContext.java:615) ~[classes/:?]
at info.magnolia.test.juni5.RepositorySupport.afterEach(RepositorySupport.java:115) ~[test-classes/:?] 

Development notes

ComponentsTestUtil.clear() interferes with the setup/tear down of the extensions. This is a problem of ComponentsTestUtil.clear() being too intrusive violating JUnit 5's "wrapping behaviour". (For the same reason ComponentsTestUtil.clear() needs to be placed after super.tearDown() instead of before currently). IMO this needs to fixed in ComponentsTestUtil by introducing means for resetting the component provider to its previous state instead of just clearing it.


Generated at Mon Feb 12 04:31:09 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.