Practical Guide to JUnit 5 Parameterized Tests

Wei Kang
Government Digital Services, Singapore
4 min readNov 20, 2021

--

Learn how to write JUnit 5 parameterized tests.

Photo by Green Chameleon on Unsplash

If you have not heard of JUnit 5, you may want to check out the following guides which I find very useful to kickstart the journey with JUnit 5:

Every upgrade might be a chore to everyone, but I personally feel that the advantages that JUnit 5 brings, outweighed the pain and time I used to migrate from JUnit 4 to JUnit 5 (it is quite easy, just laborious 😅).

In my previous article (see below 👇), I have touched on creating a JUnit 5 extension to help in testing Apache Spark easily in your Apache Spark Java project.

In this tutorial, I will be going through how we could leverage JUnit 5 Parameterized Tests to allow us to write a single test to execute with multiple different arguments.

What Do We Need

We will need the following dependencies:

--

--