Mockito Tutorial: Learn mocking with 25 Junit Examples - Step 05: Stubbing variations with Mockito - Argument Matchers &

Mockito Tutorial: Learn mocking with 25 Junit Examples - Step 05: Stubbing variations with Mockito - Argument Matchers &

Assessment

Interactive Video

Information Technology (IT), Architecture

University

Hard

Created by

Quizizz Content

FREE Resource

The video tutorial covers various Mockito examples, focusing on mocking the List interface in Java. It demonstrates stubbing methods to return specific values, handling multiple return values, using argument matchers, and throwing exceptions. The tutorial also compares Mockito's nice mock behavior with Easymock, highlighting Mockito's advantages. The video provides a step-by-step guide to creating JUnit tests for these scenarios, ensuring a comprehensive understanding of Mockito's capabilities.

Read more

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is one of the key features of Mockito that allows returning multiple values from a single method call?

Single return stubbing

Multiple return stubbing

Static method invocation

Dynamic method creation

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method is used in Mockito to specify the behavior of a mock when a method is called?

thenReturn

when

verify

mock

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In the context of mocking, what does the 'when' method do?

It throws an exception

It sets up the expected behavior of a method

It verifies the number of method calls

It initializes a mock object

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the significance of the '@Test' annotation in JUnit?

It throws an exception

It verifies the test results

It initializes a mock object

It marks a method as a test case

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the 'anyInt' argument matcher in Mockito?

To match any object type

To match any string value passed to a method

To match any integer value passed to a method

To match any boolean value

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How does Mockito handle a method call for which no behavior is stubbed?

It throws an exception

It returns a default value

It logs an error

It skips the method call

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the default behavior of Mockito when a method is not explicitly stubbed?

It throws a runtime exception

It returns a random value

It logs a warning

It returns null or default values

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?