Unit Testing with Mocks: Creating Mocks & Verifying Behavior

Software Testing    |    Intermediate
  • 14 videos | 2h 4m 57s
  • Includes Assessment
  • Earns a Badge
Rating 4.7 of 26 users Rating 4.7 of 26 users (26)
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

  • 1m 58s
  • 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 on some of our courses, which can be shared on any social network or business platform.

Digital badges are yours to keep, forever.

YOU MIGHT ALSO LIKE

Rating 5.0 of 1 users Rating 5.0 of 1 users (1)
Rating 4.6 of 18 users Rating 4.6 of 18 users (18)
Rating 4.6 of 38 users Rating 4.6 of 38 users (38)

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 4.6 of 38 users Rating 4.6 of 38 users (38)
Rating 4.4 of 56 users Rating 4.4 of 56 users (56)
Rating 4.7 of 78 users Rating 4.7 of 78 users (78)