JUnit - How to Configure JUnit 4 and JUnit 5

JUnit Configuration

To configure JUnit we just need to have a build manager like Maven or Gradle for example.

In our examples, we will use Maven, so you just need to add the following snippet of code in your pom.xml

If you are using Gradle:

Notice that we'are downloading the version 4.12. Maybe you would like to get the latest JUnit version bu take care of that.

We can download the latest version that is not production ready, but you need to know that JUnit Architecture has been changed in 5.0 version and a few features will not work as expected.

If you are really brave, so you can download the latest Alpha version

We will cover the differences between JUnit 4 and JUnit 5 in another guide.

And that's it!

Alexandre Gama

Alexandre Gama

Hacking Code Founder

Hacking Code Founder and Writer, Passionate Senior Software Engineer and Team Leader at @Elo7, Teacher of several courses at Caelum, Speaker at many conferences and terrible guitar player.
JUnit Tutorial - How to Configure JUnit 4 and JUnit 5 - Java Tutorial by Hacking Code

JUnit - How to Configure JUnit 4 and JUnit 5

Do you know the differences between JUnit 4 and JUnit 5 Configuration? Let's see!
JUnit Tutorial - Mastering Assertions - Java Tutorial by Hacking Code

JUnit - Mastering JUnit Assertions

Are you ready to see a lot of JUnit Examples of how to use Assertions?
JUnit Tutorial - Hamcrest Assertions - Java Tutorial by Hacking Code

JUnit - How to Use Hamcrest Assertions

Hamcrest Assertions is a great way to get your tests easier to read! Let's see how!
JUnit Tutorial - Tests in Suites - Java Tutorial by Hacking Code

JUnit - Tests in Suite

You can organize your tests in a Suite mode!
JUnit Tutorial - Test Execution Order - Java Tutorial by Hacking Code

JUnit - Test Execution Order

Do you want order your test execution? Probably it is a bed smell, but let's try it out!
JUnit Tutorial - Testing Exceptions - Java Tutorial by Hacking Code

JUnit - Testing Exceptions

Java Exceptions are in all places right? Let's deal with that with honor!

0 Comments

Leave a Reply

Share This
Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

%d bloggers like this: