Testing Spring Boot App with JUnit, Mockito & Testcontainers

Write Unit tests and Integration tests for Spring Boot App and Spring WebFlux App using JUnit, Mockito & Testcontainers

4.51 (1260 reviews)
Udemy
platform
English
language
Development Tools
category
9,384
students
11 hours
content
Dec 2023
last update
$94.99
regular price

What you will learn

Learn to write industry-standard Unit and Integration tests in BDD (Behaviour Driven Development) style using Spring Boot Starter Test dependency from scratch

Learn how to use BDD (Behaviour Driven Development) format that is given/when/then to write Unit tests.

Learn to Unit test Spring boot application Repository layer

Learn to Unit test Spring boot application Service layer

Learn to Unit test Spring boot application Controller layer - Unit test REST API's

Learn how to do Integration testing for the Spring boot application

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 Stubs created with Mockito

Learn how to use Mockito annotations to create mock objects.

Learn to write Integration Tests using a MySQL database

You will learn to write independent Integration tests for RESTFUL web services talking with MULTIPLE LAYERS - controller, service, and repository layers.

Learn to write Integration Tests using a Testcontainers

Learn Building Reactive CRUD REST APIs using Spring WebFlux and MongoDB

Learn Unit Testing Reactive CRUD REST APIs using JUnit and Mockito

Learn Integration Testing Reactive CRUD REST APIs using WebTestClient

Description

In this course, you will learn how to write Unit tests and Integration tests in BDD style for Spring Boot applications as well as Spring WebFlux applications using JUnit 5, Mockito, AssertJ, Hamcrest, JsonPath, and Testcontainers frameworks.


Important note: This course updated to use Spring Boot 3.


Type the code along with me in the videos. If you follow along with me then this will enhance your learning experience.


The source code and PDF files (class notes) are available for download.


Spring Boot Overview

Spring Boot is an opinionated framework that helps developers build Spring-based applications quickly and easily.

The main goal of Spring Boot is to quickly create Spring-based applications without requiring developers to write the same boilerplate configuration again and again.

Spring Boot is a very popular framework to develop REST web services and microservices.


Spring WebFlux Overview

Spring 5 includes Spring WebFlux, which provides reactive programming support for web applications.

Spring WebFlux internally uses Project Reactor and its publisher implementations, Flux and Mono.

The new framework supports two programming models:

  • Annotation-based reactive components

  • Functional routing and handling

In this course, we will focus on building reactive REST APIs using annotation-based reactive components.


What you'll learn?

  • Learn to write industry-standard Unit and Integration tests in BDD (Behaviour Driven Development) style using Spring Boot Starter Test dependency from scratch

  • Learn how to use BDD (Behaviour Driven Development) format that is given/when/then to write Unit tests.

  • Learn to Unit test the Spring boot application Repository layer

  • Learn to Unit test the Spring boot application Service layer

  • Learn to Unit test the Spring boot application Controller layer

  • Learn how to do Integration testing for the Spring boot application.

  • Learn how to do Integration testing using Testcontainers // very important

  • 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 Stubs created with Mockito

  • Learn how to use Mockito annotations to create mock objects.

  • Learn to Write Integration Tests using a MySQL database.

  • You will learn to Write INDEPENDENT Integration tests for RESTFUL web services by talking with MULTIPLE LAYERS - controller, service, and repository layers.

  • Learn Building Reactive CRUD REST APIs using Spring WebFlux

  • Learn Unit Testing Reactive CRUD REST APIs

  • Learn Integration Testing Reactive CRUD REST APIs

Tools and Technologies used in this course:

Technologies and Libraries:

  1. Java 11+

  2. Spring Boot

  3. Spring MVC

  4. Spring Data JPA ( Hibernate)

  5. JUnit 5 Framework

  6. Mockito 4 (Latest)

  7. Hamcrest framework

  8. AssertJ Library

  9. JsonPath Library

  10. Spring WebFlux

  11. MongoDB

IDE:

  • IntelliJ IDEA

Database:

  • H2 In-memory database ( for repository layer testing)

  • MySQL database ( for Integration testing)

  • MongoDB database (for Integration testing)


Amazing reviews from Students on this course:

"Ramesh is a great teacher, he provides very clean explanations on complex concepts."


"Ramesh explains things very well! His instructions are easy to follow and understand. The course is very beneficial"


"✔ Well structured course covering all layers of testing

✔ Implement each method with the "right to the point" explanation

✔ Nice introduction to TestContainers

✔ Easy to code along

✔ Fast answers from the instructor

Looking for more deep dives courses such as Maven, Gradle, DevOps tools used in production"


"Awesome course.

All the basics needed to test a spring application are discussed, and more.

