Skip to main content
CF

Testing Java with JUnit 5 & Mockito

7h 41m 22s
English
Paid
Updated September 2026

Testing Java with JUnit 5 & Mockito is a 107-lesson 7 hours 41 minutes self-paced course by Udemy. Unit testing in Java gets covered here from zero — no prior testing experience assumed — using JUnit 5 and Mockito, and building steadily into more advanced unit and integration testing along the way.

Course facts

Lessons
107
Duration
7 hours 41 minutes
Level
All levels
Language
English
Updated
2026-09-11
Instructor
Udemy
Price
Premium

Unit testing in Java gets covered here from zero — no prior testing experience assumed — using JUnit 5 and Mockito, and building steadily into more advanced unit and integration testing along the way.

Getting JUnit 5 running everywhere

Rather than assuming one setup, the course walks through configuring JUnit 5 across different environments and project types: IntelliJ IDEA and Eclipse, plain Java projects, and both Maven and Gradle-based builds.

What you'll practice

  • Test-driven development in practice
  • Mockito for mocking objects, method stubbing, and exception stubbing
  • Verifying method interactions with Mockito
  • JUnit assertions, exception testing, and lifecycle methods like @BeforeEach and @AfterAll
  • Controlling test execution order, disabling tests, and repeated tests with @RepeatedTest
  • Parameterized tests using @ValueSource and @MethodSource
  • Writing integration tests for Spring Boot applications

107 lessons in total, moving from setup fundamentals to techniques solid enough for real, production-grade Java test suites.

Who teaches Testing Java with JUnit 5 & Mockito? Udemy

Udemy thumbnail

Udemy is the largest open marketplace for online courses on the internet. Founded in 2010 by Eren Bali, Oktay Caglar, and Gagan Biyani and headquartered in San Francisco, the company went public on the Nasdaq in 2021 under the ticker UDMY. The platform hosts well over two hundred thousand courses across software development, IT and cloud, data science, design, business, marketing, and creative skills, taught by tens of thousands of independent instructors. Roughly seventy million learners use it worldwide, and the corporate arm — Udemy Business — supplies a curated subset of that catalog to enterprise customers.

Because Udemy is a marketplace rather than a single editorial publisher, the catalog is uneven by design. The strongest material lives in the long-form, project-based courses authored by working engineers — full-stack JavaScript, React, Node.js, Python data science, AWS, Docker and Kubernetes, mobile development with Flutter and React Native, and cloud certification preparation. The CourseFlix listing under this source is the slice of that catalog that has been mirrored here for offline-friendly viewing, organized by topic and updated as new releases land. Pricing on Udemy itself swings dramatically with the site's near-permanent sales, which is why the platform is best treated as a deep reference catalog: pick instructors with strong reviews and a track record of updating their material rather than buying on the headline price alone.

What lessons are included in Testing Java with JUnit 5 & Mockito?

This is a demo lesson (10:00 remaining)

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

View Pricing
0:00
/
#1: Introduction
All Course Lessons (107)
#Lesson TitleDurationAccess
1
Introduction Demo
03:25
2
What is a Unit Test?
08:20
3
Why write Unit Test?
02:29
4
The F.I.R.S.T Principle
03:54
5
Testing Code in Isolation
04:33
6
Testing Pyramid
02:20
7
What is JUnit 5?
02:10
8
JUnit and Build Tools
01:03
9
Create new Maven project using IntelliJ IDEA
02:35
10
Add JUnit Dependencies
06:13
11
Maven Surefire Plugin
04:48
12
Creating a new project
02:43
13
Add JUnit Dependencies
05:08
14
Executing Unit Test
02:23
15
Introduction
00:41
16
Basic Java project with IntelliJ
06:33
17
Basic Java project with Eclipse
06:51
18
Creating First Unit Test method
04:56
19
Assertions and Assertion message
01:58
20
Other assertions
02:59
21
Exercise solution overview
03:27
22
Lazy Assert Messages
04:41
23
Naming Unit Tests
04:22
24
@DisplayName annotation
02:34
25
Test Method Code Structure. Arrange, Act, Assert.
04:13
26
JUnit Test Lifecycle
03:37
27
Lifecycle methods demo
06:17
28
Disable Unit Test
02:48
29
Assert an Exception
05:41
30
@ParameterizedTest. Multiple Parameters with @MethodSource.
07:39
31
@ParameterizedTest. Multiple parameters with @CsvSource.
04:23
32
@ParameterizedTest + CSV file
04:45
33
@ParameterizedTest + @ValueSource annotation.
02:46
34
Repeated Tests
07:32
35
Methods Order - Random order
02:36
36
Methods Order - Order by name
01:56
37
Methods Order - Random by order index
03:48
38
Order of Unit Test Classes
08:19
39
Test Instance Lifecycle - Introduction
01:56
40
Changing Test Instance Lifecycle - example 1
04:57
41
Test Instance Lifecycle Demo project overview
05:03
42
Test Instance Lifecycle Demo Project Implementation
09:01
43
Introduction
03:05
44
New project, Class, Method
02:18
45
Creating UserService
03:35
46
Test Create User method
06:42
47
Test User object contains first name
04:15
48
Refactor Test method
02:16
49
Exercise
00:56
50
Solution overview
01:08
51
Check if user id is set
04:03
52
Assert throws Exception
07:53
53
Exercise
01:57
54
Introduction
03:32
55
Adding Mocking to a project
02:26
56
Method under test overview
01:34
57
Implementing UsersRepository
03:15
58
Injecting UsersRepository as Dependency
04:19
59
Creating a Mock object
02:43
60
Stubbing using built-in any() argument matcher
05:02
61
Verify method call
06:35
62
Exception stubbing
05:36
63
Creating EmailNotificationService class
03:48
64
Stub void method with Exception
05:21
65
Do nothing when method is called
01:59
66
Call real method
04:01
67
Introduction
03:54
68
Generating code coverage report
05:12
69
Export Code Coverage Report
02:40
70
Export Test Report using Maven
06:54
71
Jacoco - Maven Plugin for Code Coverage
03:04
72
Jacoco - Export Code Coverage Report in HTML format
03:56
73
Introduction to Unit Testing Spring Boot Application
03:29
74
Introduction to Integration Testing of Web Layer
02:11
75
Introduction to Integration Testing with All Layers
01:48
76
Adding Testing Support to Spring Boot Application
04:55
77
Existing Project overview + Source code
08:11
78
New Test Class. @WebMvcTest & @AutoConfigureMockMvc.
05:24
79
RequestBuilder - Building and Performing HTTP Request
09:14
80
@MockBean - Mocking Service Layer
06:55
81
@MockBean annotation - Trying how it works.
04:25
82
Assert for BAD_REQUEST
07:36
83
Practice exercise solution overview
03:28
84
Introduction
01:00
85
@SpringBootTest annotation
02:03
86
@SpringBootTest WebEnvironment MOCK
01:38
87
Defined Port Number
03:43
88
@TestPropertySource. Loading alternative configuration.
06:35
89
Random Port Number
03:10
90
Test Create User - User Details JSON
02:19
91
TestRestTemplate - Prepare & Perform HTTP Post Request
07:37
92
Trying how it works
02:51
93
Test JWT is Required
06:04
94
Test User Login Works
10:10
95
Order Test Methods
03:49
96
GET /users. Include JWT Token in the Request
11:25
97
Introduction to testing JPA Entities
06:11
98
JPA Entity Overview + Source Code
03:49
99
Test that UserEntity can be persisted
08:09
100
Test UserEntity cannot be persisted with invalid user's first name
04:07
101
Excersize - Test that UserId is Unique
01:48
102
Excersize solution + Source code
03:44
103
Introduction to testing JPA Repositories
05:30
104
Testing Find By Email Query Method
05:35
105
Excersize - Test Find By User Id Query Method
01:15
106
Excersize solution overview + Source code
02:59
107
Test JPQL Query + Source code
05:53
Unlock unlimited learning

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

Learn more about subscription

What courses are similar to Testing Java with JUnit 5 & Mockito?

More courses by Udemy

Frequently asked questions

What prerequisites are needed for this course?
This course is designed for beginners and does not require any prior experience with Unit Testing. A basic understanding of Java programming is recommended to follow along with the examples and exercises provided throughout the course.
What will I be able to build by the end of the course?
By the end of the course, you will be able to create and execute unit tests for various types of Java projects using JUnit 5 and Mockito. You will learn to implement Test-Driven Development (TDD) and write effective integration tests for Spring Boot applications.
Who is the target audience for this course?
The course is targeted towards Java developers who are new to Unit Testing and wish to learn how to efficiently test Java code using JUnit 5 and Mockito. It is also suitable for those looking to understand advanced testing concepts and techniques.
How does this course compare in depth and scope to other testing courses?
This course starts from the basics and progresses to advanced concepts, covering both unit and integration testing comprehensively. Unlike some courses that may focus solely on either JUnit or Mockito, this course integrates both tools, offering a well-rounded understanding of testing in Java.
What specific tools and environments will I learn to use in this course?
You will learn to create unit tests using JUnit 5 in development environments like IntelliJ IDEA and Eclipse. The course also covers integration with build tools such as Maven and Gradle, enhancing your ability to work in various project setups.
What topics are not covered in this course?
The course does not cover testing frameworks outside of JUnit 5 and Mockito. Additionally, it does not delve into testing non-Java applications or advanced topics like performance testing or security testing.
What is the expected time commitment for this course?
The course consists of 107 lessons, but the total runtime is not specified. Students should be prepared to invest time in watching the video lessons and practicing with exercises to fully grasp the testing concepts presented.