Unit Testing with Mocks: Getting Started with Mockito
Software Testing
| Beginner
- 15 videos | 1h 59m 30s
- Includes Assessment
- Earns a Badge
Mockito is a Java framework for building mocks during unit testing. When performing unit tests on an object, you often have other, complex objects that the object under test depends upon. Rather than using those complex objects, you can use Mockito to create mocks of those objects and stub their methods to simulate expected behavior. Use this course to get to grips with mocking and its relationship with unit testing. Set up a Maven project and add the required Mockito and JUnit dependencies. Create mocks of built-in classes, such as the ArrayList, and built-in interfaces, such as the Comparator. Then, work with stub methods using Mockito's when().thenReturn() syntax. When you're done, you'll be able to identify situations where using mocks is a good idea, construct mocks, stub methods in them using Mockito, and use mock objects in unit tests.
WHAT YOU WILL LEARN
-
Discover the key concepts covered in this courseRecall how mocks can be used with unit testsRecall the benefits of using mockito to mock objectsInstall maven and set up a new projectSet up intellij with a maven projectAdd dependencies for junit and mockitoUse the static mock() method to mock objectsUse the when().thenreturn() syntax to configure behavior
-
Use assertions in test casesConfigure mocks with the when().thenreturn() syntax with input argumentsCreate mock objects of interfacesSort a treeset using a comparator mockSet up a real-world object that can be mockedMock an iterator objectSummarize the key concepts covered in this course
IN THIS COURSE
-
1m 52s
-
10m 19s
-
5m 14s
-
8m 48s
-
7m 15s
-
9m 43s
-
7m 54s
-
8m 45s
-
6m 26s
-
11m 34s
-
9m 48s
-
11m 33s
-
7m 25s
-
10m 43s
-
2m 13s
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.