Add dependency to your project

There are two ways of adding dependencies to your project, as discussed in chapter 4. You can manually add dependencies or you can add the dependency to the POM file (then it will be automatically downloaded).

Prerequisites

If you decide to manually add the dependency to the project, then you have to download the library from the following location: http://code.google.com/p/hamcrest/downloads/list

How to do it

Add manual the Hamcrest dependency to the project:

  1. Download the Java bindings, since we are using Java to create our scripts. \ (Url: http://code.google.com/p/hamcrest/downloads/list)
  2. Create a (new) folder under the just created project and give it a meaningful name, like libs (as it will contain the project libraries). Right-click project -> new -> Folder

createNewFolderInProject

  1. Copy hamcrest-all.jar to libs.
  2. Select the hamcrest dependency in libs, right-click on them, and select Build Path > Add to Build Path. Now, the dependencies are added to Referenced Libraries.

addtobuildpath

Use maven to manage the Hamcrest dependency

Another option is to put it directly in the pom.xml file.

  1. Right-click on the project and select Maven -> Add Dependency. A popup window will appear.
  2. Enter hamcrest-all in the searchfield.
  3. Select the latest version of hamcrest-all and click on OK.

Just put the follow snippet between the <dependencies>...</dependencies> tags.

<dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest-all</artifactId>
    <version>1.3</version>
</dependency>

Leave a Reply

Your email address will not be published. Required fields are marked *