[MAGNOLIA-8490] Magnolia platform bootstrapping for test scenarios Created: 29/Jun/22 Updated: 21/Feb/23 |
|
| Status: | Selected |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Low |
| Reporter: | Andres Garcia | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
[ ]*
I can inject any javax.inject.Provider declared in a module .xml in my tests.
[ ]*
The setup required per test suite/class is minimal (a single annotation, rule or extension)
|
| Date of First Response: | |
| Team: |
| Description |
|
*UPD 21.02.2023*
ContextWhile developing some Norsu integrations in magnolia integration modules we've noticed that we need a `ContentAPI` object to query the Norsu backend from within the test code, E2E fashion (example of usage of an annotation that bootstraps a Norsu Postgresql container: https://git.magnolia-cms.com/projects/CLOUD/repos/norsu/browse/rest-integration/src/test/java/info/magnolia/norsu/rest/NorsuDeliveryEndpointTest.java#64 ). Current statusAll integration tests which need a `ContentAPI` instance have to do their own bootstrapping of the `ContentAPI` class (example: https://git.magnolia-cms.com/projects/CLOUD/repos/norsu/browse/rest-integration/src/test/java/info/magnolia/norsu/rest/NorsuDeliveryEndpointTest.java#218-223 ) using the `DataSource` which the `@NorsuTest` provides. While creating another extension such as `@NodeAPITest` might be a possible solution, we think it's a workaround that can be better solved elsewhere. (BTW: `@NorsuTest` is a prerequisite to the ContentAPI so it cannot be retrofitted to include such feature). Providing this `@ContentAPITest` extension might be proposed in a separate effort and a ticket would be issued in that case. ProposalThe better solution is, in our opinion, to have a way to bootstrap a basic, for tests, magnolia platform in our magnolia integration modules test (ie: having the IoC framework and other parts) which will be able to provide the basic magnolia building blocks to an integration test, much like what somehow currently `FakeMagnoliaUI` does. In this particular case, the solution, when adequately integrated with Norsu (or whatever other integration) would bootstrap the actual `ContentAPI` that a running magnolia bundle would use; and we could just grab it (like with an `@Inject` field) and then use it in the test. (This is much similar to what `@SpringBootTest` does) |
| Comments |
| Comment by Christoph Meier [ 21/Feb/23 ] |
|
see https://magnolia-cms.slack.com/archives/C0294NAECQM/p1676876266099769 for some very helpful explanations about this ticket |