5910 Breckenridge Pkwy Suite B, Tampa, FL. 33610
(800) 272-0707

SkillSoft Explore Course

Aspire     Javanista to Java Master     Javanista to Java Master Track 1: Unit Testing
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.

Objectives

Unit Testing with Mocks: Creating Mocks & Verifying Behavior

  • discover the key concepts covered in this course
  • create mocks using the @Mock annotation
  • set up multiple objects to be mocked in test cases
  • mock objects in a real-world scenario
  • use @ExtendWith to automatically initialize mocks
  • illustrate how the @InjectMock annotation works
  • use the @InjectMock annotation to inject mocks
  • use the @InjectMocks annotation to inject mocks into constructors, setters, and fields
  • verify the invocations of a method
  • use the verifyNoInteractions() function
  • illustrate the nuances of the verify() function
  • demonstrate how ordered mocks work
  • use multiple techniques to verify the behavior of objects under test and their interactions with mocks
  • summarize the key concepts covered in this course