JUnit Questions and Answers – Ant Targets, Projects, Properties and Tasks

This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Ant Targets, Projects, Properties and Tasks”.

1. ________________ creates a mock builder allowing to create a partial mock for the given class or interface.
a) createMockBuilder(Class<T> toMock)
b) createMock(Class<T> toMock)
c) createNiceControl()
d) createNiceMock(Class<T> toMock)
View Answer

Answer: a
Explanation: createMockBuilder(Class<T> toMock) is the old version of partialMockBuilder(Class), which is more completion friendly.

2. The ____________ interface is used in the creation of partial mocks with EasyMock.
a) IMockBuilder<T>
b) IMocker<T>
c) IBuilder<T>expect(T value)
d) MockBuilder<T>
View Answer

Answer: a
Explanation: The MockBuilder class implements the ImockBuilder<T> interface.

3. ____________ creates a control of the requested type.
a) createControl()
b) createControl(MockType type)
c) createNiceControl()
d) createNiceMock(Class<T> toMock)
View Answer

Answer: b
Explanation: createControl(MockType type) returns an ImocksControl object.
advertisement
advertisement

4. _____________ returns the expectation setter for the last expected invocation in the current thread.
a) createControl()
b) createControl(MockType type)
c) createNiceControl()
d) expect(T value)
View Answer

Answer: d
Explanation: The parameter value is used to transport the type to the ExpectationSetter.

5. anyObject() expects any double argument.
a) True
b) False
View Answer

Answer: b
Explanation: anyObject() expects any object argument.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. _____________ expects a comparable argument greater than or equal the given value.
a) anyObject()
b) anyString()
c) geq(Comparable<T> value)
d) anyDouble()
View Answer

Answer: c
Explanation: geq stands for greater than or equal.

7. By default, a mock is thread safe.
a) True
b) False
View Answer

Answer: a
Explanation: Unless NOT_THREAD_SAFE_BY_DEFAULT is set, a mock is thread safe.
advertisement

8. ______________ create a new capture instance that will keep only the last captured value.
a) newCapture()
b) makeThreadSafe()
c) createNiceControl()
d) createNiceMock(Class<T> toMock)
View Answer

Answer: a
Explanation: The newCapture method without arguments creates a new capture.

9. _____________ reports an argument matcher.
a) newCapture()
b) makeThreadSafe()
c) reportMatcher(IArgumentMatcher matcher)
d) createNiceMock(Class<T> toMock)
View Answer

Answer: c
Explanation: The reportMatcher method is used to report an argument matcher.
advertisement

10. The _______________ interface decides whether an actual argument is accepted.
a) IMockBuilder<T>
b) IMocker<T>
c) IBuilder<T>expect(T value)
d) IArgumentMatcher
View Answer

Answer: d
Explanation: IargumentMatcher is a public interface which decides whether an actual argument is accepted.

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