JUnit Questions and Answers – Putting Ant to The Task

This set of JUnit Assessment Questions and Answers focuses on “Putting Ant to The Task”.

1. The __________ interface allows setting expectations for an associated expected invocation.
a) IMocksControl
b) IExpectationSetters<T>
c) IExpectation<T>
d) Isetters<T>
View Answer

Answer: b
Explanation: The IexpectationSetters<T> interface is extended and allows setting expectation for the expected invocation.

2. _____________ function expect the last invocation any times.
a) andStubReturn(T value)
b) andThrow(Throwable throwable)
c) anyTimes()
d) asStub()
View Answer

Answer: c
Explanation: anyTimes() returns IExpectationSetters<T> object to allow method call chaining.

3. ______________ sets stub behavior for the expected invocation.
a) andStubReturn(T value)
b) andThrow(Throwable throwable)
c) anyTimes()
d) asStub()
View Answer

Answer: d
Explanation: Setting the stub behavior is needed for void methods.
advertisement
advertisement

4. _______________ expect the last invocation between min and max times.
a) times(int count)
b) times(int min, int max)
c) once()
d) asStub()
View Answer

Answer: b
Explanation: The max and min values are passed as arguments in the function definition times(int min, int max).

5. ____________ expect the last invocation a specified number of times.
a) times(int count)
b) times(int min, int max)
c) once()
d) asStub()
View Answer

Answer: a
Explanation: times (int count) specifies the number of times to expect the last invocation via the count argument.

6. _____________ sets a stub object that will be used for the calculation of the answer for the expected invocation.
a) andAnswer(IAnswer<? extends T>answer)
b) andDelegateTo(Object delegateTo)
c) andStubAnswer(IAnswer<? extends T> answer)
d) andThrow(Throwable throwable)
View Answer

Answer: c
Explanation: andStubAnswer(IAnswer<? extends T>answer) either returns a value, or throws an exception.

7. _______________ sets a stub object implementing the same interface as the mock.
a) andAnswer(IAnswer<? extends T> answer)
b) andDelegateTo(Object delegateTo)
c) andStubAnswer(IAnswer<? extends T> answer)
d) andStubDelegateTo(Object delegateTo)
View Answer

Answer: d
Explanation: The expected method call will be delegated to it with the actual arguments.
advertisement

8. _____________ records a call but returns nothing.
a) andVoid()
b) times(int min, int max)
c) once()
d) asStub()
View Answer

Answer: a
Explanation: andVoid() is used to chain calls on void methods expectLastCall(), andThrow(e), andVoid().

9. _____________ expects the last invocation once.
a) andVoid()
b) times(int min, int max)
c) once()
d) asStub()
View Answer

Answer: c
Explanation: This is the default in EasyMock.
advertisement

10. _______________ sets a return value that will be returned for the expected invocation.
a) andReturn(T value)
b) times(int min, int max)
c) once()
d) asStub()
View Answer

Answer: a
Explanation: The andReturn( T value) take as an argument value, which is the value to return.

Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of JUnit Assessment Questions, 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.