Transcripted Summary

In case you are using JUnit 4 and you want to migrate to JUnit 5, you must know and you must have probably already seen that some of the annotations you used to implement some behaviors in JUnit 5 are different from the annotations for the same behavior in JUnit 4.

Therefore, when you are trying to migrate from JUnit 4 to JUnit 5, you will need to keep in mind what these annotations are.

I've listed here the most frequent ones, and the ones we have tackled in this tutorial -

  • @BeforeClass and @Before from JUnit 4 have now become @BeforeAll and @BeforeEach in JUnit 5

  • @AfterClass and @After from JUnit 4 have now become @AfterAll and @AfterEach

  • @Ignore annotation is now @Disabled in JUnit 5

  • @Category annotation from JUnit 4 has been replaced with the @Tag annotation in JUnit 5

When you are trying to do the migration from JUnit 4 to JUnit 5, these are the things you need to look at, and, of course, some of the imports that you have been using in JUnit 4 will need to be changed to use the corresponding classes and packages from JUnit 5.

However, when you're doing the migration, you don't need to do it manually all by yourself.

IntelliJ can help you do the migration quite easily, and even automatically, if you want.

I have provided here a link to where you can find information on how to easily switch from JUnit 4 to JUnit 5 while using IntelliJ.

To give you a quick summary about how that can be done - well, they have two options.

The first one is to do all of the migration automatically with the hit of a button, or you can first highlight what tests need to be migrated, and then, case-by-case, you could take each of them and use their tool to automatically migrate from JUnit 4 to JUnit 5, while also showing you what the changes are so that you can see whether everything is okay when you're doing the migration.

So check out this link; this is very, very useful.

There's also a video for it, so this is going to help you a lot in doing your migration.

That's it for our course on JUnit 5.

Thank you so much for watching. I really hope it was useful for you.

Now, in order for you to check out the code that I have shown in this tutorial, I first cleaned it up a little bit - namely, I removed the unused imports and I formatted the code nicely, and then I uploaded it to GitHub.

You can find it at the location that you can see on this slide, so that you have access to all of the code that I've shown throughout this entire tutorial.

Good luck with JUnit 5; I really hope you're going to use it, because it is quite an awesome framework, and there are so many great features for our testing.

Thank you. Take care. I will see you soon.


© 2024 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR