0
0
JUnittesting~10 mins

Test naming conventions deep dive 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 name the test method following the common JUnit convention.

JUnit
@Test
public void [1]() {
    // test code here
}
Drag options to blanks, or click blank then click option'
ArunTest
BTest1
CshouldReturnTrueWhenInputIsValid
Dcheck
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague names like 'Test1' or 'check' that don't explain the test purpose.
2fill in blank
medium

Complete the code to follow the 'given_when_then' test naming style.

JUnit
@Test
public void [1]() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AgivenValidUser_whenLogin_thenSuccess
BtestLogin
CloginTestCase
DcheckLogin
Attempts:
3 left
💡 Hint
Common Mistakes
Using short or generic names that don't describe the test steps.
3fill in blank
hard

Fix the error in the test method name to follow JUnit naming conventions.

JUnit
@Test
public void [1]() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AshouldThrowExceptionWhenInputIsNull
B123testMethod
CtestMethod!
DTest Method
Attempts:
3 left
💡 Hint
Common Mistakes
Starting method names with numbers or including spaces/special characters.
4fill in blank
hard

Fill both blanks to create a test method name that follows the 'should_when' pattern and uses camelCase.

JUnit
@Test
public void [1]_[2]() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AshouldReturnTrue
BwhenInputIsValid
CWhenInputIsNull
Dshould_return_false
Attempts:
3 left
💡 Hint
Common Mistakes
Using underscores inside camelCase words or capitalizing the second part incorrectly.
5fill in blank
hard

Fill all three blanks to create a descriptive test method name using the 'given_when_then' style with camelCase.

JUnit
@Test
public void [1]_[2]_[3]() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AgivenUserIsLoggedIn
BwhenUserClicksLogout
CthenSessionEnds
DGivenUserIsLoggedIn
Attempts:
3 left
💡 Hint
Common Mistakes
Capitalizing words incorrectly or mixing styles.