Summary
Keywords
Full Transcript
Let's become expert of unit testing java spring boot rest api application using Junit , AssertJ , Mockito , H2Database , Springframework test package libraries / frameworks. This is a full one shot course on software unit testing java spring boot applications. In this tutorial, Cloud Vendor API is further evolved and junit test cases are written for all 3 layers i.e. controller layer , service layer and repository layer. All layers are unit tested using junit, assertj, mockito, h2database and springframework test package . Code coverage method is also demonstrated in this session. Software testing expected from java developers is explained here. Unit Testing is mandatory task to perform in java projects from every Java developer. Unit testing java projects helps to enhance java code quality and prevents java spring boot application from bugs. This tutorial will be helpful for backend developers and also for full stack developers. Some notes - JUNIT - Unit testing framework for Java and its frameworks. JUnit 5 is the next generation of JUnit. The goal is to create an up-to-date foundation for developer-side testing on the JVM. This includes focusing on Java 8 and above, as well as enabling many different styles of testing. AssertJ - AssertJ is a Java library that provides a rich set of assertions and truly helpful error messages. It improves test code readability, and is designed to be super easy to use within your favorite IDE. Mockito - Mockito is a mocking framework for Java. It lets you write beautiful tests with a clean & simple API. The tests are very readable and they produce clean verification errors. Mockito 3.x requires Java 8 or above. H2 Database - H2 Database is Java SQL Database Very fast and open source Used as In-Memory Database Spring Boot can auto-configure embedded H2 databases. Key Annotations - @SpringBootApplication @Test @DataJpaTest @WebMvcTest @Mock @MockBean @Autowired @BeforeEach @AfterEach and more... Spring Boot Session Links are given below - 1st session - https://youtu.be/iBGkJln9BPo 2nd session - https://youtu.be/RfHBm5yRxuw 3rd Session - https://youtu.be/L2o485T70Do 4th Session - https://youtu.be/cI6VlGDLH5s Playlist for Spring Boot How To tutorial is - https://youtube.com/playlist?list=PLcs1FElCmEu121gqGwlQt47d0SqNkzSTK GitHub link for CloudVendorApi code - https://github.com/thinkconstructive/rest-api-spring-boot-demo/tree/master Pls subscribe to the channel - https://www.youtube.com/channel/UCzmtevVkHLAvs4xMSHNr4sA?sub_confirmation=1 Follow me on - Official Website: https://thinkconstructive.com/ @Twitter : https://twitter.com/TConstructive @LinkedIn : https://www.linkedin.com/in/eshapuri/ @LinkedIn : https://www.linkedin.com/company/think-constructive/ Support the channel with your Amazon purchase - Atomic Habits - https://amzn.to/3yEzGU5 The Courage To Be Disliked - https://amzn.to/3wheVMz Disclosure, I use affiliate Amazon links above. Purchasing through these links gives me a small commission -- the price to you is the same. #thinkconstructive #eshapuri #junit #junit5 #springboot Chapters 00:00:00 Welcome 00:01:33 What is Unit Testing and Importance of Unit Testing 00:02:11 Java Spring Boot Project Design Overview 00:04:39 What is Junit ? 00:06:13 What is AssertJ ? 00:08:20 What is Mockito ? 00:09:26 What is H2 Database ? 00:11:17 Cloud Vendor API Software Project Overview 00:13:02 JUNIT Test Package Structure 00:13:50 Maven Dependency in pom.xml inclusion and verification 00:18:41 test/java/resources/application.yaml or test/java/resources/application.properties file content and structure 00:21:54 Repository Layer Test Cases : Java Spring Boot REST API 00:44:23 Service Layer Test Cases : Java Spring Boot REST API 01:09:54 Code Coverage using Intellij for Java REST API Repository Layer and Service Layer 01:12:59 Controller Layer Test Cases : Java Spring Boot REST API 01:36:32 Code Coverage using Intellij for Java REST API Controller Layer 01:39:00 Summary 01:40:25 Thank You Queries how to write unit test in java spring boot how to write unit test in java spring boot rest what is junit5 library what is assertj library what is mockito library how to use h2database what is spring boot test how to write test case in java spring boot how to test controller layer code how to test service layer code how to test repository layer code how to check code coverage how to check code coverage of java spring boot application how to verify code coverage of java project how to run junit test
