Exercise 4: Create Your Test Data With a Custom ArgumentsProvider

This exercise helps you to understand how you can create the test data that’s passed to a parameterized test by using a custom ArgumentsProvider. Let’s start by taking a quick look at the system under test.

The ProgrammingLanguage enum specifies different programming languages. Its source code looks as follows:

public enum ProgrammingLanguage {


The ProgrammingParadigm enum specifies different programming paradigms. It also has one static method called fromProgrammingLanguage(). This method returns the programming paradigm that’s used by the programming language given as a method parameter. The source code of the ProgrammingParadigm enum looks as follows:

public enum ProgrammingParadigm {


    public static ProgrammingParadigm fromProgrammingLanguage(
            ProgrammingLanguage source
    ) {
        return switch(source) {
            case C -> ProgrammingParadigm.PROCEDURAL;
            case CLOJURE -> ProgrammingParadigm.FUNCTIONAL;
            case SMALLTALK -> ProgrammingParadigm.OBJECT_ORIENTED;

During this exercise you will create the test data that’s passed to a parameterized test method which ensures that the fromProgrammingLanguage() method of the ProgrammingParadigm enum is working as expected. You can finish this exercise by following these steps:

1. Open the ProgrammingParadigmTest class that’s found from the com.cleantestautomation.junit5intro package.

2. Write the custom ArgumentsProvider that creates the test data which is passed to the shouldReturnCorrectProgrammingParadigm() method. Remember that your test data must test every possible scenario.

3. Ensure that JUnit 5 creates the test data by using your new ArgumentsProvider when it runs your parameterized test method.

4. Run your parameterized test and make sure that all test invocations pass.