CRUD JUnit Tests for Spring Data JPA | Testing Repository Layer | Spring Boot | @DataJpaTest

Java Guides
Java Guides
85.9 هزار بار بازدید - 3 سال پیش - In this video, we will
In this video, we will learn how to test repository or DAO layer using Spring boot provided @DataJpaTest annotation.

We will write a JUnit test cases for CRUD operations - Create, Read, Update and Delete.

Table of contents:
⌚[00:00] Intro
⌚[01:44] Create Spring Boot Project
⌚[05:38] Create JPA Entity
⌚[09:30] Create Spring Data JPA Repository
⌚[12:38] Create EmployeeRepositoryTests Class
⌚[13:59] JUnit test for Save Employee
⌚[18:25] JUnit test for Get Employee
⌚[20:34] JUnit test for Get List of Employees
⌚[22:18] JUnit test for Update Employee
⌚[25:11] JUnit test for Delete Employee
⌚[32:15] Ordering JUnit tests
⌚[34:45] Running JUnit tests

Spring Boot provides the @DataJpaTest annotation to test the persistence layer components that will autoconfigure in-memory embedded databases and scan for @Entity classes and Spring Data JPA repositories. The @DataJpaTest annotation doesn’t load other Spring beans (@Components, @Controller, @Service, and annotated beans) into ApplicationContext.

Source code and blog post at https://www.javaguides.net/2021/07/cr...

#junit #springboot #springdatajpa
3 سال پیش در تاریخ 1400/04/16 منتشر شده است.
85,984 بـار بازدید شده
... بیشتر