How to Set Up Continuous Integration with Eclipse, Selenium Webdriver, Maven and Hudson

Background

This is the first in a series of blog posts that will run over the course of the next 2 weeks on quality assurance testing set-up and frameworks. This post is meant for software developers and quality assurance testers looking to set up a Continuous Integration environment for their projects using Eclipse, Selenium Webdriver, Maven, and Hudson.

Prerequisites:

1.    Download the latest java jdk from here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
2.    Download the latest build for eclipse(java ee developers) from here: http://www.eclipse.org/downloads/
3.    Download the latest apache maven from here: http://maven.apache.org/download.cgi
4.    Download the latest Hudson from here: http://hudson-ci.org/

Steps:

1.    Install the Java JDK and set the JAVA_HOME environment variable to point to the path where Java JDK was installed (on a windows 7 system the environment variables can be accessed by right clicking your Computer, select Properties, then Advanced system settings, then press the Environment Variables… button)

Environment Variables

2.    Unpack the maven archive, then set the MAVEN_HOME env variable to point to the path where maven was installed

Environment Variables

3.    Set the Path variable to both: %JAVA_HOME%\bin and %MAVEN_HOME%\bin

Path variable

4.    To check everything is ok, open a command prompt and type: java –version to see the current version of the java jdk installed and also mvn to see if the command is recognized by the system

Command Prompt

5.    Unpack the eclipse archive to a local directory and create a shortcut for it on Desktop and start it

6.    Choose a directory for your workspaces

workspaces

7.    Go to Help -> Eclipse Marketplace and search for m2eclipse, then choose Maven Integration for Eclipse

Eclipse Marketplace

8.    Click Next on the following screen

Eclipse Marketplace

9.    Accept the license and click Finish

Eclipse Marketplace

10.    Restart eclipse

Restart eclipse

11.    Go to the workspaces folder and create a new folder for your project

12.    In that folder copy the following pom.xml file:

Restart eclipseJust make sure the versions for:

selenium-java
                2.28.0 and 
junit
4.11 are set to the latest available

13.    Open a command prompt and run “mvn clean install” in that directory where the pom.xml file is located:

command prompt

14.    Wait for the build to be completed, then run “mvn eclipse:eclipse”

mvn eclipse:eclipse

15.    You now have an eclipse project generated for you

Eclipse Marketplace

16.    Go to eclipse, choose File -> Import, then Existing projects into workspace

Existing projects into workspace

17.    Click Next then select the path to the previously created project folder

Import Projects

18.    Your project will be imported and it will look something like this:

Java EE Eclipse

19.    In eclipse right click the project folder and select New-> Source Folder and give it the name: “src” then click Finish

New Source Folder

20.    Select the src folder, right click on it, select New -> Package and give it the name: “test.java”

Java Package

21.    Right click the test.java package and select New -> Class and name it CI_StarterTest, uncheck the Inherited abstract methods option and click Finish (the class name must have the word Test in it!)

New Java Class

22.    Copy the contents of this file in the java class you’ve just created

23.    Your project should now look like this:

Java EE

24.    To make sure everything works fine, go to your project folder and start a command prompt in that folder, the run the command: “mvn clean install”, you should have a successful build

mvn clean install

Hudson configuration

1.    Copy the war file to a directory of your convenience

2.    Create a bat file to run it, call it runHudson.bat, it will contain: “java –jar hudson.war”, I’ve attached it here for you convenience, just copy it to the hudson folder

3.    Run the file and wait for hudson to start

Hudson configuration

4.    You can now access hudson on: http://localhost:8080/

5.    Make sure you check the maven plugins(x3)

maven plugins

6.    Click Install on the bottom of the page

maven plugins

7.    It will take a while… you can take a break while it finishes 🙂

8.    Click Finish when it is done

Hudson
9.    Hudson is now ready 🙂

Hudson

10.    Click on New Job link and name it CI

Hudson

11.    On the configuration page, under Advanced Project options check the Use custom space checkbox and paste in the path to your project folder

Hudson

13.    Click Save

14.    Run the build and check the status

Hudson

15.    Congrats, you are all done, now you can move along to add all of sorts of tests in your newly configured CI

16.    You can also setup hudson to run as a service, instructions are here:

http://wiki.eclipse.org/Hudson-ci/Installing_Hudson

 

Daniel Nistor

Daniel Nistor

Senior QA Engineer

Daniel Nistor is a Senior QA Engineer at 3Pillar’s Timisoara, Romania office. Daniel’s responsibilities include planning, preparing and executing software quality assurance manual and automated procedures as per industry standards. His expertise includes working on multiple QA toolsets like QTP (Quick Test Professional) and Selenium Webdriver. In his free time he likes riding his bike, listening to music, and going out with his dog.

One Response to “How to Set Up Continuous Integration with Eclipse, Selenium Webdriver, Maven and Hudson”
  1. Siva on

    Hi Daniel,

    Thanks a ton for such a wonderful article.

    Regards
    Siva

    Reply
Leave a Reply

Related Posts

4 Reasons Everyone is Wrong About Blockchain: Your Guide to ... You know a technology has officially jumped the shark when iced tea companies decide they want in on the action. In case you missed that one, Long Isl...
3Pillar Recognized as a Leading Experience Designer by Forre... Fairfax-based product development company named to its second Forrester report in 2018 FAIRFAX, VA (June 18) - Today, 3Pillar Global, a global cust...
3 Cloud Optimization Projects That Will Pay for Themselves i... AWS introduced 1,430 new features and tools in 2017, including 497 in the 4th quarter alone. This means that it can be a challenge for even the mos...
The Connection Between Innovation & Story On this episode of The Innovation Engine, we'll be looking at the connection between story and innovation. Among the topics we'll cover are why story ...
Go Native (App) or Go Home, and Other Key Takeaways from App... I just returned from my first WWDC. I feel like I learned more in a week at Apple’s annual developer’s conference than I have in years of actually dev...