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
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
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
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
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
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
Explanation: geq stands for greater than or equal.
7. By default, a mock is thread safe.
a) True
b) False
View Answer
Explanation: Unless NOT_THREAD_SAFE_BY_DEFAULT is set, a mock is thread safe.
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
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
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
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.
- Practice Programming MCQs
- Check JUnit Books
- Check Programming Books
- Apply for Computer Science Internship