Get Started With JUnit 5

If you want to learn how to work smarter, you have come to the right place. This is a beginner friendly course that teaches you techniques which help you to save time when you have to write tests with JUnit 5.

Why Bother?

JUnit 5 is a very popular testing framework that’s used to write tests for JVM applications. If you have to write tests in 2023, it’s extremely likely that you must use JUnit 5. The goal of my Junit 5 course is to help you get started with JUnit 5 and teach you techniques which help you to save your precious time, especially, when things go wrong and your tests fail.

You will learn to:

  • Make your tests fun to write and maintain by writing less test code.
  • Transform your test suite into an executable specification which identifies the requirements of your application.
  • Write assertions which shorten your feedback loop.

Why Should You Learn From Me?

My name is Petri Kainulainen and I have used JUnit 5 from day one. In fact, I was one of the supporters of the JUnit Lambda crowdfunding campaign which funded the development of the first JUnit 5 version.

I have used JUnit 5 for writing tests to Java and Kotlin applications, and I have integrated it with testing libraries and frameworks such as AssertJ, Mockito, Mockk, Spring MVC Test, TestContainers, and WireMock. I have written thousands of tests with JUnit 5 and I am constantly looking for new ways to write better tests.

To be honest, I have to admit that I have written my share of bad tests. I created this course because I don’t want that you will make the same mistakes as I did.

Get started today

If you bought my Test With Spring course, I will give you free access to this course. If you want to redeem this benefit, take a look at the FAQ.

If you aren’t living in the European Union, I cannot sell this course to you. I simply don’t have the time or money to ensure that I am not breaking any tax laws, which, by the way, are literally changing all the time. If you want to buy this course and you aren’t living in the European Union, drop me an email. If I get enough emails, I will check if there is something I can do to fix this problem.

Introduction to JUnit 5 Course

The Introduction to JUnit 5 course is a text-based course that has 25 lessons, 47 exercises, and 13 quizzes. This is an opinionated course and I will cover only the features which I have found useful when I have written unit and integration tests with JUnit 5.

The teaching method which I use in this course has three cornerstones:

  • Every lesson of this course has practical learning goals and the lesson describes how you can achieve these goals. For example, a lesson might describe how you can create a Maven project that can compile and run tests which use JUnit 5.
  • I believe that the easiest way to learn new things is to do them yourself. That’s why most lessons of this course have hands-on exercises. These exercises will help you to understand how you can use your new skills in your daily work.
  • The quizzes of this course make sure that you have learned the required skills.

Here Is What You Get

This course is divided into six topics:

Running JUnit 5 Tests With Maven and Gradle
2 lessons (text), 2 exercises, 2 quizzes, and sample projects.

This topic describes how you can integrate JUnit 5 with Maven and Gradle. After you have finished this topic, you:

  • Can get the required dependencies with Maven and Gradle.
  • Know how you can run JUnit 5 tests with Maven and Gradle.
Introduction to JUnit 5 Test Classes
4 lessons (text), 8 exercises, 4 quizzes, and sample projects.

This topic helps you to write your first tests with JUnit 5. After you have finished this topic, you:

  • Know how you can write normal and nested tests with JUnit 5.
  • Can identify the invocation order of setup, teardown, and test methods.
  • Understand how you can write parameterized tests with JUnit 5.
Selecting the Invoked Test Methods
2 lessons (text), 15 exercises, 2 quizzes, and sample projects.

This topic describes how you can group your test methods and run only the tests which belong to a specific group. After you have finished this topic, you:

  • Know how JUnit 5 tags work.
  • Can add JUnit 5 tags to your test methods.
  • Understand how you can select the invoked test methods with Maven and Gradle.
Writing Assertions With JUnit 5
11 lessons (text), 22 exercises, 3 quizzes, and sample projects.

This topic describes how you can write assertions with JUnit 5 and use third party assertion libraries. After you have finished this topic, you:

  • Can write assertions with JUnit 5 Assertion API, Hamcrest, and AssertJ.
  • Understand how you can combine Hamcrest matchers.
  • Know how you can shorten your feedback loop by using JUnit 5 assertion groups or writing soft assertions with AssertJ.
  • Can emphasize business rules by writing custom Hamcrest matchers or writing custom assertions with AssertJ.
Introduction to JUnit 5 Extension Model
2 lessons and 1 quiz (THIS TOPIC IS UNDER WORK)

This topic describes how you can leverage the JUnit 5 extension model when you are writing tests with JUnit 5. After you have finished this topic, you:

  • Know what JUnit 5 extension is.
  • Can use JUnit 5 extensions.
  • Understand how you can write your own JUnit 5 extensions.

This topic is under work! It’s missing lessons, quizzes, and exercises.

Writing Better Tests With JUnit 5
4 lessons (text) and 1 quiz.

This topic identifies best practices which help you to write better tests with JUnit 5. After you have finished this topic, you:

  • Understand what kind of test cases you should write.
  • Know how you can select the test cases which have the best ROI if you don’t have enough time to test all possible scenarios.
  • Understand why you should write your assertions with AssertJ.
  • Know how you can save your time by writing nested tests which don’t have duplicate code.
  • Understand how you can remove duplicate code from your test suite by writing parameterized tests.

Get started today

Take a Look at the Material Before You Buy

I don’t expect anyone to buy this course if they cannot take a look at the material before the purchase. That’s why I have published these sample lessons:

14-Day Unconditional Money Back Guarantee

I have put a lot of work into this course and I am confident that it will be useful to you. That’s why I am offering a 14-day unconditional money back guarantee. If this course doesn’t help you save your time, just contact support within 14 days of your purchase and you will get your money back. No questions asked.

Get Started Today

Unfortunately I cannot sell this course at the moment because I have to figure out a new way to handle my VAT obligations to the European Union.

Frequently Asked Questions

Take a look at the FAQ page