Skip to main content
CF

Hands-On Mocking With Mockito

2h 8m 58s
English
Paid

Hands-On Mocking With Mockito is a 27-lesson 2 hours 8 minutes self-paced course by Philip Riecks. This course teaches you how to use Mockito in real tests.

Course facts

Lessons
27
Duration
2 hours 8 minutes
Level
All levels
Language
English
Updated
Instructor
Philip Riecks
Price
Premium

This course teaches you how to use Mockito in real tests. You learn how to make mock objects, set their behavior, and check how parts of your code talk to each other. The focus is on clear steps and hands-on work.

What You Learn

You work with mocks in small, focused examples. You see how mocks replace real objects during a test. You also learn how mocks help you test hard‑to‑reach code paths.

Create Mocks

You create mock objects with simple code. You use them to test classes that depend on outside systems. This helps you keep tests fast and easy to read.

Control Mock Behavior

You set return values for mock methods. This is called stubbing. You use stubbing to guide the path of your test and cover edge cases.

Check Method Calls

You verify that your code calls the right methods with the right data. You also check how many times a call happens. This gives you clear proof that your code works as planned.

What the Course Does Not Cover

The course does not teach the basics of unit testing in Java. You should know how tests run and how to write simple test cases. The goal here is to help you use the main features of Mockito with confidence.

Additional

https://github.com/rieckpil/hands-on-mocking-with-mockito

Who teaches Hands-On Mocking With Mockito? Philip Riecks

Philip Riecks thumbnail

Filip helps developers release software products more frequently and with greater confidence through practical technical content and applied consulting. He is an indie hacker, often travels around Southeast Asia, plays squash, is learning padel, and enjoys running in nature.

What lessons are included in Hands-On Mocking With Mockito?

This is a demo lesson (10:00 remaining)

You can watch up to 10 minutes for free. Subscribe to unlock all 27 lessons in this course and access 10,000+ hours of premium content across all courses.

View Pricing
0:00
/
#1: Why Do We Need Mocking
All Course Lessons (27)
#Lesson TitleDurationAccess
1
Why Do We Need Mocking Demo
11:15
2
Important Note About The Terminology
01:20
3
Introduction To The Java Project
02:12
4
The Class Under Test
02:17
5
Understanding How Mockito Creates Mocks
06:59
6
Using @Mock To Create Mocks
04:00
7
Simplify The Setup Using The MockitoExtension
03:27
8
Default Behavior Of Mocks
03:38
9
Stubbing The First Method Call
07:41
10
Exploring ArgumentMatchers
05:09
11
Instructing The Mock To Throw An Exception
03:13
12
Instructing The Mock To Call The Real Method
02:27
13
Using .thenAnswer() Instead of .thenReturn()
06:15
14
Full Mockito Setup For Our Class Under Test
03:19
15
Second Test For Our Class Under Test
02:20
16
How To Stub Void Methods?
05:48
17
Using .doReturn() For Non-Void Methods
02:52
18
Exploring Mockito's BDD Syntax
04:25
19
Introduction To Verifications With Mockito
08:49
20
Verifying in Order
03:02
21
Capturing Method Arguments With ArgumentCaptors
07:30
22
@Mock vs. @Spy
06:17
23
Deep Stubbing
04:27
24
How To Mock Static Methods?
07:51
25
How To Mock Constructors?
03:56
26
@Mock vs. @MockBean
04:40
27
The Four Golden Rules Of Mockito
03:49
Unlock unlimited learning

Get instant access to all 26 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.

Learn more about subscription

What courses are similar to Hands-On Mocking With Mockito?

More courses by Philip Riecks

Frequently asked questions

What are the prerequisites for this course?
The course assumes you have a basic understanding of unit testing in Java. You should already know how tests run and how to write simple test cases. The course focuses on using Mockito, so familiarity with Java and basic testing concepts is necessary to get the most out of the lessons.
What projects or exercises will I work on?
The course includes hands-on exercises where you will create and control mock objects using Mockito. You will work on examples that demonstrate creating mocks, stubbing methods, and verifying method calls. These exercises are designed to give you practical experience in using Mockito for testing Java applications.
Who is the target audience for this course?
This course is intended for Java developers who want to enhance their testing skills by learning how to use Mockito effectively. If you are looking to improve your ability to test hard-to-reach code paths and ensure correct method interactions, this course is designed for you.
How does this course compare to other Mockito courses?
This course focuses on practical, hands-on experience with Mockito. Unlike introductory courses that might cover general unit testing principles, this course dives into specifics such as creating and controlling mock behavior, and verifying method calls. It offers detailed lessons on using Mockito's features, like the MockitoExtension and ArgumentMatchers.
What specific tools or platforms will I learn to use?
The course teaches you how to use Mockito, a popular Java mocking framework. You will learn specific features like @Mock, MockitoExtension, ArgumentMatchers, and BDD syntax. The course also covers advanced topics like mocking static methods, constructors, and using ArgumentCaptors.
What topics are not covered in this course?
The course does not cover the basics of unit testing in Java, such as how tests run or how to write simple test cases. Its focus is solely on using Mockito to create and manage mock objects and verify interactions in Java applications.
How can the skills learned in this course benefit my career?
The skills you acquire in this course will enhance your ability to write robust Java tests, particularly for complex systems with external dependencies. Mastery of Mockito will make you more proficient in ensuring code quality and reliability, which are highly valued in software development roles. These skills are transferable to other testing frameworks and methodologies, broadening your expertise in software testing.