Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to disable the test method using the correct annotation.
JUnit
@[1]
public void testFeature() {
// test code here
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Ignore instead of @Disabled
Forgetting the '@' symbol
Using @Test which runs the test instead of skipping
✗ Incorrect
The @Disabled annotation in JUnit is used to skip or disable a test method.
2fill in blank
mediumComplete the code to disable the entire test class.
JUnit
@[1] public class FeatureTests { @Test public void testOne() {} }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Test which runs tests
Using @Ignore which is from JUnit 4, not recommended in JUnit 5
Missing the '@' symbol
✗ Incorrect
Placing @Disabled on a class disables all tests inside it.
3fill in blank
hardFix the error in the code to properly disable the test method.
JUnit
@Test
@[1]
public void testFeature() {
// test code
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Ignore instead of @Disabled
Using @Skip which is not a JUnit annotation
Using @Test twice
✗ Incorrect
The correct annotation to disable a test in JUnit 5 is @Disabled, not @Ignore or @Skip.
4fill in blank
hardFill both blanks to disable the test method with a reason message.
JUnit
@[1]("[2]") public void testFeature() { // test code }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Ignore with a reason (JUnit 4 style)
Using @Test instead of @Disabled
Not providing a string reason
✗ Incorrect
The @Disabled annotation can take a string reason explaining why the test is skipped.
5fill in blank
hardFill all three blanks to disable a test method with a reason and import the correct annotation.
JUnit
import org.junit.jupiter.api.[1]; @[2]("[3]") public void testFeature() { // test code }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing @Ignore instead of @Disabled
Using @Test instead of @Disabled
Not providing the reason string
✗ Incorrect
The @Disabled annotation is imported from org.junit.jupiter.api and can take a reason string like "Skipped".