0
0
JUnittesting~10 mins

Multiple parameter types in JUnit - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a parameterized test method with two parameters.

JUnit
[1] void testMethod(int number, String text) {}
Drag options to blanks, or click blank then click option'
A@Test
B@ParameterizedTest
C@CsvSource
D@ValueSource
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Test instead of @ParameterizedTest for parameterized tests.
Placing the annotation inside the parameter list.
2fill in blank
medium

Complete the code to provide multiple parameters using CSV source.

JUnit
@ParameterizedTest
@CsvSource([1])
void testMethod(int number, String text) {}
Drag options to blanks, or click blank then click option'
A"1,apple", "2,banana"
B"1, 'apple', 2, 'banana'"
C"1;apple", "2;banana"
D"1|apple", "2|banana"
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons or pipes instead of commas as separators.
Putting all values in one string instead of separate strings.
3fill in blank
hard

Fix the error in the parameterized test method declaration.

JUnit
@ParameterizedTest
@CsvSource({"1,apple", "2,banana"})
void testMethod([1] number, String text) {}
Drag options to blanks, or click blank then click option'
Aint
Bdouble
CString
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of int for numeric CSV values.
Using incompatible types like boolean or double.
4fill in blank
hard

Fill both blanks to correctly declare a parameterized test with multiple parameter types and source.

JUnit
@ParameterizedTest
@CsvSource([1])
void testMethod([2] number, String text) {}
Drag options to blanks, or click blank then click option'
A"3,orange", "4,grape"
Bint
CString
D"3;orange", "4;grape"
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons instead of commas in CSV strings.
Using String type for numeric parameters.
5fill in blank
hard

Fill all three blanks to complete a parameterized test method with multiple parameter types and CSV source.

JUnit
@ParameterizedTest
@CsvSource([1])
void testMethod([2] number, [3] text) {}
Drag options to blanks, or click blank then click option'
A"5,melon", "6,berry"
Bint
CString
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong separators in CSV strings.
Mixing up parameter types.