Make TestcontainersExtension public#5285
Conversation
Proposed fix for testcontainers#2045 When we use multiple JUnit5 extensions, the way to order them is via the @ExtendsWith({FirstExtension.class, SecondExtension.class}) annotation. But TestcontainersExtension is not public so we can only use the @testcontainers annotion and we are not able to order the extension. See the following documentation on JUnit5: https://junit.org/junit5/docs/current/user-guide/#extensions-registration-declarative
|
Hi @hmatt1, sorry for not reacting sooner. Can you give me an example of a list of extensions, where the order with regards to the Looking around different 3rd party Jupiter extensions, (like junit-pioneer), I get the feeling that having the |
|
@kiview It is mentioned in the issue that one user wanted to do some registry authentication config: #2045 (comment) The issue also mentions
I'm not familiar with the specific extensions the users are referring to. However, in the docs I linked to, they provide this example of defining a custom composed annotation that combines multiple extensions in a reusable way. This is another use case that isn't supported when the TestcontainersExtension class is package-private. This is something I wanted to take advantage of in my project, since we have a few extensions we are using across our tests and would like to define them in one place. |
|
Thanks for providing more info @hmatt1. I was talking with @sormuras from the JUnit team and he generally recommended to not go for I can imagine that there might be concrete cases where this ordering is the only way to make it work, but I wanted to know the concrete case, to understand if there might be a better approach (similar to what e.g. Spring provides with DynamicPropertySource). |
|
@kiview Is the use case around creating a composed annotation that includes the TestContainers extension still valid? My understanding is that it is not possible if the extension isn't |
|
@hmatt1 Thanks for providing the PR, after some consideration and thanks to the feedback of the community, we decided to make the extension |
Proposed fix for #2045
When we use multiple JUnit5 extensions, the way to order them is via the @ExtendsWith({FirstExtension.class, SecondExtension.class}) annotation.
But TestcontainersExtension is not public so we can only use the @testcontainers annotion and we are not able to order the extension.
See the following documentation on JUnit5: https://junit.org/junit5/docs/current/user-guide/#extensions-registration-declarative