-
Notifications
You must be signed in to change notification settings - Fork 64
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
Support JUnit 4 via the VintageTestEngine #53
Comments
The initial goal is support for the JUnit Platform in general, with specific support for JUnit Jupiter. However, some preliminary work has been done to provide built-in support for JUnit Vintage: Lines 94 to 95 in acf1474
If you are experiencing specific issues, please provide a sample application demonstrating what you are encountering or provide stack traces, debug output, etc. that could help the team assess the problem. As I mentioned above, the current "support" for JUnit Vintage is preliminary which means you likely have to add some manual configuration for yourself -- for example, reflection config for JUnit Vintage internals. Though, in theory it should be possible to get JUnit 4 tests running via the JUnit Vintage |
I see, thanks for the clarification. I'll give running the JUnit4 tests a try and followup in this thread what configurations I used if I'm able to get it working. |
I played around with it and was able to get JUnit 4 working with the following additional classes marked for build-time initialization:
Link to example: https://github.com/dzou/junit4-experiment I'll try this out on a bigger set of tests and see if it still works. |
Great! Thanks for sharing, and please do keep us posted on your progress. See also: #59 (comment) |
Hey @dzou! We've added really basic support for the JUnit Vintage engine as part of #59 - could you try out the latest changes on master and see if they work for your samples? While it's at a really basic level right now, it should hopefully grow over time and encompass more JUnit features out of the box |
Great! I'll give it a try and will followup. |
@gradinac -- Hey, thanks for making those changes. It works great for the simple test repo! I just tried it on a more complex repo of tests here: https://github.com/dzou/java-pubsub I am getting an error that looks like this:
I guess the puzzling part is that the class it is complaining about I have also gotten this error for the |
I did some further debugging, trying to understand what tests the junit vintage engine picks up. I basically found that once we get into And then I'm failing when it tries to resolve the EDIT: Oh, I guess it must be because I'm falling back into test-discovery mode. I still see this error even though I have this dependency added. Maybe I am missing something; will debug a bit more tomorrow.
EDIT 2: Something also worth noting is that JUnitPlatformFeature (line 89) the |
Ok, I think I got it to work. It looks like in my project setup something got messed up with the So to fix the problem, I define it again in the native profile right before the native-maven-plugin and it seemed to work! My setup below:
But yes, it looks JUnit4 is working well @gradinac 🙂. |
Hey @dzou! Thank you very much for the detailed analysis! :) It seems like the tests were indeed running in the discovery mode - this particular one seems to come from the JUnit test discovery internals. For the discovery mode, we will most likely need to somehow tell JUnit to ignore these failures and just skip over the descriptor from which they originated. As for JUnit4, that's great news! :) We currently have the most basic tests in place for it and no additional automatic configuration , but hopefully that support will grow over time |
Cool. I'll close this for now since JUnit4 looks to be supported well; if any issues emerge in the future then people can file separate issues. |
@dzou, thanks for providing the detailed analysis of the errors you encountered!
This actually stems from the fact that the For example, the JUnit Platform Build tools and IDEs do something similar. For details on what Maven Surefire includes by default, consult the official documentation.
That's the other part of the puzzle. The The combination of scanning all JARs in the classpath and NOT having a class name or package name filter results in the JUnit Vintage Thus, if the fallback discovery mode is to be retained, it must properly configure either a class name or package name include filter, and it probably should not blindly add everything to the classpath for classpath scanning. However, I believe that @lazar-mitrovic intends to remove the fallback discovery mode. So that may become a moot point. |
Many thanks for this great project.
I wanted to ask about
junit-platform-native
: Is there future plans to make this compatible with JUnit4 running tests viajunit-vintage-engine
?The text was updated successfully, but these errors were encountered: