课程: Complete Guide To Java Testing with JUnit 5 & Mockito
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Verify arguments with argument captors
课程: Complete Guide To Java Testing with JUnit 5 & Mockito
Verify arguments with argument captors
- [Instructor] Argument captors provide an alternative approach for verifying your methods are called with the correct arguments. Instead of merely specifying conditions that the arguments should match, argument captors allow you to capture and inspect the actual arguments passed. This enables more detailed inspections of the arguments after the method call, making your tests more robust. Let's take a look at an example. Here we have a test that verifies some processing for a transaction. In our verification, we use an argument matcher to verify the third argument is a timestamp. Let's modify this to use an argument captor so we can see the actual value of the timestamp passed. To start off, we'll create an argument captor for our timestamp. This is done as part of the method, but we can also make this a field if we want to use the captor in multiple tests. If we make it a field, we can leverage the captor annotation. The captor annotation creates an argument captor instance that can…
内容
-
-
-
-
-
-
-
-
(已锁定)
Set up Mockito1 分钟 40 秒
-
(已锁定)
Mocking basics3 分钟 17 秒
-
(已锁定)
How to mock an object in Java2 分钟 32 秒
-
(已锁定)
Stub a method with Mockito3 分钟
-
(已锁定)
Verify an interaction with Mockito3 分钟 49 秒
-
(已锁定)
Verify arguments with argument matchers3 分钟 13 秒
-
(已锁定)
Verify arguments with argument captors5 分钟 7 秒
-
(已锁定)
Challenge: Test a library management system1 分钟 32 秒
-
(已锁定)
Solution: Test a library management system7 分钟 6 秒
-
(已锁定)
-
-
-