Mô tả

Unit Testing is a must-have skill and this video course is about unit testing.

If you take this video course, you will learn how to test your Java code using JUnit 5 and Mockito framework.

This video course is for beginners and you do not need to have any prior Unit testing knowledge to enrol in this course.


JUnit 5 in Different Java projects

There are different Java projects, build tools and development environments. In this course, you will learn how to create a new project and configure JUnit 5 support for different types of projects, using different development environments and build tools.

You will learn how to create a Unit test in: 

  • IntelliJ IDEA and

  • Eclipse Development environments.

You will learn how to create a Unit test in: 

  • Regular Java project,

  • Maven-based Java project,

  • Cradle-based Java project.


Course Overview

This video course teaches Unit and Integration testing with Java from the very beginning and covers many advanced topics as well. By the end of this course, you will learn:

  • JUnit 5 basics, and

  • JUnit 5 advanced topics.

Once you become familiar with JUnit 5, you will learn to use:

  • Test-Driven Development(TDD)

You will then learn to use another very popular Test framework for Java called: 

  • Mockito

You will also learn how to write:

  • Spring Boot integration tests, and

  • Use Testcontainers to integrate real, containerized services(like databases) into your Java application tests, making sure your test scenarios are realistic without complex setup.

By the end of this course you will learn and be able to use all of the following: 


  • Create Unit Tests in IntelliJ,

  • Create Unit Tests in Eclipse,

  • Run unit tests using Gradle,

  • Run Unit Tests using Maven,

  • Use @DisplayName annotation,

  • Use JUnit assertions,

  • Test for Exceptions,

  • Use Lifecycle methods (@BeforeAll, @BeforeEach, @AfterEach, @AfterAll),

  • Run unit tests in any order you need: (Random, Order by Name, Order by Index),

  • Disable Unit test,

  • Repeated Tests with @RepeatedTest annotation,

  • Parameterized tests with @Parameterized annotation

    • @ValueSource,

    • @MethodSource,

    • @CsvSource,

    • @CsvFileSource

  • Change Test Instance lifecycle with @TestInstance (PER_CLASS, PER_METHOD)

  • Learn to Mock objects with Mockito's @Mock annotation,

  • Learn to user Mockito's argument matches,

  • Mockito method stubbing,

  • Mockito Exception stubbing,

  • Verify method call,

  • Call Real Method,

  • Do nothing when a method is called,

  • Write integration tests for Spring Boot applications,

  • and more...


Bạn sẽ học được gì

JUnit 5 - basic & advanced topics

Test Web Layer and Controllers

Test Java code with Mockito - the most popular Mocking Framework.

Test Data layer and JPA Repositories

Write Spring Boot Integration Tests

Test Business and Service layer classes

Master Test Driven Development (TDD)

Perform Integration testing with Testcontainers

And more...

Yêu cầu

  • Basic knowledge of Java

Nội dung khoá học

15 sections

Introduction

10 lectures
Introduction
03:24
Welcome from the instructor
01:16
What is a Unit Test?
08:19
Why write Unit Test?
02:28
The F.I.R.S.T Principle
03:53
Testing Code in Isolation
04:32
Testing Pyramid
02:19
Quiz. Basics of Unit Testing
5 questions
What is JUnit 5?
02:09
JUnit and Build Tools
01:02

Add JUnit 5 to Maven project

4 lectures
IntelliJ IDEA Ultimate edition licence
00:29
Create new Maven project using IntelliJ IDEA
02:34
Add JUnit Dependencies
06:12
Maven Surefire Plugin
04:47

Add JUnit 5 to Gradle project

3 lectures
Creating a new project
02:41
Add JUnit Dependencies
05:07
Executing Unit Test
02:22

Add JUnit 5 to a basic Java project

3 lectures
Introduction
00:40
Basic Java project with IntelliJ
06:32
Basic Java project with Eclipse
06:50

Basics of JUnit 5

16 lectures
Introduction
00:12
Creating First Unit Test method
04:54
Assertions and Assertion message
01:57
Assertion Message
1 question
Other assertions
02:58
JUnit Test Exercise
00:25
Exercise solution overview
03:26
Lazy Assert Messages
04:40
Naming Unit Tests
04:21
@DisplayName annotation
02:33
Test Method Code Structure. Arrange, Act, Assert.
04:12
JUnit Test Lifecycle
03:36
Lifecycle methods demo
06:16
Quiz - JUnit Test Lifecycle
3 questions
Disable Unit Test
02:47
Assert an Exception
05:40

Advanced JUnit 5

15 lectures
@ParameterizedTest. Multiple Parameters with @MethodSource.
07:38
@ParameterizedTest. Multiple parameters with @CsvSource.
04:22
@ParameterizedTest + CSV file
04:43
@ParameterizedTest + @ValueSource annotation.
02:44
Repeated Tests
07:30
Methods Order - Random order
02:35
Methods Order - Order by name
01:54
Methods Order - Random by order index
03:47
Order of Unit Test Classes
08:18
Methods Execution Order - Quiz
3 questions
Test Instance Lifecycle - Introduction
01:55
Changing Test Instance Lifecycle - example 1
04:56
Test Instance Lifecycle Demo project overview
05:02
Test Instance Lifecycle Demo Project Implementation
09:00
Test Instance Lifecycle - Quiz
3 questions

