This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Maven Introduction”.
1. The __________ package contains plugins that make it easier to use jMock with legacy code.
a) org.jmock.api
b) org.jmock.lib.action
c) org.jmock.lib.script
d) org.jmock.lib.legacy
View Answer
Explanation: org.jmock.lib.legacy contains several plugins that make it suitable to use jMock with legacy code.
2. _____________ class enables to imposterise abstract and concrete classes without calling the constructors of the mocked class.
a) ClassImposteriser
b) Imposteriser
c) ImposterisingClass
d) Imposter
View Answer
Explanation: The ClassImposteriser implements Imposteriser interface.
3. ________ method reports if the Imposteriser is able to imposterise a given type.
a) canImposterise(Class<?> type)
b) Imposterise(Class<?> type)
c) imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes)
d) imposter()
View Answer
Explanation: canImposterise(Class<?> type) returns true if this imposteriser can imposterise type, false otherwise.
4. ___________ creates an imposter for a given type that forwards Invocations to an Invokable object.
a) canImposterise(Class<?> type)
b) Imposterise(Class<?> type)
c) imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes)
d) imposter()
View Answer
Explanation: imposterise(Invokable mockObject, Class<T> mockedType, Class<?>… ancilliaryTypes) returns a new imposter. The imposter must implement the mockedType and all the ancialliaryTypes.
5. The mockObject parameter of imposterise() is the class representing the static type of the imposter.
a) True
b) False
View Answer
Explanation: The mockType parameter of imposterise() is the class representing the static type of the imposter.
6. The ancilliaryTypes parameter of the imposterise() function must all be interfaces.
a) True
b) False
View Answer
Explanation: The types must all be interfaces because Java only allows single inheritance of classes.
7. The __________ package contains plugins that make it easier to write custom actions by scripting their behaviour with BeanShell.
a) org.jmock.api
b) org.jmock.lib.action
c) org.jmock.lib.script
d) org.jmock.lib.legacy
View Answer
Explanation: org.jmock.lib.script is the package containing plugins to write custom actions by scripting.
8. ___________ class is an Action that executes a BeanShell script.
a) ScriptedAction
b) Scripted
c) Action
d) ScriptedActionClass
View Answer
Explanation: ScriptedAction class makes it easy to implement custom actions.
9. ______________ method performs an action in response to an invocation.
a) describeTo(Description description)
b) invoke(Invocation invocation)
c) perform(String script)
d) where(String name, Object value)
View Answer
Explanation: invoke(Invocation invocation) returns the result of the invocation, if not throwing an exception.
10. The invoke method throws which exception?
a) ArrayIndexOutOfBounds
b) StringIndexOutOfBounds
c) Throwable
d) NullPointer
View Answer
Explanation: Any checked exception thrown must be in the throws list of the invoked method.
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
- Buy Programming Books
- Apply for Information Technology Internship
- Buy JUnit Books
- Apply for JUnit Internship