-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Investigate JUnit 5 #6402
Comments
/cc @sbrannen |
Regarding the first bullet point: You can run JUnit 4 tests with the new JUnit Platform. You just have to add junit-vintage-engine to the classpath. Please note that JUnit 5 is not final yet. We've merely shipped M1. As such, we are still working on providing migration patterns from JUnit 4 to JUnit 5. So let's keep in touch! :) |
Thanks @marcphilipp! |
JUnit 5 support would be very useful as part of the general Spring Boot + Kotlin improvements discussed in #5537. Using JUnit 4 in Kotlin is almost ok except for one major pain point: The good news is that JUnit 5 M4 is likely to support non-static cc @sbrannen |
Speaking only for myself, the |
@philwebb , i believe that it's possible to run JUnit4 Tests with JUnit5, from what i understand, you just need to add the I think that we should integrate JUnit5 as standard in |
In preparation for switching tests to JUnit 5, run existing JUnit 4 tests using the JUnit Vintage test engine. Related to spring-projectsgh-6402
Would it make sense to work on support for JUnit 5 for Spring Boot 2? |
Thanks to Spring Framework's test framework, we don't really need to do anything in Boot to support JUnit 5. We already have a sample showing how to use the two together. |
And we have dependency management for it now (see #10240). I suspect we'll need to refine this a bit more though. |
I didn't know it's already usable. So much the better! |
Nice, I have been able to update MiXiT Kotlin + Boot 2.0 application to use Junit 5 and it works as expected, including the per class lifecycle mode: mixitconf/mixit@05c68f4. |
Did you already address that issue (can't recall which one right now) regarding support for "test annotations" so that it includes test annotations from JUnit Jupiter? |
Ahhh... found the issue: #6898 which is still open. |
FYI: just for fun... I migrated your If you're interested in having as a part of Spring Boot, I could submit a PR. 😉 |
@sbrannen while playing with JUnit 5 + Java 9 and trying to pass JVM arguments to Junit 5 in order to add some modules, I faced junit-team/junit5#650 and found that various capabilities are waiting for gradle/gradle#1037 to be fixed. As you know I am a big Junit 5 fan, but I am wondering if the builtin Gradle Junit 5 support is required before switching to it by default in Boot or not. Any thoughts? |
@sdeleuze My gut instinct is that we not should switch to it by default in 2.0. (I accidentally said switch in 2.0 but I meant to say we should not switch) I've edited this comment. |
@philwebb Should we move this to an earlier milestone? |
That's correct. We've been waiting for a long time now, and we hope the Gradle team picks up the task (no pun intended) by the end of 2017.
I'd say the built-in support from the JUnit 5 team is "good enough" for most builds, but it is obviously far from feature complete. There are, however, custom workarounds for some missing features. The status of the built-in Maven Surefire plugin is about the same. The Maven Surefire team has taken over the code, but they have yet to publish anything. So, in the end, it's honestly a tough call: the build support works for Maven and Gradle, but it's currently suboptimal. |
With regard to testing using Java 9 modules, that's a whole different can of worms. The world is still deciding/debating how best to do that. FWIW, @sormuras has put in a lot of work for prototyping JUnit 5 + Java 9. Plus, JUnit 5.1 will include support for scanning the module-path in addition to the current support for scanning the class-path (i.e., to find test classes). |
@sbrannen Ok thanks, that's true that Java 9 is a whole story by itself. @philwebb As proposed by @wilkinsona I think you should not wait |
@sdeleuze Oh wow. That was a total typo. I meant to say we should not switch :/ |
Phew! |
Yeah, sorry about that :) |
Sorry but we have no intention of doing that. We don't want to overwhelm users with too many options and, IMO, the right call for this is to go with whatever the default in Spring Boot is. |
No worries, and no reason to be sorry. I only said it would be "quite nice", not a must. 😉 |
We discussed this today in the context of possibly switching to JUnit 5 by default in Spring Boot 2.1. We concluded that the ecosystem isn't ready yet due to the additional build tool configuration that's still required. SUREFIRE-1330 will help with that but it has no ETA. |
@wilkinsona Thanks for the update! I'm sure you're aware that Gradle now provides native support. According to junit-team/junit5#809 (comment), starting with 3.0.0-M2 Surefire will not require additional configuration anymore. @Tibor17 Are there any updates on the Surefire timeline? |
@wilkinsona, understood. Thanks for sharing the team decision. |
SUREFIRE-1330 has been fixed in Surefire 2.22.0. Spring Boot has upgraded in #13500, targeting 2.1. |
Spring Boot 2.2 will switch to JUnit 5 by default. This issue has now been superseded by the following issues:
|
JUnit 5 looks like it might be a very awkward upgrade for both our users and Spring Boot itself. We'll need to come up with a plan going forward for how people should upgrade.
Of particular concern:
@Test
annotations andexpectedException
has been dropped@Rule
annotation (this will break a lot of our tests and we'll need to offer alternatives to the rules we offer)We might be able to offer JUnit 5 alongside JUnit 4 for a while (possibly a long while) so that people can use both.
I imagine probably going to frustrate a lot of users given that mostly their own test code has very little direct contact with the JUnit API. Mostly people use
@Test
,@Before
/@After
, perhaps a few@Rule
annotations and someAssert
calls.Related issue junit-team/junit5#169
The text was updated successfully, but these errors were encountered: