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.
advertisement

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.

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.
advertisement

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.

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.

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.

advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn