JUnit Questions and Answers – Maven Surefire

«
»

This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Maven Surefire”.

1. ____________ translates ExpectationErrors into JUnit’s AssertionFailedErrors.
a) JUnit3ErrorTranslator
b) JUnit3Mockery
c) MockObjectTestCase
d) VerifyingTestCase
View Answer

Answer: a
Explanation:JUnit3ErrorTranslator translate Expectation Errors into JUnit AssertionFailedErrors.
2. ___________ is a Mockery that reports expectation errors as JUnit 3 test failures.
a) JUnit3ErrorTranslator
b) JUnit3Mockery
c) MockObjectTestCase
d) VerifyingTestCase
View Answer
Answer: a
Explanation: JUnit3Mockery is used to report expectation errors.
advertisement

3. __________ is a TestCase that supports testing with mock objects.
a) JUnit3ErrorTranslator
b) JUnit3Mockery
c) MockObjectTestCase
d) VerifyingTestCase
View Answer

Answer: a
Explanation: MockObjectTestCase is used for testing mock objects.

4. ____________ is a TestCase that verifies postconditions after the test has run and before the fixture has been torn down.
a) JUnit3ErrorTranslator
b) JUnit3Mockery
c) MockObjectTestCase
d) VerifyingTestCase
View Answer

Answer: a
Explanation: VerifyingTestCase is a class that verifies post conditions.

5. To write a mock object test in JUnit 3, MockObject needs to be extended.
a) True
b) False
View Answer

Answer: b
Explanation: To write a mock object test in JUnit 3, MockObjectTestCase needs to be extended.
advertisement

6. A _________ is a JUnit Rule that manages JMock expectations and allowances.
a) JunitRuleMockery
b) JmockRuleMockery
c) JunitRule
d) JunitMockery
View Answer

Answer: a
Explanation: JunitRuleMockery asserts that expectations have been met after each test has finished.

7. The __________ class provides factory methods for the executor services provided in the package.
a) Executors
b) Exceptions
c) ReadOnly
d) AbstractMock
View Answer

Answer: a
Explanation: The Executors class has factory methods for the executor services.

8. A __________ offers services for the components it’s hosting, such as lifecycle, security, transaction, distribution, and so forth.
a) Component
b) Container
c) Mock
d) Appraisal
View Answer

Answer: b
Explanation: A component executes in a container.
advertisement

9. Stubs work well to ________ a given class for testing and asserting the state of its instances.
a) Delete
b) Enhance
c) Isolate
d) Append
View Answer

Answer: c
Explanation: Stubbing a servlet container allows us to track how many requests were made, what the state of the server is, or what URL s where requested.

10. Stubs test the behavior of faked objects.
a) True
b) False
View Answer

Answer: b
Explanation: In stubs, specialized methods are required to verify states.

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