Controlling execution order of JUnit 5 extension relative to other extensions not possible
See original GitHub issueI am trying to use this extension together with @SpringBootTest
. How to ensure testcontainer starts first before executing SpringBootTest
extension?
This issue is not limited to Spring, but rather an issue as soon as multiple extensions are used at the same time and a certain ordering is required.
Context
From what I see in the JUnit 5 documentation the annotation order matters. Since Java sorts annotations in bytecode alphabetically Spring will always run first unless it is possible to explicitly import @ExtendWith(TestcontainersExtension.class)
. Currently, this cannot be done due to TestcontainersExtension
being package-private.
Possible solution
I believe making TestcontainersExtension
public is all that’s needed for users to be able to explicitly define the order of multiple extensions.
Based on https://github.com/testcontainers/testcontainers-java/pull/887#issuecomment-447815105 and https://github.com/testcontainers/testcontainers-java/pull/887#issuecomment-447818414.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
@kiview @michael-simons I’m trying to write a new JUnit Jupiter extension that builds on top of the Testcontainers extension. The original solution proposed in this issue (make
TestcontainersExtension
a public class) is exactly I need, because then I can do:I’m trying to follow the various issues linked in this issue to find out why the
TestContainersExtension
class was never made public, but didn’t find anything. Is this option still on the table?Thanks a lot for checking against #1020. Let’s try to merge it soon 🙂