Are you using dependency management yet?

When I wrote “Selenium Simplified” I was not using dependency management much. At work we were slowly migrating over to Maven but many of the libraries we were using had to be referenced either locally from the Maven pom or into a local repository manager like Artifactory or Nexus.

I didn’t really want the hassle of explaining local references, as well as Maven, as well as setting up a local repo manager in a beginner’s book like “Selenium Simplified” so I stuck to Ant, with libraries managed in the version control system.

This seemed fine at the time because the Selenium binaries were not in a Maven repo and many of the companies I worked at took a similar approach.

But now, when I working with Selenium WebDriver I have pretty much moved over to using dependency management.

Using dependency management helps me:

Keep my local version control repo small

Change between versions of libraries easily

Setup up different build targets for testing quite easily

I do most of my work using Java so Maven works out of the box really well, so long as I conform to the Maven directory structure.

I’ve slowly learned a little more about Maven, e.g. using profiles to partition out test runs, but really for most of the testing requirements we have, I don’t have to do very much with maven at all and I mainly use it for the dependency management and simple build features.

So if you haven’t started using dependency management yet in your testing projects I thoroughly recommend it.

I did some client work recently on a very quick proof of concept of using WebDriver on their application and using a dependency management approach with Maven I was able to get started with WebDriver, JUnit, Hamcrest and the OperaDriver and Firefox driver without having to setup a bunch of libraries in my project. My dependency section was as simple as:

<dependencies>
<!-- if we use junit-dep then we can bring in the full hamcrest -->
<!-- JUnit 4.10 depends on hamcrest 1.1 -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<!-- bring in the full selenium deploy
we could be more selective and bring
only what we need -->
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.26.0</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.1</version>
</dependency>
</dependencies>

Of course, Selenium WebDriver is up to version 2.28 at the time of writing, so to update the pom file I would have to change the version of the dependency to 2.28.0, which would take about a second - which is a tad faster than downloading the libraries and checking them in to my version control system and changing my ant file.

And of course JUnit 4.11 is out now, and uses hamcrest 1.3, but that would be easy to add to the dependencies as well, or to drop back down a version of WebDriver if you encounter issues in your tests.

You don’t have to jump to Maven, you can use dependency management from within Ant as well, and most other languages have their own dependency management systems.

If you haven’t started using dependency management yet. I recommend you experiment now.