This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on ” JMock”.
1. The Cobertura command for merging datafiles is ________________
Explanation: The cobertura-merge.bat command is used along with parameters to run merging using Cobertura.
2. In order to write testable code, ______________ should be reduced as much as possible.
Explanation: Classes with too many dependencies require complicated tests.
3. A solution to reducing dependencies is to separate code between methods that instantiate new ____________ and methods that provide application logic.
Explanation: Separation of objects and logic leads to reduced dependencies.
4. ________________ is a design guideline that states that one class should know only as much as it needs to know.
a) Law of knowledge
b) Class laws
c) Law of Demeter
d) Action methods
Explanation: The law of demeter is also known as the Principle of Least Knowledge.
5. ____________ is a useful design pattern that ensures a class has only one instance.
a) Modular code
b) Lossless paradigm
c) Granular methods
Explanation: Most often, the implementation of a singleton defines a private constructor and a static variable.
6. The obvious drawback of a singleton is that it introduces _____________ into the application.
c) Global State
Explanation: The global state object can be accessed by anyone.
7. _______________ can easily be used to substitute application code with the test code.
d) Static binding
Explanation: Polymorphism is used to force certain code patterns to be tested.
8. At runtime, code can’t change a/an ___________ hierarchy.
Explanation: As code cannot change the hierarchy, objects needs to be composed differently.
9. For wrtiting favourable tests, __________ is perferred over inheritance.
Explanation: Composition is a better code re-use mechanism.
10. One of the main ways to decrease complexity is to try to avoid long _________ and if statements.
Explanation: Long switch statements increase the complexity of code and corresponding test cases.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.