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.
advertisement

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.

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.
advertisement

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.

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.

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.
advertisement

Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn