Mockito
Argument Captors
Autoplay
Previous
About
Argument Captor
In this lesson, we'll explain how to verify the parameters which are passed to mock objects.
We'll explain how Argument Captors work and how you can use them to ensure that not only is your mock method being called, but that it is being called with the correct parameter.
Summary of Content
- Showing an example where we need to not only verify that a mock method was called, but we also need interrogate the parameter passed to a mock method
- Explanation of what an Argument Captor is
- How to create an Argument Captor, using the
ArgumentCaptor.forClass()
method - How to retrieve the object that was captured by the argument captor, using the
getValue()
method - Showing a test passing which successfully verifies the parameter passed to a mock object.
Other Relevant Links:
Instructor
Links
Comments
Lessons in Mockito
Introduction and Integration
02:19
Writing Your First Unit Test with Mockito

Pro
03:10
A Guide to Writing Testable Code

Pro
02:51
What Makes a Good Unit Test

04:17
Test Doubles

Pro
04:34
Configuring Stubs

Pro
04:21
Stubs - Default Return Values

Pro
03:45
String Matchers - anyString()

Pro
02:45
Stubs - Matching on Any Parameters of a Given Type

Pro
04:36
Introduction to Mocks

02:03
Verifying a Method Was Never Called

Pro
01:46
Verifying a Method Was Called An Exact Number of Times

Pro
01:36
Verifying That a Method was Called a Minimum or Maximum Number of Times

Pro
01:17
Mocking and Stubbing Final Classes

02:58
Argument Captors

Pro
04:04

Something went wrong
Lesson added to playlist
Create new playlist
Name can't be empty