Learn Java Unit Testing with Junit & Mockito in 30 Steps

所在平台: Udemy

课程主页: https://www.udemy.com/course/mockito-tutorial-with-junit-examples/

课程评论:没有评论

第一个写评论        关注课程

课程简介

本课程名为“30步掌握Java单元测试,使用JUnit和Mockito”,旨在帮助学习者从优秀程序员迈向卓越程序员。课程强调了编写优秀单元测试的重要性,并系统地教授了如何使用Mockito和JUnit来完成这项技能。 课程内容涵盖了Java单元测试的多个方面,分为JUnit和Mockito两大模块。 **JUnit部分(12步)**: * 学习单元测试的需求和基础。 * 设置首个JUnit测试并实现“绿条”(成功运行)。 * 学习使用`assertEquals`、`assertTrue`、`assertFalse`等断言方法。 * 掌握JUnit的设置和清理方法,如`@Before`、`@After`、`@BeforeClass`、`@AfterClass`。 * 学习测试数组、异常和性能。 * 探索参数化测试和JUnit测试套件的组织。 **Mockito部分(18步)**: * 使用Eclipse设置包含JUnit和Mockito的Java项目。 * 理解mock的必要性,并学习创建第一个Mockito mock。 * 深入了解stub的概念、用法及其局限性。 * 掌握Mockito的多种stubbing技巧,包括多返回值、参数匹配器和抛出异常。 * 学习行为驱动开发(BDD)和Mockito的BDD语法(Given-When-Then)。 * 学习如何验证mock对象的行为,例如方法调用次数。 * 掌握如何捕获传递给mock方法的参数。 * 学习使用Hamcrest Matchers简化断言。 * 利用Mockito注解(`@Mock`、`@InjectMocks`、`@RunWith`、`@Captor`)简化测试代码。 * 了解JUnit Rules,并使用`MockitoJUnit.rule()`替代`@RunWith`。 * 通过真实的Spring框架示例应用所学知识。 * 学习spy的概念和使用方法。 * 探讨Mockito为何不支持mock final和private方法。 * 学习使用PowerMock和Mockito来mock静态方法、私有方法和构造函数。 * 最后,学习如何编写好的单元测试。 学习者反馈普遍积极,认为课程讲解清晰,实例丰富,无论是初学者还是有经验的开发者都能从中获益良多。课程以循序渐进的方式,将理论与实践相结合,帮助学习者在JUnit和Mockito方面达到熟练掌握的水平。

课程评论(0条)

课程详情

Writing Great Unit Tests distinguishes Good Programmers from Great Programmers. In this course, you will learn how to Write Great Java Unit Tests with Mockito and JUnit. WHAT OUR LEARNERS ARE SAYING:5 STARS - When I've started this course I had very basic knowledge of JUnit and Mockito and now everything is clearer. It is a very good course for beginners. Everything was very well explained. 5 STARS - As always, Ranga offers an excellent way of teaching: coding from scratch, good explanation, useful examples for the real world job. He is not only an experienced programmer, but also a great teacher. I learned more than I expected. Thanks5 STARS - It was my long time wish to learn Mockito and this instructor nailed it. Best 5hrs I spent ever. He is really good in what he is doing. 5 STARS - This course is a great tutorial to unit testing and standard practices of mocking. I would recommend it to even experienced developers who would be surprised to find some new ideas in here. Explanations are precise and detailed. Well done.5 STARS - Very interesting course with good examples. Every topic was easy to understand because of author's awesome explanation. I rate this course as 5/5.5 STARS - Very good course. The approach is very systematic and step by step. I really like the combination of theory and practical goes hand by hand. The journey from JUnit to Mockito to Powermock is very well described.COURSE HIGHLIGHTSYou take 12 steps with JUnit and 18 steps with Mockito into unit testing proficiency.Mocking with Mockito Step 01: Set up an Eclipse Project with JUnit and Mockito frameworks. First Green Bar.Step 02: Example to start understanding why we need mocks.Step 03: What is a stub? Create an unit test using Stub? Disadvantages of Stubs.Step 04: Your first Mockito code! Hurrah!!! Lets use Mockito to mock TodoService.Step 05: Stubbing variations with Mockito. A few mockito examples mocking List class: Multiple return values, Argument Matchers and throwing exceptions.Step 06: Introduction to BDD. Given When Then. BDD Mockito Syntax.Step 07: How to verify calls on a mock? Verify how many times a method is called. We will add deleteTodo method to the TodoService.Step 08: How to capture an argument which is passed to a mock?Step 09: Hamcrest Matchers.Step 10: Let's simplify things with Mockito Annotations. @Mock, @InjectMocks, @RunWith(MockitoJUnitRunner.class), @CaptorStep 11: JUnit Rules. Using MockitoJUnit.rule() instead of @RunWith(MockitoJUnitRunner.class).Step 12: Real world Example with SpringStep 13: What is a spy? How to spy with Mockito?Step 14: Some Theory: Why does Mockito not allow stubbing final and private methods?Step 15: Using PowerMock and Mockito to mock a Static Method.Step 16: Using PowerMock and Mockito to invoke a private Method.Step 17: Using PowerMock and Mockito to mock a constructor.Step 18: Good Unit Tests.JUnit FrameworkStep 01: Need for Unit TestingStep 02: Setting up your First JUnitStep 03: First Successful JUnit. Green Bar and assertEqualsStep 04: Refactoring Your First JUnit TestStep 05: Second JUnit Example assertTrue and assertFalseStep 06: @Before @AfterStep 07: @BeforeClass @AfterClassStep 08: Comparing Arrays in JUnit TestsStep 09: Testing Exceptions in JUnit TestsStep 10: Testing Performance in JUnit TestsStep 11: Parameterized TestsStep 12: Organize JUnits into SuitesStart Learning Now. Hit the Enroll Button!

课程标签

0人关注该课程

主题相关的课程