Skip to content
New issue

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

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

Already on GitHub? # to your account

JUnit 5 extension auto-registration support (?) #5420

Closed
reckart opened this issue Nov 10, 2022 · 4 comments
Closed

JUnit 5 extension auto-registration support (?) #5420

reckart opened this issue Nov 10, 2022 · 4 comments

Comments

@reckart
Copy link
Contributor

reckart commented Nov 10, 2022

Is there already a way to use the JUnit extension auto-registration with the bnd test runner?

Simply adding a runroperties in the *.bndrun file does not seem to do the trick:

-runproperties: \
	junit.jupiter.extensions.autodetection.enabled=true,\
@bjhargrave
Copy link
Member

Did you try

-runvm: -Djunit.jupiter.extensions.autodetection.enabled=true

@kriegfrj
Copy link
Contributor

Auto-registration depends on the ServiceLoader. In addition to getting the right system property set, you might also need to:

  1. use Spi-Fly to make sure that the bridge the service loader client in the Jupiter engine bundle (BSN "junit-jupiter-engine") is properly instrumented to load ServiceLoader implementations from the OSGi service registry;
  2. register your extension as a service in your own bundle (declaring it as a @Component should do the trick);
  3. ensure that the bundle that contains your extension is started before the test suite runs.

I have not personally tested this myself so I might not be of much further help to you in any of the details, but it theory it should work.

@bjhargrave
Copy link
Member

Not a Bnd problem.

@kriegfrj
Copy link
Contributor

This might be more appropriate in the discussion forum https://bnd.discourse.group

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

No branches or pull requests

3 participants