JUnit Questions and Answers – Using Mocks as Trojan Horses

This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Using Mocks as Trojan Horses”.

1. _________ is a free Java tool that calculates the percentage of code accessed by tests.
a) Cobertura
b) JUnit
c) XUnit
d) Maven
View Answer

Answer: a
Explanation: Cobertura is used to identify which parts of the Java program are lacking test coverage.

2. Cobertura is based on ____________
a) JUnit
b) XUnit
c) Maven
d) Jcoverage
View Answer

Answer: d
Explanation: Jcoverage is an open source tool that allows to test the effectiveness of java tests.

3. In order to measure test coverage, Cobertura creates __________ of class files specified.
a) Instrumented copies
b) Objects
c) Mocks
d) Images
View Answer

Answer: a
Explanation: Cobertura uses instrumented copies of the code to provide test coverage.
advertisement
advertisement

4. While using Cobertura from the command line, which parameter specifies the base directory?
a) −−datafile
b) −−destination
c) −−ignore
d) −−basedir
View Answer

Answer: d
Explanation: The –basedir parameter specifies the base directory of the class files that are to be instrumented.

5. ______________ is used to specify the name of the file to use for storing the metadata about the classes.
a) −−datafile
b) −−destination
c) −−ignore
d) −−basedir
View Answer

Answer: a
Explanation: The file specifies by –datafile is a single file containing serialized Java classes.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. ________ specifies the output directory for the instrumented classes.
a) −−datafile
b) −−destination
c) −−ignore
d) −−basedir
View Answer

Answer: b
Explanation: The –destination parameter is used to fix an output directory.

7. ___________ specifies a regular expression to filter out certain lines of the source code.
a) −−datafile
b) −−destination
c) −−ignore
d) −−basedir
View Answer

Answer: c
Explanation: This is useful for ignoring logging statements and for such the ignore parameter is used.
advertisement

8. ___________ is used to add extra classes and jar files to Cobertura.
a) −−datafile
b) −−destination
c) −−ignore
d) −−auxClasspath
View Answer

Answer: d
Explanation: This adds files that Cobertura may have missed during instrumentation.

9. The default value for the –datafile parameter is ____________
a) cobertura.ser
b) cobertura.dat
c) datafile.ser
d) cobertura.log
View Answer

Answer: a
Explanation: The file is created in the current directory.
advertisement

10. To use cobertura, we need to include __________
a) cobertura.jar
b) junit.jar
c) hamcrest.jar
d) junitCobertura.jar
View Answer

Answer: a
Explanation: The external jar file adds Cobertura to the present project.

Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

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.