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

Continuous testing is not picking up custom JUnit extension from same module #24229

Closed
famod opened this issue Mar 10, 2022 · 9 comments · Fixed by #24440
Closed

Continuous testing is not picking up custom JUnit extension from same module #24229

famod opened this issue Mar 10, 2022 · 9 comments · Fixed by #24440
Labels
Milestone

Comments

@famod
Copy link
Member

famod commented Mar 10, 2022

Describe the bug

A Junit extension, e.g. a org.junit.jupiter.api.extension.BeforeAllCallback, that is registered via src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension is not picked up when mvn quarkus:test (CT) is run in that module.

If CT is run in another module that depends on the module that contains the extension, everything works as expected!

Expected behavior

"local" extension is run

Actual behavior

"local" extension is not run/found

How to Reproduce?

q_ct-junitext.zip

  • mvn verify ✔️
  • run test in Eclipse ✔️
  • mvn quarkus:test

Output of uname -a or ver

No response

Output of java -version

17.0.2, vendor: BellSoft

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.3.Final and 2.7.4.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4

Additional information

ℹ️ There is no issue when the extension is registered via @ExtendWith(...)!

@famod famod added the kind/bug Something isn't working label Mar 10, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 10, 2022

/cc @stuartwdouglas

@famod
Copy link
Member Author

famod commented Mar 10, 2022

/cc @geoand @aloubyansky (FTR)

@famod
Copy link
Member Author

famod commented Mar 10, 2022

Turns out that the "Deployment Class Loader" that is used for discovering the tests does know the META-INF/services/org.junit.jupiter.api.extension.Extension, but the "Augmentation Class Loader" which is used for the actual execution doesn't.

@famod
Copy link
Member Author

famod commented Mar 17, 2022

@aloubyansky @stuartwdouglas any thoughts/hints?
This inconsistency is pretty annoying when you rely on global JUnit extensions (for all test types and modes).
I'm under the impression that this problem and the one from #24257 would vanish if that serviceloader file would be known to the augmentation classloader...?

@aloubyansky
Copy link
Member

aloubyansky@a0d8601 appears to fix it. It replaces the current TCCL which is the augment CL with the deployment CL. @stuartwdouglas what do you think about that?

@famod
Copy link
Member Author

famod commented Mar 17, 2022

Interesting! I was thinking about that as well, but after seeing that ModuleTestRunner is using the augmentation classloader to run the Runnable from JunitTestRunner, I was under the impression that has to be/stay like that.
I'll give it a spin in my real project.

@famod
Copy link
Member Author

famod commented Mar 20, 2022

@aloubyansky your change does seem to fix this issue! 👍
The annotation issue in #24257 requires more work/fixes, though.

@stuartwdouglas
Copy link
Member

That approach seems correct, the fact it was not using it must have been an oversight on my part.

@aloubyansky
Copy link
Member

Thanks @stuartwdouglas I'll open a PR then

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

Successfully merging a pull request may close this issue.

4 participants