[
https://issues.apache.org/jira/browse/SLING-12278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Konrad Windszus updated SLING-12278:
------------------------------------
Description:
Currently neither in
https://sling.apache.org/documentation/development/osgi-mock.html#junit-5-osgi-context-junit-extension
nor in
https://sling.apache.org/documentation/development/sling-mock.html#junit-5-sling-context-junit-extension
it is mentioned that the context must not be instantiated in {{@BeforeAll}} or
{{@BeforeEach}} as at that point in time the extension has already instantiated
another context. Those two contexts may lead to subtle issues (for example if
resources are only added in the second context). For a concrete example look at
https://github.com/wcm-io/io.wcm.testing.aem-mock/issues/37.
In the best case the JUnit5 extension never creates a context (but only uses
the existing instance) or at least creation should be deferred until the Before
methods have been executed.
was:
Currently neither in
https://sling.apache.org/documentation/development/osgi-mock.html#junit-5-osgi-context-junit-extension
nor in
https://sling.apache.org/documentation/development/sling-mock.html#junit-5-sling-context-junit-extension
it is mentioned that the context must not be initialized in {{@BeforeAll}} or
{{@BeforeEach}} as at that point in time the extension has already initialized
another context. Those two context may lead to subtle issues (for example if
resources are only added in the second context). For a concrete example look at
https://github.com/wcm-io/io.wcm.testing.aem-mock/issues/37.
In the best case the JUnit5 extension never creates a context (but only uses
the existing instance) or at least creation should be deferred until the Before
methods have been executed.
> Improve handling of late instantiated context in
> SlingContextExtension/OsgiContextExtension
> -------------------------------------------------------------------------------------------
>
> Key: SLING-12278
> URL: https://issues.apache.org/jira/browse/SLING-12278
> Project: Sling
> Issue Type: Improvement
> Reporter: Konrad Windszus
> Priority: Major
>
> Currently neither in
> https://sling.apache.org/documentation/development/osgi-mock.html#junit-5-osgi-context-junit-extension
> nor in
> https://sling.apache.org/documentation/development/sling-mock.html#junit-5-sling-context-junit-extension
> it is mentioned that the context must not be instantiated in {{@BeforeAll}}
> or {{@BeforeEach}} as at that point in time the extension has already
> instantiated another context. Those two contexts may lead to subtle issues
> (for example if resources are only added in the second context). For a
> concrete example look at
> https://github.com/wcm-io/io.wcm.testing.aem-mock/issues/37.
> In the best case the JUnit5 extension never creates a context (but only uses
> the existing instance) or at least creation should be deferred until the
> Before methods have been executed.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)