This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Timeout Testing”.
1. What is timeout testing?
a) Testing for exceptions
b) Testing code execution within time limits
c) Testing code correctness
d) Testing code with time functions
View Answer
Explanation: Timeout Testing checks if the code runs within specified time limits.
2. The ___________ parameter is used along with the @Test annotation to test for timeouts.
a) Expected
b) Timeout
c) NoLimit
d) Time
View Answer
Explanation: Timeout Parameter specifies the maximum time each test method can take.
3. @Test(timeout = 130) implies a time limit of ___________
a) 130 milliseconds
b) 130 minutes
c) 130 seconds
d) 1.30 minutes
View Answer
Explanation: The timeout argument is in milliseconds.
4. Timeout testing is ____________
a) Software Dependent
b) Hardware Dependent
c) Software and Hardware Dependent
d) Software and Hardware Independent
View Answer
Explanation: Since different software and hardware gives different performance, timeout testing is software and hardware dependent.
5. What applies the same timeout to every test method of a class?
a) @Timeout
b) @Expected
c) Timeout Rule
d) Not possible to apply same timeout
View Answer
Explanation: The timeout can be specified as a rule so that it is applied to every method.
6. A Timeout Rule is initialized by ____________
a) @Rule public Timeout object = new Timeout()
b) @Rule public Timeout object = Timeout.seconds()
c) public Timeout object = Timeout.seconds()
d) public Timeout object = new Timeout()
View Answer
Explanation: The correct way to initialise a Timeout Rules is using the Timeout.seconds() function.
7. Where is the Timeout class present?
a) org.junit.rules.Timeout
b) org.junit.Timeout
c) org.Timeout
d) org.junit.RuleClasses.Timeout
View Answer
Explanation: The correct package for the Timeout class is under org.junit.rules.
8. The Timeout Rule implements which interface?
a) Timeout
b) Test
c) TestingTimeout
d) TestRule
View Answer
Explanation: The TestRule interface is extended and implemented by Timeout Rule.
9. If a timeout which has been specified lapses before the completion of the test, its execution is interrupted with _____________
a) Interrupt()
b) Thread.interrupt()
c) Thread.interruptable()
d) Threads.interruptable()
View Answer
Explanation: The timeout is brought about through Interruptible I/O and locks.
10. What does a specified timeout of 0 imply?
a) 130 milliseconds
b) 130 minutes
c) 130 seconds
d) Not set
View Answer
Explanation: A specified timeout of 0 implies that the Timeout is not set.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Buy JUnit Books
- Apply for Information Technology Internship
- Apply for JUnit Internship
- Buy Programming Books
- Practice Programming MCQs