
Mockito Tutorial: Learn mocking with 25 Junit Examples - Step 13: Mockito Spy
Interactive Video
•
Information Technology (IT), Architecture
•
University
•
Practice Problem
•
Hard
Wayground Content
FREE Resource
Read more
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the primary purpose of using a spy in Mockito?
To completely replace the functionality of a class
To simplify the code structure
To track method calls while retaining original functionality
To enhance the performance of a test
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the default behavior of a mock in Mockito?
It performs the actual method logic
It logs the method call
It returns a default value
It throws an exception
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you change the return value of a method in a mock?
By using the 'modify' method
By using the 'replace' method
By using the 'stub' method
By using the 'override' keyword
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a key difference between a mock and a spy?
A spy replaces all methods, a mock does not
A spy can track method calls, a mock cannot
A mock can track method calls, a spy cannot
A mock retains original functionality, a spy does not
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In what scenario is it more appropriate to use a spy instead of a mock?
When you need to test a new feature
When you want to track method calls in a legacy system
When you want to improve test performance
When you need to simplify the code
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens when you add an element to a spy of an ArrayList?
An exception is thrown
The size of the list increases
The size of the list remains unchanged
The list is cleared
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you verify that a method was never called on a spy?
By using the 'check' method
By using the 'verify' method with 'never'
By using the 'assertNever' method
By using the 'confirm' method
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?