Skip to content
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

Introduce extension API for container templates #4315

Merged
merged 61 commits into from
Feb 19, 2025

Conversation

marcphilipp
Copy link
Member

@marcphilipp marcphilipp commented Feb 12, 2025

Overview

Analogous to @TestTemplate on the method level, this PR introduces a class-level @ContainerTemplate annotation with an accompanying ContainerTemplateInvocationContextProvider extension API.

Resolves #871.


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@georgberky
Copy link

Holy smokes, thanks for your work! I've been waiting for this. Can I help with testing this somehow?

@marcphilipp
Copy link
Member Author

marcphilipp commented Feb 12, 2025

Sure thing! There will be follow-up work (most importantly #878) but if you could review the code and try using it guided by the docs in this PR, I'd be very interested in your feedback.

@Sola-ris
Copy link

Sola-ris commented Feb 13, 2025

I have two questions about the container templates, hope it's Ok to ask them here

  • Are there plans to make the container template invocations interceptable via an InvocationInterceptor
    like test method templates?
  • Change return type to Stream<? extends TestTemplateInvocationContext> #3577 talks about declaring the return type of TestTemplateInvocationContextProvider#provideTestTemplateInvocationContexts
    as Stream<? extends TestTemplateInvocationContext> instead of Stream<TestTemplateInvocationContext>.
    Was ContainerTemplateInvocationContextProvider#provideContainerTemplateInvocationContexts's return type declared without the upper bound to be in sync with TestTemplateInvocationContextProvider?

@marcphilipp
Copy link
Member Author

  • Are there plans to make the container template invocations interceptable via an InvocationInterceptor
    like test method templates?

We don't currently have plans to support intercepting the entire invocation of a container template which would encompass all of its test methods, nested test classes etc. Instead, we will add new lifecycle methods and extension points, specifically for container templates in #4320.

  • Change return type to Stream<? extends TestTemplateInvocationContext> #3577 talks about declaring the return type of TestTemplateInvocationContextProvider#provideTestTemplateInvocationContexts
    as Stream<? extends TestTemplateInvocationContext> instead of Stream<TestTemplateInvocationContext>.
    Was ContainerTemplateInvocationContextProvider#provideContainerTemplateInvocationContexts's return type declared without the upper bound to be in sync with TestTemplateInvocationContextProvider?

Thanks for reminding me of that issue! I've changed ContainerTemplateInvocationContextProvider accordingly in bffb6c7. TestTemplateInvocationContextProvider will have to wait until 6.0 (which is planned for later this year) because changing it is binary incompatible with previous releases.

@Sola-ris
Copy link

We don't currently have plans to support intercepting the entire invocation of a container template which would encompass all of its test methods, nested test classes etc. Instead, we will add new lifecycle methods and extension points, specifically for container templates in #4320.

Those should also cover the use case I had in mind, thank you.

Thanks for reminding me of that issue! I've changed ContainerTemplateInvocationContextProvider accordingly in bffb6c7. TestTemplateInvocationContextProvider will have to wait until 6.0 (which is planned for later this year) because changing it is binary incompatible with previous releases.

You're welcome :D

@marcphilipp
Copy link
Member Author

As discussed in the team, I'll go ahead and merge this to make it easier to work on #878 next. Feedback is still appreciated, though, even post-merge!

@marcphilipp marcphilipp enabled auto-merge (squash) February 19, 2025 07:45
@marcphilipp marcphilipp disabled auto-merge February 19, 2025 07:45
@marcphilipp marcphilipp merged commit 202d939 into main Feb 19, 2025
15 checks passed
@marcphilipp marcphilipp deleted the marc/871-container-templates branch February 19, 2025 07:55
@bruderj15
Copy link

This is awesome! I was awaiting this feature for a long time!
Will I have to wait a little bit longer until 5.13.0 or may you release it earlier?
Either way, great work!

@marcphilipp
Copy link
Member Author

Will I have to wait a little bit longer until 5.13.0 or may you release it earlier?

You will have to wait until 5.13. However, if you're willing to use a milestone version, we will probably release an 5.13.0-M1 early on to make it easier to try out this new feature and provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce extension API for container templates
4 participants