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

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.

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

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

Answer: b
Explanation: anyObject() expects any object argument.

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.

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