Test Driven Development (TDD) in Java

12 lectures
Introduction to the Test Driven Development(TDD) in Java
03:04
New project, Class, Method
02:17
Creating UserService
03:34
Test Create User method
06:41
Test User object contains first name
04:14
Test Driven Development(TDD) - Refactor Test method
02:15
Test Driven Development(TDD) - Exercise
00:55
Test Driven Development(TDD) - Solution overview
01:07
Check if user id is set
04:02
Assert throws Exception
07:52
TDD - Exercise 2
01:56
Test Driven Development in Java - Quiz.
1 question

Mockito - Create Mocks to test Java code in isolation

14 lectures
Introduction to Mockito
03:31
Adding Mockto to a Java project
02:25
Method under test overview
01:33
Implementing UsersRepository
03:14
Injecting UsersRepository as Dependency
04:17
Mockito - Creating a Mock object
02:42
Stubbing using built-in any() argument matcher
05:01
Mockito - Verify method call
06:34
Mockito - Exception stubbing
05:35
Creating EmailNotificationService class
03:47
Mockito - Stub a void method with Exception
05:20
Mockito - Do nothing when method is called
01:58
Mockito - Call a real method
04:00
Mockito - Quiz
6 questions

Code Coverage - Identify untested code in your Java application

7 lectures
Code Coverage - Introduction
03:52
Generating JUnit Code Coverage report with IntelliJ
05:11
Export JUnit Code Coverage Report using IntelliJ
02:39
Export JUnit Test Report using Maven
06:53
Jacoco - Maven Plugin for Code Coverage
03:03
Jacoco - Export Code Coverage Report in HTML format
03:55
Code Coverage - Quiz
3 questions

Spring Boot (Part 1) - Testing Rest Controllers

13 lectures
Introduction to JUnit Testing of Spring Boot Application
03:28
Introduction to Integration Testing of Web Layer
02:09
Introduction to Integration Testing of All Layers in Spring Boot application
01:47
Adding Testing Support to a Spring Boot Application
04:54
Existing Project overview + Source code
08:10
New Test Class. @WebMvcTest & @AutoConfigureMockMvc.
05:23
RequestBuilder - Building and Performing HTTP Request
09:13
@MockBean - Mocking Service Layer
06:54
@MockBean annotation - Trying how it works.
04:24
Assert for BAD_REQUEST
07:34
Testing Rest Controller - Practice exercise
00:39
Testing Rest Controller - Practice exercise solution overview
03:27
Testing Spring Boot application - Quiz
5 questions

Spring Boot (Part 2) - Testing All layers

16 lectures
Testing All layers of Spring Boot Application - Introduction
00:59
@SpringBootTest annotation
02:02
@SpringBootTest WebEnvironment MOCK
01:37
@SpringBootTest: Defined Port Number
03:42
@TestPropertySource. Loading alternative configuration.
06:34
@SpringBootTest: Random Port Number
03:08
Test Create User - User Details JSON
02:18
TestRestTemplate - Prepare & Perform HTTP Post Request
07:36
Trying how it works
02:50
Test JWT is Required
06:03
Test User Login Works
10:09
Order Test Methods
03:47
GET /users. Include JWT Token in the Request
11:24
Source code
00:03
More lessons are about to be uploaded
00:22
Spring Boot Integration Testing - Quiz
5 questions

Spring Boot(Part 3). Testing Data Layer Only. JPA Entities.

7 lectures
Introduction to testing JPA Entities in Spring Boot application
06:10
JPA Entity Overview + Source Code
03:48
Test that UserEntity can be persisted
08:08
Test UserEntity cannot be persisted with invalid user's first name
04:06
Excersize - Test that UserId is Unique
01:47
Excersize solution + Source code
03:43
Testing Data Layer of Spring Boot Application - Quiz
4 questions

Testing JPA Repositories

5 lectures
Introduction to testing JPA Repositories
05:29
Testing Find By Email Query Method
05:34
Excersize - Test Find By User Id Query Method
01:14
Excersize solution overview + Source code
02:58
Test JPQL Query + Source code
05:52

Integration testing with Testcontainers

13 lectures
Introduction to Testcontainers
05:41
System Under Test(SUT) overview + Source Code
04:49
Adding support for Testcontainers to a Spring Boot application
04:17
@Testcontainers annotation: Enable Testcontainers in a Test class
02:57
@Container annotation: Creating a MySQL container
05:58
@DynamicPropertySource annotation. Connecting to MySQL container.
06:52
Test if container is running
03:58
@ServiceConnection annotation: Connecting to MySQL container.
02:44
MySQL Container: Test User can be created
05:11
Order test methods
06:22
PostgreSQL Testcontainers configuration
00:29
'Oracle Free' Testcontainers configuration
00:32
Apache Kafka Testcontainers configuration
00:52

What's next?

2 lectures
Let's connect!
00:10
Bonus lecture
02:21

Đánh giá của học viên

Chưa có đánh giá
Course Rating
5
0%
4
0%
3
0%
2
0%
1
0%

Bình luận khách hàng

Viết Bình Luận

Bạn đánh giá khoá học này thế nào?

image

Đăng ký get khoá học Udemy - Unica - Gitiho giá chỉ 50k!

Get khoá học giá rẻ ngay trước khi bị fix.