Master Java Unit Testing with Spring Boot & Mockito

所在平台: Udemy

课程主页: https://www.udemy.com/course/learn-unit-testing-with-spring-boot/

课程评论:没有评论

第一个写评论        关注课程

课程简介

这门Coursera课程“使用Spring Boot和Mockito精通Java单元测试”旨在帮助学习者掌握为Spring Boot RESTful服务编写高质量单元测试的技能。课程强调了Spring Boot Starter Test、Mockito和JUnit等核心框架的应用,并通过40个步骤详细讲解了如何构建独立的单元测试,涵盖了Web、业务和数据层。 课程内容包括: * **Mockito基础**:学习如何使用Mockito进行模拟,包括Stub、`@Mock`、`@InjectMocks`、`@RunWith(MockitoJUnitRunner.class)`等注解,以及模拟返回值、验证方法调用、参数捕获等高级技巧。 * **Spring Boot单元测试RESTful服务**:利用`MockMvc`测试Controller,使用`Response Matchers`检查响应状态和内容。学习如何进行JSON断言,包括`JsonAssert`的深入使用。 * **分层测试**:学习如何模拟业务层,测试数据层(使用`@DataJpaTest`和H2内存数据库),以及编写端到端(Integration Test)的测试。 * **Spring Boot测试注解**:重点讲解`@RunWith(SpringRunner.class)`,`@SpringBootTest`,`@WebMvcTest`,`@DataJpaTest`和`@MockBean`等关键注解的用法。 * **其他测试工具和技巧**:课程还介绍了`Hamcrest Matchers`、`AssertJ`和`JsonPath`以进行更丰富的断言,以及如何进行静态导入、测量测试覆盖率和关注单元测试性能。 本课程适合初学者和希望提升Java测试技能的开发者,通过丰富的示例和清晰的讲解,帮助学员编写出高效、可维护的单元测试。

课程评论(0条)

课程详情

Great Programmers write Great Unit Tests. Want to Write Great Unit Tests for Spring Boot REST API ?Spring Boot Test? Yes. Layered Unit Tests? Yes. Of Course. Spring Boot Integration Tests? Yes.Mockito? Yes. JsonAssert, Hamcrest Matchers, and JsonPath? Yes. Included.WHAT OUR LEARNERS ARE SAYING:5 STARS - This a very comprehensive introduction to spring boot test, which brings Mockito, Junit, JsonAssert, Spring Data JPA, REST, design pattern, and many more. Very valuable course. Thanks.5 STARS - Excellent and to the point course on Unit testing with good references.5 STARS - This is an excellent course for both beginners as well as experienced Java developers who which to hone their skill. The instructor was very knowledgeable and knew how to keep the course engaging while providing lots of tips. Highly recommended...5 STARS - Great Course to learn Junit Testing. Great content and great examples to explain each scenarios of writing test cases. If you want to write java test cases then definitely go through this course.5 STARS - This course is a great introduction to unit and integration testing using Spring Boot, Mockito, and a number of other libraries that can help to write effective tests. It is easy to follow along with and has plenty of references where to look for more information.5 STARS - Needed it for new client project. Excellent source of concise tutorials for JUnit of microservices.5 STARS - I was drowning in unit test concepts and this course cleared up what read about them. And have a simple but clear explanation of when is good and how to create unit test in your app.COURSE OVERVIEWSpring Boot is the most popular framework to develop RESTful Services. It has Awesome Unit Testing capabilities through Spring Boot Starter Test. Mockito is the most popular mocking framework. JUnit is most popular Java Unit Testing Framework.In this course, you will learn to Write Great Unit Tests for Simple RESTful Services with Spring Boot Starter Test, Mockito and JUnit. You will learn to write independent unit tests for RESTful web services talking with multiple layers - web, business and data. You will learn how to write integration tests using an in memory database H2.You will build the unit tests step by step - in 40 easy steps. This course would be a perfect first step as an introduction to unit testing with Spring Boot and Mockito Frameworks.You will be using Spring (Dependency Management), Spring Boot, Maven (dependencies management), Eclipse (IDE), in memory database H2 and Tomcat Embedded Web Server. We will help you set up each one of these.You will use all the frameworks that are part of Spring Boot Starter Test - JUnit, Spring Test, Spring Boot Test, AssertJ, Hamcrest, Mockito, JSONassert and JsonPath.You will learn to use the most important Unit Testing Annotations - @RunWith(SpringRunner.class), @SpringBootTest, @WebMvcTest, @DataJpaTest and @MockBean.COURSE HIGHLIGHTSSection 1 - Learning Mocking with MockitoStep 01: Setting up the project using Spring InitializrStep 02: Writing Unit Test for a Simple Business ServiceStep 03: Setting up a Business Service to call a Data ServiceStep 04: Writing your first unit test with StubExercise - Update Tests 2 & 3Step 05: Exercise Solution - Updating Tests 2 & 3 to use Stubs - Problem with Stubs.Step 06: Writing Unit Tests with Mocking using MockitoExercise - Updating Tests 2 & 3 to use MockitoStep 07: Exercise Solution - Updating Tests 2 & 3 to use MockitoStep 08: More Refactoring - @Mock, @InjectMocks and @RunWith(MockitoJUnitRunner.class)Step 09: Mockito Tips - Multiple Return Values and Specific Argument MatchersStep 10: Mockito Tips - Argument MatchersStep 11: Mockito Tips - Verify method callsStep 12: Mockito Tips - Argument CaptureStep 13: Mockito Tips - Argument Capture on Multiple CallsStep 14: Introduction to SpyStep 15: Mockito FAQSection 2 - Unit Testing RESTful Services with Spring Boot and MockitoStep 01: Creating a Hello World ControllerStep 02: Using Mock Mvc to test Hello World ControllerStep 03: Using Response Matchers to check status and contentStep 04: Creating a Basic REST Service in Item ControllerStep 05: Unit Testing Item Controller and Basic JSON AssertionsStep 06: Digging deeper into JSON AssertStep 07: Writing a REST Service talking to Business LayerStep 08: Writing Unit Test for REST Service mocking Business LayerStep 09: Prepare Data Layers with JPA, Hibernate and H2Step 10: Create Item Entity and Populate data with data.sqlStep 11: Create a RESTful Service talking to the databaseStep 12: Writing Unit Test for Web Layer - Controller - Using Mock MVCStep 13: Exercise & Solution - Writing Unit Test for Business Layer - MockingStep 14: Writing Unit Test for Data Layer - Data JPA TestStep 15: Writing an Integration Test using @SpringBootTestStep 16: Tip: Using @MockBean to mock out dependencies you do not want to talk to!Step 17: Tip: Creating Different Test ConfigurationStep 18: Writing Unit Tests for Other Request MethodsStep 19: Refactor SomeBusinessImpl to use Functional ProgrammingStep 20: Better Assertions with Hamcrest - HamcrestMatcherTestStep 21: Better Assertions with AssertJ - AssertJTestStep 22: Better Assertions with JSONPath - JSONPathTestStep 23: Easier Static ImportsStep 24: Tip: Measuring Test Coverage with EclipseStep 25: Tip: Keep an eye on performance of unit tests!Step 26: Good Unit TestsStart Learning Now. Hit the Enroll Button!

课程标签

0人关注该课程

主题相关的课程