0
0
JUnittesting~10 mins

@EnabledOnJre for JRE-specific tests 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 enable the test only on Java 17.

JUnit
@EnabledOnJre({JRE.[1])
void testFeature() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AJAVA_11
BJAVA_17
CJAVA_8
DJAVA_19
Attempts:
3 left
💡 Hint
Common Mistakes
Using a Java version constant that does not match the intended JRE version.
Forgetting to import the JRE enum.
2fill in blank
medium

Complete the code to enable the test only on Java 11 and Java 17.

JUnit
@EnabledOnJre({JRE.JAVA_11, JRE.[1])
void testMultipleVersions() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AJAVA_8
BJAVA_19
CJAVA_15
DJAVA_17
Attempts:
3 left
💡 Hint
Common Mistakes
Using a version not supported or not intended for the test.
Syntax errors in the array of JRE versions.
3fill in blank
hard

Fix the error in the annotation to correctly enable the test on Java 8.

JUnit
@EnabledOnJre(JRE.[1])
void testLegacySupport() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AJAVA8
BJAVA-8
CJAVA_8
DJAVA8_
Attempts:
3 left
💡 Hint
Common Mistakes
Using JAVA8 without underscore causes a compile error.
Using hyphens or trailing underscores is invalid.
4fill in blank
hard

Fill both blanks to enable the test only on Java 15 or Java 19.

JUnit
@EnabledOnJre({JRE.[1], JRE.[2])
void testFutureVersions() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AJAVA_15
BJAVA_11
CJAVA_19
DJAVA_8
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing older versions like Java 8 or 11 when the test targets newer versions.
Syntax errors in the array notation.
5fill in blank
hard

Fill all three blanks to enable the test on Java 8, Java 11, and Java 17.

JUnit
@EnabledOnJre({JRE.[1], JRE.[2], JRE.[3])
void testMultipleLTS() {
    // test code here
}
Drag options to blanks, or click blank then click option'
AJAVA_8
BJAVA_11
CJAVA_17
DJAVA_19
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to close the array with a closing brace.
Using incorrect enum constants or missing commas.