1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Testing in Java

Connected

Exercise

Username Validation Parameterized

As your Java knowledge increases, you've decided to revisit the username validator from Chapter 1. Since it depends on a single output, it can be shortened using parameterization.

Consider all the failure outcomes of the isValidUsername() method. Condense them all in a single @ParameterizedTest.

The necessary JUnit packages have been imported for you.

Instructions

100 XP
  • Use the correct annotation to mark a test as a parameterized test.
  • Add a null input to the test.
  • Add the annotation to the input values in the test.
  • Mark the value type of the inputs.