0
0
JUnittesting~10 mins

@Tag for categorization 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 add a tag named "fast" to the test method.

JUnit
@Test
@Tag("[1]")
void testQuick() {
    // test code here
}
Drag options to blanks, or click blank then click option'
Afast
Bslow
Cintegration
Ddatabase
Attempts:
3 left
💡 Hint
Common Mistakes
Using a tag name that does not match the test purpose.
Forgetting to put the tag name inside quotes.
2fill in blank
medium

Complete the code to add a tag named "database" to the test class.

JUnit
@Tag("[1]")
public class DatabaseTests {
    @Test
    void testConnection() {
        // test code
    }
}
Drag options to blanks, or click blank then click option'
Adatabase
Bfast
Cui
Dperformance
Attempts:
3 left
💡 Hint
Common Mistakes
Placing the tag annotation on the method instead of the class.
Using an unrelated tag name.
3fill in blank
hard

Fix the error in the tag annotation to correctly tag the test as "integration".

JUnit
@Test
@Tag([1])
void testIntegration() {
    // test code
}
Drag options to blanks, or click blank then click option'
Aintegration
B"integration"
C'integration'
DintegrationTest
Attempts:
3 left
💡 Hint
Common Mistakes
Using the tag name without quotes causes a syntax error.
Using single quotes instead of double quotes.
4fill in blank
hard

Fill both blanks to tag the test method with "slow" and "ui" tags.

JUnit
@Test
@Tags({@Tag("[1]"), @Tag("[2]")})
void testUI() {
    // test code
}
Drag options to blanks, or click blank then click option'
Aslow
Bfast
Cui
Dintegration
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Tag multiple times without @Tags wrapper.
Mixing tag names or missing quotes.
5fill in blank
hard

Fill all three blanks to tag the test class with "performance", "database", and "critical" tags.

JUnit
@Tags({@Tag("[1]"), @Tag("[2]"), @Tag("[3]")})
public class PerformanceTests {
    @Test
    void testLoad() {
        // test code
    }
}
Drag options to blanks, or click blank then click option'
Aperformance
Bdatabase
Ccritical
Dui
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use @Tags wrapper for multiple tags.
Using incorrect tag names or missing quotes.