JUnit Questions and Answers – Timeout Testing

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

Answer: b
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

Answer: b
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

Answer: a
Explanation: The timeout argument is in milliseconds.
advertisement
advertisement

4. Timeout testing is ____________
a) Software Dependent
b) Hardware Dependent
c) Software and Hardware Dependent
d) Software and Hardware Independent
View Answer

Answer: c
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

Answer: c
Explanation: The timeout can be specified as a rule so that it is applied to every method.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: b
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

Answer: a
Explanation: The correct package for the Timeout class is under org.junit.rules.
advertisement

8. The Timeout Rule implements which interface?
a) Timeout
b) Test
c) TestingTimeout
d) TestRule
View Answer

Answer: d
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

Answer: b
Explanation: The timeout is brought about through Interruptible I/O and locks.
advertisement

10. What does a specified timeout of 0 imply?
a) 130 milliseconds
b) 130 minutes
c) 130 seconds
d) Not set
View Answer

Answer: d
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.