Wikipedia

Search results

Friday, 8 August 2014

How to Set Up Continuous Integration with 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

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:
Just make sure the versions for:
selenium-java
                2.42.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

No comments:

Post a Comment