课程: Complete Guide To Java Testing with JUnit 5 & Mockito
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Test asynchronous code with Mockito
课程: Complete Guide To Java Testing with JUnit 5 & Mockito
Test asynchronous code with Mockito
- [Instructor] Asynchronous programming has become increasingly common in modern software development, especially with the rise of reactive programming. Testing asynchronous code can be challenging, but with the right tools and techniques, it can be made simpler and more effective. Let's take a look at an example. Here, we have a user service class that interacts asynchronously with a user repository. Completable Future was introduced in Java eight, and represents a future result of an asynchronous operation. Here, that operation is finding a user by its ID. The return type indicates it will eventually provide a user object as a result of the asynchronous operation. The supply async method is a static factory method provided by the completable feature class. It will execute a supplier asynchronously. Here, that supplier is our Lambda function. When supply async is called, the logic inside the Lambda expression will be submitted to the default executor service. This means the method…
内容
-
-
-
-
-
-
-
-
-
(已锁定)
Spy on real objects with Mockito4 分钟 31 秒
-
(已锁定)
Test exception handling with Mockito2 分钟 10 秒
-
(已锁定)
Test void methods with Mockito5 分钟 10 秒
-
(已锁定)
Verify no (or a set number of) interactions5 分钟 1 秒
-
(已锁定)
GetAllValues with ArgumentCaptor5 分钟 1 秒
-
(已锁定)
Test asynchronous code with Mockito3 分钟 17 秒
-
(已锁定)
Mock a static method with Mockito3 分钟 15 秒
-
(已锁定)
Challenge: Test an ordering service1 分钟 2 秒
-
(已锁定)
Solution: Test an ordering service8 分钟 21 秒
-
(已锁定)
-
-