Exactly what i needed and coudn't find anywhere.

Ramesh is a great instructor.

Thank you sir !"


"A very good course explained with excellent examples.

Lot to learn from this course, covered every layer of a typical Spring Boot application."


"I really appreciate the trainer Ramesh to providing is this amazing course,

the content of this course and explanation is great."


"Wonderful Sir, Loved the way u explain things. And I am very lucky that I found this course at right time."


"I am personally very impressed with this course, if you dont have any prior experience of unit testing I am pretty sure that after taking this course you will feel more confident and I would be happy if the lecturer could also release some training tutorials about Microservices and TDD approach. thanks and wish you all the successes."


"Even though as a experience guy, this course was very useful.."


"The course is great and covers all I need to create my tests.

I truly recommend it ."


"Great course. This is the second course I am taking from Ramesh. Interesting so far."


"Awesome course and highly recommend it."


"This course is a good match for me. Especially so because it's new and up to date."


"great teacher and great course"


"Yes this is a good match for me and I am glad I enrolled for this. I personally prefer teaching of ramesh.fadatare. I started to watch his videos from YouTube and also gone through his comments to few problems in stack overflow. I thought it would be good if I can go through all his videos in one go."


"this is what they ask you to do on a real job... please do more courses ramesh.. amazing as always"

Content

Introduction

Course overview and roadmap
What is Unit testing and Integration testing?
Best practices for Unit Testing in Java
Download all the important Lecture notes in PDF

Spring Boot Project Setup

Create and setup Spring Boot project in Intellij Idea
Understanding Spring boot starter test dependency
Create JPA entity
Create Spring Data JPA repository

Spring Boot - Unit Testing Repository Layer

Repository layer Unit testing overview
Spring Boot @DataJpaTest annotation
Unit test for save employee operation
Unit test for get all employees operation
Unit test for get employee by id operation
Unit test for get employee by email operation (Spring Data JPA query method)
Unit test for update employee operation
Unit test for delete employee operation
Unit test Spring Data JPA custom query method using JPQL with index parameters
Unit test Spring Data JPA custom query method using JPQL with named parameters
Unit test Spring Data JPA custom native query with index parameters
Unit test Spring Data JPA custom Native query with Named parameters
Refactoring JUnit tests to use @BeforeEach annotation
Download source code of this section

Spring Boot - Unit Testing Service Layer

Service Layer unit testing overview
Create EmployeeService with saveEmployee method
Quick Recap of Mockito basics (before writing JUnit tests to use Mock objects)
Unit test for EmployeeService saveEmployee method
Using @Mock and @InjectMocks annotations to mock the object
Unit test for saveEmployee method which throws Exception
Unit test for EmployeeService getAllEmployees method - Positive Scenario
Unit test for EmployeeService getAllEmployees method - Negative Scenario
Unit test for EmployeeService getEmployeeById method
Unit test for EmployeeService updateEmployee method
Unit test for EmployeeService deleteEmployee method
Download source code of this section

Spring Boot - Unit Test Controller Layer (Unit Test REST APIs)

Controller Layer unit testing overview
Overview of @WebMvcTest annotation
@WebMvcTest VS @SpringBootTest
Build createEmployee REST API
Unit test createEmployee REST API
Build GetAllEmployees REST API
Unit test GetAllEmployees REST API
Refactoring JUnit test to use static imports
Build getEmployeeById REST API
Unit test getEmployeeById REST API - Positive Scenario
Unit test getEmployeeById REST API - Negative Scenario
Build updateEmployee REST API
Unit test updateEmployee REST API - Positive Scenario
Unit test updateEmployee REST API - Negative Scenario
Build deleteEmployee REST API
Unit test deleteEmployee REST API
Download source code of this section

Spring Boot - Integration Testing

Integration testing overview
@SpringBootTest annotation overview
Configure MySQL database for integration testing
Create a base for Integration testing
Integration test for create employee REST API
Integration test for get all employees REST API
Integration test for get employee by id REST API - Positive & Negative Scenarios
Integration test for update employee REST API - Positive & Negative Scenarios
Integration test for delete employee REST API
Download source code of this section

Quiz - Test Yourself

Quiz to test knowledge about this course

Screenshots

Testing Spring Boot App with JUnit, Mockito & Testcontainers - Screenshot_01Testing Spring Boot App with JUnit, Mockito & Testcontainers - Screenshot_02Testing Spring Boot App with JUnit, Mockito & Testcontainers - Screenshot_03Testing Spring Boot App with JUnit, Mockito & Testcontainers - Screenshot_04

Reviews

RAGHAVENDRA
August 29, 2023
This course is good for anyone who wants to learn/work on Spring Boot based projects. Despite having many years of experience writing test cases, learnt a lot from this course. Also, course is easy to follow. Highly recommend.
Vijay
July 26, 2023
This course has best delivery in and it will make easy working on Testing Spring Boot App with JUnit, Mockito & Testcontainers.
Mahmudul
May 19, 2023
To be honest this course gives all the ideas which you need for writing unit test cases as a beginner. The instructor tries to give proper explanations whatever he teaches in this course. However, if you are an advanced spring boot developer this course might not help you that much. I would like to expect more advanced contents from him in future. I liked the way he teaches though. Last but not the least the instructor avoided to answer my question when I asked him some advanced question in the Q&A section. As an instructor he should have advanced knowledge as well.
Diana
May 3, 2023
It's a great course to learn about testing applications is all the layers. Ramesh is a great instructor
Ravinder
April 23, 2023
While I have taken courses from Ramesh before, I found myself disappointed with the delivery and explanation of this particular course. 1. He takes too much time explaining the same concept repeatedly. 2. The current project felt like a bare minimum, and I think his spring blog API project would have been a better fit.
Andres
April 3, 2023
I recommend to buy this course. One can follow along and learn concepts, despite the instructor's thick indian accent which should not be a problem unless your english is not so good (Ramesh has poor diction and transcription is not accurate either). Ramesh has reply my answers promptly every time, which is always a good thing, and the course is far from being left out. Why four stars only? Well, it lacks something fundamental when it comes to testing: coverage review. Besides in the last project no negative scenarios were covered. He replied these topics are being considered for future updates...I give him the benefit of the doubt, since new videos pop up frequently.
Amit
March 11, 2023
Nice course worth of money and the instructor has strong hold and in-depth knowledge on the subjects Following coding standards and practices
Jose
March 5, 2023
No examples with argument capture, No examples mocking static private methods Too much time testing a repository class which nobody needs to test is all already tested by spring.
Xuan
February 15, 2023
I found this course super helpful! It is very concise and gets straight into the point. The important annotations and mechanism behind them were explained very well. Thank you for the great course!
Romulo
February 8, 2023
O curso foi muito bom! Competente em apresentar o conteúdo e cumpre com a grade curricular que ele propõe. O professor pode ser repetitivo eventualmente, e nas aulas de Integration Testing, ele cometeu um pequeno erro ao achar que @Testecontainer já era o suficiente para rodar no banco de dados do docker, mas na verdade ele não percebeu que estava rodando no banco local, antes de add a @DynamicPropertySource . Apenas por esses 2 pontos, não ganhou 5 estrelas. Hi, Artem, I bought the notebook last Friday and it is estimated to be delivered on February 15th. As soon as Dell makes the receipt available, I'll send it here
olumide
February 4, 2023
Straight to the point. Technical and Practical concept were explained in detail. You can never go wrong with this course.
Rohit
January 31, 2023
Excellent course. I specially like container testing section. Any one who wants to learn about unit testing for overall application, must go through the course. Thank you very much Ramesh for this course.
Salitha
November 27, 2022
This was the best course I found so far to learn testing with Spring Boot! Hats off to the creator. Highly recommend this course to anyone who needs a complete knowledge on performing unit and integration testing in correct way.
Himabindu
November 14, 2022
Good explanation. After going through this course understood how to write testcases using Junit which help me a lot.
Paul
October 23, 2022
This course handles a lot of topics about JUnit testing and explains it well. But it contains a lot of repetition. The same explanation is given over and over and it takes too much time for code that is almost the same as explained before.Getting rid of these would reduce the amount of time to follow the course considerably. The author sometimes sounds quite unintelligible. The transcript sometimes completely loses track of what is said (‘So by default, my cycle container class will take my sexual image with some wording from the Docker’ and ‘OK, so let's go around the gender discourse again.’ is not quiet what is meant :)) Section 7 step 68: here the instructor is cheating: the code still uses his local MySQL database instead of the database in the container. In the next step this will be solved. Section 8 the assignment is exactly the same as the code already created during the code (only the class Employee is replaced by Student, but even its properties are the same). This is a useless exercise. An exercise should test if you understand what is taught, not if you can copy and paste or repeat exactly what is already being done.

Coupons

DateDiscountStatus
12/30/202163% OFF
expired

Charts

Price

Testing Spring Boot App with JUnit, Mockito & Testcontainers - Price chart

Rating

Testing Spring Boot App with JUnit, Mockito & Testcontainers - Ratings chart

Enrollment distribution

Testing Spring Boot App with JUnit, Mockito & Testcontainers - Distribution chart
4457400
udemy ID
12/23/2021
course created date
12/30/2021
course indexed date
Bot
course submited by