Java - Interview Questions and Answers for 'Mockito' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Mockito


   




Interview Questions and Answers for 'Mockito' - 5 question(s) found - Order By Newest

 Q1. Difference between Assert and Verify ?
admin
info@buggybread.com
Ans. Assert works only if assertions ( -ea ) are enabled which is not required for Verify.

Assert throws an exception and hence doesn't continue with the test if assert evaluates to false whereas it's not so with Verify.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     assert   junit   mockito   verify   testing   unit testing   barclays


 Q2. What should I do if I want to make sure that a particular method of a class is getting called ?
admin
info@buggybread.com
Ans. If its a static method of the class , we can use verify to make sure its getting called.

If its an instance method , We can mock the object and then use verify with the mocked object to make sure that the method is getting called.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     junit   mockito   mock


 Q3. What is the use of Mockito.any ?
admin
info@buggybread.com
Ans. In case we need to verify that a method is being called with any argument and not a specific argument we can use Mockito.any(Class), Mockito.anyString, Mockito.anyLong etc.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     junit   mockito   mock   mockito.any


 Q4. Which of the following is not the advantage of Mocking frameworks ?

a. It helps testing the module independently
b. It helps in faster unit testing
c. It helps in testing code even when external dependencies like service calls are not working
d. It helps in doing end to end Integration Testing
Anonymous
Ans. It helps in doing end to end Integration Testing

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     mocking frameworks   mockito   unit testing   junits


 Q5. Have you ever tried mocking static methods ?Testing2016-12-07 16:13:30

Ans. Yes, that can be done using Power Mock. Mockito doesnt provide a way to mock static methods.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     Mockito  junit  powermock




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: