Master Java Unit Testing with Spring Boot & Mockito (Udemy.com)
Learn to write awesome Java JUnit unit tests with Spring Boot, Mockito, JsonAssert, Hamcrest & JsonPath in 40 easy steps
Created by: in28Minutes Official
Last updated November 2024
What you will learn
- You will learn to WRITE GREAT UNIT and INTEGRATION Tests using Spring Boot Starter Test from SCRATCH
- You will learn to Write INDEPENDENT Unit Tests for RESTFUL web services talking with MULTIPLE LAYERS - web, business and data
- You will learn to Use the most important Unit Testing ANNOTATIONS - @SpringBootTest, @WebMvcTest, @DataJpaTest and @MockBean
- Use ALL the FRAMEWORKS in Spring Boot Starter Test - JUnit, Spring Test, Spring Boot Test, AssertJ, Hamcrest, Mockito, JSONassert and JsonPath.
- You will learn to write unit tests using MOCKS and SPYS created with MOCKITO
- You will learn to Write Integration Tests using an IN MEMORY DATABASE - H2
How it compares
Against the other 281 rated Udemy courses in Software Testing on CourseDuck:
- Rating4.4 out of 5higher than 35% of them
- Reviews8,309#26 of 282 by number of reviews
- Length4 hoursshorter than 68% of them
- Last updatedNovember 2024earlier than 60% of them
Course Description
Great Programmers write Great Unit Tests. Want to Write Great Unit Tests for Spring Boot REST API ?
Spring Boot Test? Yes. Layered Unit Tests? Yes. Of Course. Spring Boot Integration Tests? Yes.
Mockito? Yes. JsonAssert, Hamcrest Matchers, and JsonPath? Yes. Included.
WHAT OUR LEARNERS ARE SAYING:
5 STARS - This a very comprehensive introduction to spring boot test, which brings Mockito, Junit, JsonAssert, Spring Data JPA, REST, design pattern, and many more. Very valuable course. Thanks.
5 STARS - Excellent and to the point course on Unit testing with good references.
5 STARS - This is an excellent course for both beginners as well as experienced Java developers who which to hone their skill. The instructor was very knowledgeable and knew how to keep the course engaging while providing lots of tips. Highly recommended...
5 STARS - Great Course to learn Junit Testing. Great content and great examples to explain each scenarios of writing test cases. If you want to write java test cases then definitely go through this course.
5 STARS - This course is a great introduction to unit and integration testing using Spring Boot, Mockito, and a number of other libraries that can help to write effective tests. It is easy to follow along with and has plenty of references where to look for more information.
5 STARS - Needed it for new client project. Excellent source of concise tutorials for JUnit of microservices.
5 STARS - I was drowning in unit test concepts and this course cleared up what read about them. And have a simple but clear explanation of when is good and how to create unit test in your app.
COURSE OVERVIEW
Spring Boot is the most popular framework to develop RESTful Services. It has Awesome Unit Testing capabilities through Spring Boot Starter Test. Mockito is the most popular mocking framework. JUnit is most popular Java Unit Testing Framework.
In this course, you will learn to Write Great Unit Tests for Simple RESTful Services with Spring Boot Starter Test, Mockito and JUnit. You will learn to write independent unit tests for RESTful web services talking with multiple layers - web, business and data. You will learn how to write integration tests using an in memory database H2.
You will build the unit tests step by step - in 40 easy steps. This course would be a perfect first step as an introduction to unit testing with Spring Boot and Mockito Frameworks.
You will be using Spring (Dependency Management), Spring Boot, Maven (dependencies management), Eclipse (IDE), in memory database H2 and Tomcat Embedded Web Server. We will help you set up each one of these.
You will use all the frameworks that are part of Spring Boot Starter Test - JUnit, Spring Test, Spring Boot Test, AssertJ, Hamcrest, Mockito, JSONassert and JsonPath.
You will learn to use the most important Unit Testing Annotations - @RunWith(SpringRunner.class), @SpringBootTest, @WebMvcTest, @DataJpaTest and @MockBean.
COURSE HIGHLIGHTS
Section 1 - Learning Mocking with Mockito
Step 01: Setting up the project using Spring Initializr
Step 02: Writing Unit Test for a Simple Business Service
Step 03: Setting up a Business Service to call a Data Service
Step 04: Writing your first unit test with Stub
Exercise - Update Tests 2 & 3
Step 05: Exercise Solution - Updating Tests 2 & 3 to use Stubs - Problem with Stubs.
Step 06: Writing Unit Tests with Mocking using Mockito
Exercise - Updating Tests 2 & 3 to use Mockito
Step 07: Exercise Solution - Updating Tests 2 & 3 to use Mockito
Step 08: More Refactoring - @Mock, @InjectMocks and @RunWith(MockitoJUnitRunner.class)
Step 09: Mockito Tips - Multiple Return Values and Specific Argument Matchers
Step 10: Mockito Tips - Argument Matchers
Step 11: Mockito Tips - Verify method calls
Step 12: Mockito Tips - Argument Capture
Step 13: Mockito Tips - Argument Capture on Multiple Calls
Step 14: Introduction to Spy
Step 15: Mockito FAQ
Section 2 - Unit Testing RESTful Services with Spring Boot and Mockito
Step 01: Creating a Hello World Controller
Step 02: Using Mock Mvc to test Hello World Controller
Step 03: Using Response Matchers to check status and content
Step 04: Creating a Basic REST Service in Item Controller
Step 05: Unit Testing Item Controller and Basic JSON Assertions
Step 06: Digging deeper into JSON Assert
Step 07: Writing a REST Service talking to Business Layer
Step 08: Writing Unit Test for REST Service mocking Business Layer
Step 09: Prepare Data Layers with JPA, Hibernate and H2
Step 10: Create Item Entity and Populate data with data.sql
Step 11: Create a RESTful Service talking to the database
Step 12: Writing Unit Test for Web Layer - Controller - Using Mock MVC
Step 13: Exercise & Solution - Writing Unit Test for Business Layer - Mocking
Step 14: Writing Unit Test for Data Layer - Data JPA Test
Step 15: Writing an Integration Test using @SpringBootTest
Step 16: Tip : Using @MockBean to mock out dependencies you do not want to talk to!
Step 17: Tip : Creating Different Test Configuration
Step 18: Writing Unit Tests for Other Request Methods
Step 19: Refactor SomeBusinessImpl to use Functional Programming
Step 20: Better Assertions with Hamcrest - HamcrestMatcherTest
Step 21: Better Assertions with AssertJ - AssertJTest
Step 22: Better Assertions with JSONPath - JSONPathTest
Step 23: Easier Static Imports
Step 24: Tip : Measuring Test Coverage with Eclipse
Step 25: Tip : Keep an eye on performance of unit tests!
Step 26: Good Unit Tests
Instructor Details
- 4.4 Rating
8,309 Reviews
in28Minutes Official
Ranga Karanam, the founder of in28minutes, has 2 decades of experience with technology - architecture, design, and programming. We are helping learners take their first steps into modern cloud native technology and gain expertise on AWS, Azure, Google Cloud, Docker, Kubernetes amongst others.
Our happiest moments are when learners tag us on LinkedIn or reach out to us with their stories of getting their first job, getting a promotion, or a big raise.
----------------------
Ranga is multi-cloud certified - Google Cloud Certified Professional Cloud Architect, Google Cloud Certified Associate Cloud Engineer, AWS Certified Cloud Practitioner, Azure Fundamentals Certified AZ-900, DP-900 and AI-900.
Our courses are focused on Cloud Certifications (AWS, Azure, Google Cloud Platform - GCP), DevOps, Full Stack ( React, Angular ), Serverless, Programming, and Microservice Development with Java and Spring Boot.
Our Top Courses include:
1) Master Microservices with Spring Boot and Spring Cloud
2) Java Programming for Complete Beginners
3) Google Cloud Certification - Associate Cloud Engineer - 2021
4) DevOps For Beginners - Docker, Kubernetes, and Azure DevOps
5) Spring Framework Master Class - Java Spring the Modern Way
More courses by in28Minutes Official
Master Microservices with Spring Boot and Spring Cloud (2026)
4.5 (60,531 Reviews)
Provider: Udemy
Time: 22.8h
$159.99
Java Programming for Complete Beginners (2026)
4.6 (54,293 Reviews)
Provider: Udemy
Time: 60.6h
$139.99
AZ-900 Microsoft Azure Fundamentals in a Weekend (2026)
4.6 (49,111 Reviews)
Provider: Udemy
Time: 11.6h
$129.99
GCP Associate Cloud Engineer - Google Cloud Certification (2026)
4.6 (38,020 Reviews)
Provider: Udemy
Time: 25.6h
$124.99
Spring Framework Master Class - Java Spring the Modern Way (2026)
4.5 (29,267 Reviews)
Provider: Udemy
Time: 14.7h
$139.99
Learn Java Unit Testing with Junit & Mockito in 30 Steps (2024)
4.6 (27,703 Reviews)
Provider: Udemy
Time: 5h
$16.99
More Software Testing courses
ZeroToHero TestNG Framework - From Basics to Advanced (2026)
4.9 (828 Reviews)
Provider: Udemy
Time: 6.2h
$59.99
Selenium WebDriver with Java- Basics to Advanced + Framework (2026)
4.9 (620 Reviews)
Provider: Udemy
Time: 35.5h
$84.99
Karate DSL: API Automation and Performance from Zero to Hero (2026)
4.8 (4,652 Reviews)
Provider: Udemy
Time: 7.2h
$10.99
API Testing in detail using Postman - Test Automation (2026)
4.8 (423 Reviews)
Provider: Udemy
Time: 7.8h
$10.99
Quick Introduction to Postman and API Testing for Beginners (2025)
4.7 (23,113 Reviews)
Provider: Udemy
Time: 3.2h
$13.99
Software Testing Masterclass (2026) - From Novice to Expert
4.7 (12,622 Reviews)
Provider: Udemy
Time: 9.9h
$149.99
Reviews
By Benedict Grimer on 5/7/2026
I had a bit of a problem with SpringBoot 4. I had to set the pom.xml files back to Spring 3.25 or something. Without this there would have been an addtional step with Security Configuration - without which the /h2-console was not enabled. It took me about 2 hours to figure this out with the help of Google Gemini. Saying that, it was a great course and I have given it 5 stars. This feedback is more to help others in the future and maybe put an additional insert in the course indicating this pitfall.
By Daniel Palestina Reyes on 1/5/2024
this course has really helped me to understand not only concepts but also how to apply this concepts to practical exercises, those that really apply to my everyday work. I'd only like to see more clearly that those tools like JsonAssert, Hamcrest & JsonPath are extensions or tools that enrich and are not part of the JUnit environment and helps you achieve more. Thank you
By Rafaell Estevam on 5/6/2023
Incredible! Totally worth the purchase. I used to get confused looking up Java unit testing on the internet, because nobody seemed to be able to explain things right. I finally understood the annotations, their purpose, the correct ways to write the test, the patterns and when to use them. Thanks! Hugs from Brazil.
By Michael Berger on 8/28/2022
The course is not bad but not too good either. Giving 4 stars is a bit generous I think. Although the course does have structure, it is hard to see it, because instead of some kind of real-world exercise to rung along with the course, it is full of small general examples which explain the topic on a very basic level. In the middle of nowhere, the lecturer comes to some old lecturer and fixes the coding to a functional style. This all looks very patchy, hard to follow and remember the material, not enough practice. The level is very basic, introductional, and very different from real-world tests. This course is ok for students, but not good enough for a professional, who looks to level up skills. Wanted to give 3.5, but ended up giving 4 because the lecturer is a nice guy I think :)
By Anonymized User on 8/17/2022
I wanted to know how to use Mockito framework so I preferred this course. I noticed two things in this course those will distract the way of learning. 1. Video 23 Step1: Creating a HelloWorldController - Mention here if they want to create web application they need to add "starter web" dependency in pom.xml file because if they are new they can't figure it out the issue, it will lead to lack of interest. 2. Video 47 Step20: Better Assertions With Hamcrest - HamcrestMacherTest - Mention here if they want to use Hamcrest framework they need to add "hamcrest-library" dependency in pom.xml file because I faced issue here. I came across these two issues, I believe you will definitely consider my feedback. Thanks for the good teaching.
By Marlon Braga on 7/10/2022
Very disappointed. I took other courses by this instructor and although I still enjoy his teaching style I don't agree when instructors on Udemy claim that their courses are "updated", while the only thing they really did was to add documents with extra information on what the student needs to change to run the examples. This course is outdated and sprinkling "JUnit 5 Alert" through the course is an awful experience to those starting their programming career. Instructors and content creators should hold themselves in a higher standards and ACTUALLY remake content when there is framework changes. I could not make my database work, spent 4 days trying to make it work until I decided to use MySQL. Moreover, my tests at one point weren't no longer running, even though I followed all the instructions on the documents shared by the instructor. I've given 5 stars to this instructor before, but not this time. Disappointed!
By QA Learning on 7/22/2021
Way way better than his mockito-powermock's course which i consider it's a mess but in this one you actually learn and understand how to create tests for each layer and doing so in an splendid way which i totally confirm after reading a lots of posts and talking with developers.
By Rob Kremers on 8/28/2019
I have received a very good overview of the combination of Mockito icm with unit tests. Also I have had a chance to get acquainted again with Spring Boot again (after a year). I took the chance to experiment a lot. I did not just do the tasks as shown by the author, but also tried a lot myself. E.g. I used JUnit 5 instead of 4 (took the JUnit 5 course before this one) which necessitated to adapt the code here and there. Thanks for the clear explanation.
By Bruno Filgueiras on 1/6/2019
The video classes have been extremely helpful and I am already practicing the concepts learned here in a real project I am working on, I had almost no knowledge in the subject and now I am much more confident after I finished the course. For sure all the hard work will produce good results in the future, thanks to your help Ranga. Can't wait to engage in another course ministered by you (Microservices will be the next). All the best.
By Shovan Biswas on 11/26/2018
Excellent. Mockito on Springboot framework has been pretty well explained so far. I would recommend this to my friends. Based on the lessons, I wrote my own JUnitTest, for a REST controller that returns a ModelAndView object going to a Thymeleaf view (html page). However, it would be more helpful if the instructor created chapter on ModelAndView going to a html or jsp page. I like to see a case with input parameters in: "when(service.method(input parameters).thenReturn(returnValue)" Thanks.
Quality Score
No CourseDuck member has rated this course yet. Taken it? Give each part a thumbs up or down.
Overall Score : 88 / 100












