Unit Testing with Mocks: Creating Mocks & Verifying Behavior

Software Testing
  • 14 Videos | 2h 4m 57s
  • Includes Assessment
  • Earns a Badge
Likes 1 Likes 1
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 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

IN THIS COURSE

  • Playable
    1. 
    Course Overview
    1m 58s
    UP NEXT
  • Playable
    2. 
    Using the @Mock Annotation to Create Mocks
    9m 57s
  • Locked
    3. 
    Creating Objects to be Mocked
    7m 59s
  • Locked
    4. 
    Using Mocks of Real-world Objects
    9m 17s
  • Locked
    5. 
    Using the @ExtendWith Annotation
    7m 20s
  • Locked
    6. 
    Working with the @InjectMocks Annotation
    11m 3s
  • Locked
    7. 
    Using the @InjectMocks Annotation to Inject Mocks
    11m 57s
  • Locked
    8. 
    Injecting Mocks into Constructors, Fields, & Setters
    11m 52s
  • Locked
    9. 
    Using verify() to Verify Method Invocations
    11m 24s
  • Locked
    10. 
    Using the verifyNoInteractions() Function
    9m 50s
  • Locked
    11. 
    Navigating the Nuances of verify()
    8m 1s
  • Locked
    12. 
    Checking for Method Invocation Order
    10m 22s
  • Locked
    13. 
    Using Techniques to Verify Test Object Behavior
    11m 56s
  • Locked
    14. 
    Course Summary
    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 of this course, which can be shared on any social network or business platform

Digital badges are yours to keep, forever.