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

Allow the JUnit 5 extension to be registered with @RegisterExtension #31

Open
RomanJRW opened this issue Sep 24, 2021 · 3 comments
Open
Labels

Comments

@RomanJRW
Copy link

In Optimize, we make use of a number of extensions. We prefer to be explicit as to the order in which they are registered, as there are sometimes unfortunate dependencies between their responsibilities. It would be great if the EzeExtension could also be registered in such a way, so that we could give it an explicit @Order(x) too.

We also instantiate extensions differently depending on the type of test class (beforeAllMode vs beforeEachMode etc.). I can imagine us having some wrapper extension around the EZE extension that gives us similar behaviour. Access to the EZE extension as an instance field would also be useful for this.

@saig0
Copy link
Collaborator

saig0 commented Sep 27, 2021

@RomanJRW thank you for raising this up.

You can register the EzeExtension as a normal JUnit 5 extension.

The annotation @EmbeddedZeebeEngine is just a shortcut that registers the extension by @ExtendWith(EzeExtension::class).

Does this work for you?
What else do you need?

@RomanJRW
Copy link
Author

RomanJRW commented Sep 27, 2021

Thanks @saig0 🙂

Is it also possible to register the extension as a class variable though? We would typically do something like this:

  @RegisterExtension
  @Order(5)
  protected ZeebeExtension zeebeExtension = new ZeebeExtension();

@saig0
Copy link
Collaborator

saig0 commented Sep 27, 2021

@RomanJRW yes, that is possible.

class EzeExtensionTest {

    @RegisterExtension
    private val eze = EzeExtension()

    private lateinit var zeebe: ZeebeEngine
    private lateinit var client: ZeebeClient
    private lateinit var clock: ZeebeEngineClock
    private lateinit var recordStream: RecordStreamSource

    // ...

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

No branches or pull requests

2 participants