-
Notifications
You must be signed in to change notification settings - Fork 57
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
Question: JUnit 5 Support? #103
Comments
Currently blocked by junit-team/junit5#672 Once that is done, supporting JUnit 5 should be easy. |
+1 |
Other possibly related JUnit issues: |
Now that junit-team/junit5#672 has been implemented, do you plan to support JUnit 5? |
Perhaps junit5 might be a solution for cdi-unit as well. Examples can be seen in tests. A first (not yet released) implementation of the support can be seen in JUnit5Extension |
@aschoerk In other words, make the CDI-Unit Test class not a bean, but just That would certainly fit with these environments that insist on creating the Test object, but CDI-Unit itself and often CDI-Unit-based tests make use of CDI interceptors, eg for |
@kalgon said:
Specifically TestInstanceFactory: junit-team/junit5#672 (comment) and junit-team/junit5#1443 Marked as "experimental", included in JUnit 5.3.0-RC1, not yet part of a GA release. There's this still waiting to be implemented, to control the ClassLoader, but I don't think it's needed by CDI-Unit (or Weld): junit-team/junit5#201 I think we'll have to implement some sort of So it looks like it may be possible now. I'm not using JUnit 5 myself yet, so I can't say when I'll find the time to investigate further. |
I had that problem and solved it by using a regular class see testRequestScope() in I tried TestInstanceFactory in JUnit 5.3.0-RC1 but sadly it did not fit in my current intellij-Environment. So I dropped that approach. I fear it also might not be so easy to handle the inner classes since those can not be created using weld. But we will see. At the moment JUnit5 promises to allow very well structured Tests. |
Can you elaborate? What sort of problems did you see?
In your picture, I gather CanHandleValidationExceptions, CanMapOtherExceptions and GreenPathTests are non-static inner classes of MobileInformationServiceEjbCdiUnit5Test? |
Sorry, no at the moment not. In the current snapshot I switched to 5.3.0-RC1, introduced a primitive factory and the tests seem to work. I need to look further into that. Perhaps the intellij-installation on the other computer is slightly different.
yes, tests starting with [#] are different parameters generated by Method. Btw. the inner classes work in per_class-lifecycle (necessary to be able to provide a non static parameter generating method in the class) the outer level is per_method as default. |
Implementing TestInstanceFactory look quite well, but there ssem to be yet problems, when Life-Cycle gets changed in inner classes. see stackoverflow |
@aschoerk Did you report your problem to the junit team? It could be fixed before 5.3 is released. |
@kalgon not yet, I followed a link in the user guide. As soon as I am back in WiFi I will move the stackoverflow issue to github |
Update: I have a basic proof of concept working. It's a total hack job with duplicated code from I haven't yet tested support for all the annotations like AdditionalClasses, ActivatedAlternatives, Mock, SupportJaxRs, SupportEjb, SupportDeltaspike, ProducerConfig, but I hope they'll just work, as long as the annotations are not on an inner class. Mock support for inner classes will probably need a bit of extra work. There is one problem though: the Interceptors are working for outer classes, but inner classes only support field injection (A: because of the above |
I haven't fixed the copy-paste crimes or other deficiencies, but in case anyone wants to try it, I've uploaded the mess here: https://github.com/seanf/cdi-unit/tree/junit5 Sample JUnit 5 test here: https://github.com/seanf/cdi-unit/blob/junit5/cdi-unit/src/test/java/org/jglue/cdiunit/CdiExtensionTest.java If anyone wants to hack on it, send a PR to my seanf fork, branch name junit5. |
@aschoerk's issue is junit-team/junit5#1566. See also junit-team/junit5#1567 |
Any update on this? |
Since this project has been inactive for quite a while, I decided to implement a JUnit 5 extension for CDI Unit in a separate project cschabl/cdi-unit-junit5. It is intended to serve as a kludge as long as CDI Unit itself doesn't provide one. |
Hi @cschabl, Did you manage to convert a complete set of tests from CDI-Unit to JUnit 5? |
Hi @ikysil , |
Hi @cschabl , I've seen your project at https://github.com/cschabl/cdi-unit-junit5 |
Hi @ikysil , no I don't mind. Do you want me to create a PR or do you like to copy and adjust the code for the cdi unit project? |
Hi @cschabl , Thank you for the feedback. Both will work for me as long as you agree. Thank you for the efforts, I will work on restructuring and integrating your code. |
Hi @ikysil , let me know when you're done. |
Hi @ikysil , |
You know that ioc-unit supports junit5? |
For the moment, no development around JUnit 5 were done at all - except this project by @cschabl |
Would love to see Jupiter support in CDIUnit. The other project (cdi-unit-junit5) doesn't seem to support jakarta name spaces. |
Feel free to play with changes at #287 |
I've been working on a JakartaEE-compatible version of cdi-unit-junit5 based on CDI-Unit 5.0.0.EA2, simultaneously. |
Hey!
Are there any plans to upgrade or support JUnit 5 extension model?
The text was updated successfully, but these errors were encountered: