Unit Testing with Mocks: Creating Mocks & Verifying Behavior
Software Testing
| Intermediate
- 14 videos | 2h 4m 57s
- Includes Assessment
- Earns a Badge
Mocks built in Mockito do more than just simulate the behavior of complex objects that your object under test depends upon. Mockito makes it easy for you to verify specific aspects of how the object under test and the mock interact. In this course, learn how to build mocks using annotations and use them to perform dependency injection into the object. Then, learn how to work with constructor, setter property, and field injection. Moving along, verify the behavior of the object under test and its interaction with the mock using Mockito constructs, such as verify(), verifyNoInteractions(), and various argument matchers. When you're done, you'll be able to use annotations to construct mocks in a clean and simple manner and test very specific aspects of the interactions between the stubs in your mocks and the object under test.
WHAT YOU WILL LEARN
-
Discover the key concepts covered in this courseCreate mocks using the @mock annotationSet up multiple objects to be mocked in test casesMock objects in a real-world scenarioUse @extendwith to automatically initialize mocksIllustrate how the @injectmock annotation worksUse the @injectmock annotation to inject mocks
-
Use the @injectmocks annotation to inject mocks into constructors, setters, and fieldsVerify the invocations of a methodUse the verifynointeractions() functionIllustrate the nuances of the verify() functionDemonstrate how ordered mocks workUse multiple techniques to verify the behavior of objects under test and their interactions with mocksSummarize the key concepts covered in this course
IN THIS COURSE
-
1m 58s
-
9m 57s
-
7m 59s
-
9m 17s
-
7m 20s
-
11m 3s
-
11m 57s
-
11m 52s
-
11m 24s
-
9m 50s
-
8m 1s
-
10m 22s
-
11m 56s
-
2m 3s
EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE
Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.
Digital badges are yours to keep, forever.