0
0
JUnittesting~5 mins

@Disabled for skipping tests in JUnit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the @Disabled annotation in JUnit?
The <code>@Disabled</code> annotation is used to skip or ignore a test method or class temporarily. It prevents the test from running without deleting or commenting out the code.
Click to reveal answer
beginner
How do you disable a single test method using JUnit?
Add the @Disabled annotation directly above the test method. For example:<br>
@Disabled<br>@Test<br>void testExample() { ... }
Click to reveal answer
intermediate
Can you disable an entire test class in JUnit? How?
Yes, by placing the <code>@Disabled</code> annotation above the class declaration, all tests inside that class will be skipped during execution.
Click to reveal answer
intermediate
What happens to the test report when tests are skipped using @Disabled?
Skipped tests are reported as 'skipped' or 'ignored' in the test report. They do not count as passed or failed but are noted so you know they were intentionally not run.
Click to reveal answer
beginner
Why might you want to use @Disabled instead of deleting a test?
Using @Disabled keeps the test code for future use or debugging. It allows you to temporarily skip tests that are flaky, incomplete, or dependent on external factors without losing the test logic.
Click to reveal answer
What does the @Disabled annotation do in JUnit?
ARuns the test multiple times
BMarks the test as failed
CEnables the test to run only on weekends
DSkips the annotated test method or class
Where do you place the @Disabled annotation to skip a test method?
AIn the test class constructor
BInside the test method body
CAbove the test method declaration
DBelow the test method declaration
If you want to skip all tests in a class, what should you do?
AAdd <code>@Disabled</code> above the class declaration
BAdd <code>@Disabled</code> to each test method
CDelete the test class
DRename the test class
How are skipped tests shown in the test report?
AAs failed tests
BAs skipped or ignored tests
CAs passed tests
DThey are not shown at all
Why is it better to use @Disabled instead of deleting a test?
ATo keep the test code for future use
BTo make the test run faster
CTo automatically fix test errors
DTo run the test on a different machine
Explain how and why you would use the @Disabled annotation in JUnit testing.
Think about situations when you want to skip tests without deleting them.
You got /4 concepts.
    Describe the impact of using @Disabled on test reports and test suite results.
    Consider how test reports show tests that were not executed.
    You got /3 concepts.