Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
25.8. Common JUnit Annotations
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
5 cards from this lesson. Good the night before a test.
Try these first
- 1.
What does the @Test annotation do?
Hint
Think about how JUnit knows what to run.
- 2.
What is the purpose of @Disabled?
Hint
Consider how you would mark a test that isn’t ready.
- 3.
What does the @Test annotation signify?
- To skip tests
- To define a test
- To clean up resources
Hint
This is the core annotation for creating unit tests.
- 4.
True or False: The @AfterEach annotation runs after each test method.
- True
- False
Hint
Consider the lifecycle of the test method.
- 5.
Create a JUnit test class for a library system where you manage book loans. Use both @BeforeAll and @AfterAll to handle setup and teardown processes, and demonstrate usage of other annotations.
Hint
Think of how sections of your library can share the same resources.
- 6.
Describe a scenario in your ongoing project where using @Disabled would be appropriate and explain your reasoning.
Hint
Consider times when you are actively coding a feature and tests don't reflect the current state.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting