From the course: Java: Testing with JUnit

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Mockito

Mockito

- [Instructor] Whenever you are using any framework, you'll often find yourself using common libraries that go well with it. For unit testing, you really want to minimize the dependencies. And as we just saw, the fact is, that we often can't get around needing an external object. This is the point where it's time to meet the Mockito library. Mockito is a testing library that helps for stubbing and mocking objects. "Mocking" means that we're going to create an isolated version of the object that we can influence, rather than the real one. This will help us to keep our dependencies to a minimum, and isolate our test to be truly testing the simple unit. Let's move over to IntelliJ, and look at the simple Mockito example. Let's configure a project to be used in Mockito. You'll have to add the following dependencies to your pom. So the first one is the "org.mockito" groupId, and then the artifactId, "mockito-junit-jupiter".…

Contents