Parameterized Test with @ValueSource
This lesson demonstrates use of @ValueSource to pass different arguments to @ParameterizedTest.
We'll cover the following
@ValueSource
@ValueSource
is one of the simplest ways to pass arguments array to @ParameterizedTest
method. This array can be of following types -
- short
- byte
- int
- long
- float
- double
- char
- java.lang.String
- java.lang.Class
Let’s look into a demo.
Step 1 - Let’s create a class OddEven.java
, it is our class under test.
Step 2 - To this class we provide a method by name isNumberEven()
. This method takes in an integer value and returns true if the number is even or false if the number is odd.
Get hands-on with 1400+ tech skills courses.