Master the art of unit testing with the powerful combination of Spring Boot and Mockito. Learn how to develop robust and efficient RESTful Services by harnessing the capabilities of these popular frameworks.
Course Overview
In this comprehensive course, you will discover how to write exceptional unit tests for simple RESTful services using Spring Boot Starter Test, Mockito, and JUnit. This course will guide you in writing independent unit tests for RESTful web services that interact with multiple layers: web, business, and data. Additionally, you will master the art of writing integration tests utilizing an in-memory database H2.
Course Structure
Step-by-Step Guide
Embark on a journey of 40 comprehensive steps designed to introduce you to unit testing with the Spring Boot and Mockito frameworks.
Tools and Technologies
Throughout the course, you will work with Spring (Dependency Management), Spring Boot, Maven (dependencies management), Eclipse (IDE), in-memory database H2, and the Tomcat Embedded Web Server. We will assist you in setting up each of these tools.
Frameworks and Libraries
You will explore a variety of frameworks included in Spring Boot Starter Test, including JUnit, Spring Test, Spring Boot Test, AssertJ, Hamcrest, Mockito, JSONassert, and JsonPath.
Key Annotations
Enhance your skills by learning to use the most critical unit testing annotations: @RunWith(SpringRunner.class), @SpringBootTest, @WebMvcTest, @DataJpaTest, and @MockBean.
Course Content
Section 1: Learning Mocking with Mockito
- Step 01: Setting up the project using Spring Initializr
- Step 02: Writing a Unit Test for a Simple Business Service
- ... (and other steps)
Section 2: Unit Testing RESTful Services
- Step 01: Creating a Hello World Controller
- Step 02: Using Mock Mvc to Test Hello World Controller
- ... (and other steps)
Requirements
- A willingness to learn and have fun :)
- Basic working knowledge of Java, JUnit, Spring, Spring Boot, and JPA/Hibernate.
- Assistance in installing Eclipse and getting started with Maven and Tomcat is provided.
Who Should Enroll
- Spring/Spring Boot/Java Programmers who aim to write outstanding unit tests for RESTful Services
- Developers interested in using mocking for unit tests
- Those who want to understand the best practices in writing superior unit tests with JUnit, Mockito, and Spring Boot Starter Test
- Learners eager to employ Hamcrest Matchers, JSON Assert, Assert J, and JSON Path libraries for effective assertions
Learning Outcomes
- Proficiency in writing GREAT UNIT and INTEGRATION Tests using Spring Boot Starter Test from the ground up
- Skill in creating INDEPENDENT Unit Tests for RESTFUL web services interacting with MULTIPLE LAYERS
- Mastery of essential Unit Testing ANNOTATIONS like @SpringBootTest, @WebMvcTest, @DataJpaTest, and @MockBean
- Utilization of all frameworks in Spring Boot Starter Test including JUnit, AssertJ, and Mockito
- Expertise in writing unit tests employing MOCKS and SPYS created with MOCKITO
- Capability to write Integration Tests using an IN MEMORY DATABASE - H2