Setup Mock in the Maven pom.xml

In this part, we will guide how to setup the Mock in the Eclipse that using Maven. We assume that the Maven is already installed in Eclipse.

In order to add a Maven dependency to the Mockito library, please follow these steps:
1.Double-click on the Maven pom.xml file in your Eclipse project (this is the Maven configuration file)

2.Under the Dependencies tab (NOT the “Dependency Hierarchy” tab) –> Click the “Add…” button beside the left-hand “Dependencies” column.

3.In the Dependency Properties window –> Set the following properties:
Group Id: org.mockito
Artifact Id: mockito-core
Version: 2.8.9
Type: jar
Scope: test
You can leave the other fields empty

4.Click OK when done.
Save pom.xml via File->Save All

5.Maven will automatically download Mock lib into your local classpath.
Thanks for Maven for this useful feature ^^.

If you face any issues, please refer to this FAQ:
https://prestobear.com/2017/11/eclipse-problem-issue/

Add Comment