Skip to content

Provide a way to NOT inherit extensions in nested containers or methods #1842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jlink opened this issue Apr 2, 2019 · 7 comments
Closed

Comments

@jlink
Copy link
Contributor

jlink commented Apr 2, 2019

Sometimes an extension should not be applied to nested containers, e.g. if the extension wants to open and close a resource just once per annotated container. It seems to me that currently any registered extension will also be applied to its children and I couldn't find a way to switch that off.

The workarounds I can think of require strange things like storing the first context object in order to compare the current context object with it. I might be missing something, though.

Related Issues

@sormuras
Copy link
Member

sormuras commented Apr 2, 2019

Test authors should be in full-charge to decide what resource is to be used where. Extension authors should provide means to configure/setup that requirement using the existing model. If the extension model lacks such configuration, we need to improve it.

Said that, I favor a generic and built-in ResourceSupplier SPI as layed out here: https://github.com/sormuras/brahms#resource-manager-extension

@jlink
Copy link
Contributor Author

jlink commented Apr 2, 2019

I guess ResourceSupplier would solve my problem at hand. I am not sure, though, that the more general problem of deciding where exactly to apply an extension can be solved with it.

Moreover, it's yet another mechanism to annotate and modify test behaviour - making things even more complicated and offering one more option for the same or very similar problems.

@sormuras
Copy link
Member

sormuras commented Apr 2, 2019

With extensions comes complexity...

With ResourceSupplier you get explicit, type-safe and easy to see resources that you (as a test author) control. No need for an own extension. 3rd-party extensions may use the ResourceSupplier SPI to manage resources as well, but should (optionally) pass the control of creating/closing (read managing) to the test author.

@sormuras
Copy link
Member

sormuras commented Apr 2, 2019

@testcontainers and other long-living resources are a perfect use-case: https://twitter.com/philipp_hauer/status/1112757852685430785

I'm preparing a Java 8-based ResourceSupplier implementation here: https://github.com/micromata/raktajino -- soon.

@sbrannen
Copy link
Member

sbrannen commented Apr 2, 2019

This is a duplicate of or subtask of #506.

@marcphilipp marcphilipp modified the milestones: 5.5 M2, 5.5 Backlog Apr 18, 2019
@stale
Copy link

stale bot commented May 13, 2021

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution.

@stale stale bot added the status: stale label May 13, 2021
@stale
Copy link

stale bot commented Jun 3, 2021

This issue has been automatically closed due to inactivity. If you have a good use case for this feature, please feel free to reopen the issue.

@stale stale bot closed this as completed Jun 3, 2021
@marcphilipp marcphilipp removed this from the 5.8 Backlog milestone Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants