Testing Spring Boot Application with JUnit and Mockito

Unit tests and Integration tests for Spring Boot App using JUnit, Mockito, AssertJ, Hamcrest, JsonPath, & Testcontainers
Testing Spring Boot Application with JUnit and Mockito
File Size :
5.44 GB
Total length :
8h 30m

Category

Instructor

Ramesh Fadatare (Java Guides)

Language

Last update

Last updated 7/2022

Ratings

4.6/5

Testing Spring Boot Application with JUnit and Mockito

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 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

Testing Spring Boot Application with JUnit and Mockito

Requirements

Java programming
Good to know JUnit and Mockito basics
Good to know Spring Boot basics
Basic understanding of using IntelliJ IDEA

Description

In this course, you will learn how to write Unit tests and Integration tests in BDD style for Spring Boot application using JUnit 5, Mockito, AssertJ, Hamcrest, JsonPath, and Testcontainers frameworks.The objective of this course is to teach you how to Unit test different layers of the Spring boot application such as repository, service, and controller layers. You will also learn how to perform Integration testing using MySQL database as well as Testcontainers.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 OverviewSpring 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.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 scratchLearn 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 layerLearn to Unit test Spring boot application Service layerLearn to Unit test Spring boot application Controller layerLearn how to do Integration testing for the Spring boot application.Learn how to do Integration testing using Testcontainers // very importantYou will learn to use the most important Unit Testing ANNOTATIONS – @SpringBootTest, @WebMvcTest, @DataJpaTest, and @MockBeanUse 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 MockitoLearn 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.Tools and Technologies used in this course:Technologies and Libraries:Java 11+Spring BootSpring MVCSpring Data JPA ( Hibernate)JUnit 5 FrameworkMockito 4 (Latest)Hamcrest frameworkAssertJ LibraryJsonPath LibraryIDE:Intellij IDEADatabase:H2 In-memory database ( for repository layer testing)MySQL 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 instructorLooking 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”

Overview

Section 1: Introduction

Lecture 1 Course overview and roadmap

Lecture 2 Best Way to Take This Course and How to Get Help

Lecture 3 What is Unit testing and Integration testing?

Lecture 4 Best practices for Unit testing in Java

Lecture 5 Download Source Code

Lecture 6 Download All the Important Lecture Notes in PDF

Section 2: Spring Boot Project Setup

Lecture 7 Create and setup Spring Boot project in IntelliJ IDEA

Lecture 8 Understanding Spring boot starter test dependency

Lecture 9 Create JPA entity

Lecture 10 Create Spring Data JPA repository

Section 3: Spring Boot – Unit Testing Repository Layer

Lecture 11 Repository layer Unit testing overview

Lecture 12 Spring Boot @DataJpaTest annotation

Lecture 13 Unit test for save employee operation

Lecture 14 Unit test for get all employees operation

Lecture 15 Unit test for get employee by id operation

Lecture 16 Unit test for get employee by email operation (Spring Data JPA query method)

Lecture 17 Unit test for update employee operation

Lecture 18 Unit test for delete employee operation

Lecture 19 Unit test Spring Data JPA custom query method using JPQL with index parameters

Lecture 20 Unit test Spring Data JPA custom query method using JPQL with named parameters

Lecture 21 Unit test Spring Data JPA custom native query with index parameters

Lecture 22 Unit test Spring Data JPA custom Native query with Named parameters

Lecture 23 Refactoring JUnit tests to use @BeforeEach annotation

Lecture 24 Download source code of this section

Section 4: Spring Boot – Unit Testing Service Layer

Lecture 25 Service Layer unit testing overview

Lecture 26 Create EmployeeService with saveEmployee method

Lecture 27 Quick Recap of Mockito basics (before writing JUnit tests to use Mock objects)

Lecture 28 Unit test for EmployeeService saveEmployee method

Lecture 29 Using @Mock and @InjectMocks annotations to mock the object

Lecture 30 Unit test for saveEmployee method which throws Exception

Lecture 31 Unit test for EmployeeService getAllEmployees method – Positive Scenario

Lecture 32 Unit test for EmployeeService getAllEmployees method – Negative Scenario

Lecture 33 Unit test for EmployeeService getEmployeeById method

Lecture 34 Unit test for EmployeeService updateEmployee method

Lecture 35 Unit test for EmployeeService deleteEmployee method

Lecture 36 Download source code of this section

Section 5: Spring Boot – Unit Test Controller Layer (Unit Test REST APIs)

Lecture 37 Controller Layer unit testing overview

Lecture 38 Overview of @WebMvcTest annotation

Lecture 39 @WebMvcTest VS @SpringBootTest

Lecture 40 Build createEmployee REST API

Lecture 41 Unit test createEmployee REST API

Lecture 42 Build GetAllEmployees REST API

Lecture 43 Unit test GetAllEmployees REST API

Lecture 44 Refactoring JUnit test to use static imports

Lecture 45 Build getEmployeeById REST API

Lecture 46 Unit test getEmployeeById REST API – Positive Scenario

Lecture 47 Unit test getEmployeeById REST API – Negative Scenario

Lecture 48 Build updateEmployee REST API

Lecture 49 Unit test updateEmployee REST API – Positive Scenario

Lecture 50 Unit test updateEmployee REST API – Negative Scenario

Lecture 51 Build deleteEmployee REST API

Lecture 52 Unit test deleteEmployee REST API

Lecture 53 Download source code of this section

Section 6: Spring Boot – Integration Testing using Local MySQL Database

Lecture 54 Integration testing overview

Lecture 55 @SpringBootTest annotation overview

Lecture 56 Configure MySQL database for integration testing

Lecture 57 Create a base for Integration testing

Lecture 58 Integration test for create employee REST API

Lecture 59 Integration test for get all employees REST API

Lecture 60 Integration test for get employee by id REST API – Positive & Negative Scenarios

Lecture 61 Integration test for update employee REST API – Positive & Negative Scenarios

Lecture 62 Integration test for delete employee REST API

Lecture 63 Integration testing EmployeeRepository using MySQL database

Lecture 64 Download source code of this section

Section 7: Spring Boot – Integration Testing using Testcontainers

Lecture 65 What problem does Testcontainers solve

Lecture 66 Testcontainers overview

Lecture 67 Adding Testcontainers

Lecture 68 Integration Testing EmployeeController using Testcontainers

Lecture 69 Using @DynamicPropertySource

Lecture 70 Singleton containers pattern

Lecture 71 Integration Testing EmployeeRepository using Testcontainers

Lecture 72 Download source code of this section

Section 8: Assignments and Solutions

Lecture 73 Assignments for You

Lecture 74 Solution for All the Assignments in One Video

Section 9: Quiz – Test Yourself

Section 10: What’s Next?

Lecture 75 Discounts for My Other Udemy Courses

Lecture 76 Thank You Note and Feedback About This Course

This is course is for beginners as well as professional to teach how to write Unit and Integration tests for Spring boot application.

Course Information:

Udemy | English | 8h 30m | 5.44 GB
Created by: Ramesh Fadatare (Java Guides)

You Can See More Courses in the Developer >> Greetings from CourseDown.com

New Courses

Scroll to Top