JUnit Questions and Answers – Mocking an HTTP Connection

This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Mocking an HTTP Connection”.

1. The __________ test relies exclusively on the external system interface to verify its correctness.
a) White Box
b) Unit
c) Black Box
d) Loss
View Answer

Answer: c
Explanation: Black box tests have no knowledge of the internals of the code.

2. In black box testing, all that is needed to know in order to test the system properly is the system’s ______________
a) Functional specification
b) Modularity
c) Redundancy
d) Class definition
View Answer

Answer: a
Explanation: The function specification tells the output and input and not the internals.

3. White box testing is also known as ______________
a) Black box testing
b) Sand box testing
c) Closed testing
d) Glass box testing
View Answer

Answer: d
Explanation: White box requires the internals to be known just as a glass box shows what is inside.
advertisement
advertisement

4. White box testing provides better test _________ than black box testing.
a) Result
b) Coverage
c) Mechanism
d) Acceptance
View Answer

Answer: b
Explanation: White box tests cover the internal working of the code leading to greater coverage of the system.

5. ________ tests are more difficult to write and run.
a) White Box
b) Unit
c) Black Box
d) Loss
View Answer

Answer: c
Explanation: Black box tests are difficult to write because they usually deal with a graphical front end.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Black box tests can bring more ________ than white box tests.
a) Value
b) Coverage
c) Mechanism
d) Acceptance
View Answer

Answer: a
Explanation: Since black box tests just check the external characteristics including input and output, they bring more value.

7. Using ____________ testing, tests can be created that cover the public API of an application.
a) White Box
b) Unit
c) Black Box
d) Loss
View Answer

Answer: c
Explanation: As the documentation is used as the guide, black box tests are written.
advertisement

8. Higher test coverage is achieved by white box tests because of ____________
a) Access to more methods
b) Better documentation
c) Faster tests
d) More accepted tests
View Answer

Answer: a
Explanation: Since white box tests have knowledge of the implementation, they have access to more methods.

9. ____________ tests can control both the inputs to each method and the behaviour of secondary objects.
a) White Box
b) Unit
c) Black Box
d) Loss
View Answer

Answer: a
Explanation: Secondary objects like mock objects and stubs are controlled by white box tests.
advertisement

10. White box unit tests can be written against ____________ package-private, and public methods.
a) Static
b) Private
c) Protected
d) Void
View Answer

Answer: c
Explanation: As white box unit tests cover protected methods too, they give more test coverage.

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.