Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

October 8, 2015

Selenium Integration With Jenkins

October 08, 2015 4
In this post i am going to explain how to integrate with continuous integration tool Jenkins..

Prerequisites:
Here i am trying to run Maven project scripts so

  1. Maven Project with TestNG (you can go through this post  create-sample-maven-project.html)
  2. and few webdriver scripts
  3. Downlaod Maven Project from Here....
Download Jenkins:

1. Navigate ti http://jenkins-ci.org/
2. Download .war file

3. Save the jenkins.war file in any of the location, you need to run this Jenkins.war file.


Set Up Jenkins:

1. Navigate to folder where you kept your jenkis.war
2. type command java -jar jenkins.war and press Enter

3. Will take some time to extract Jenkins, then you will get a success message.
4. By default Jenkins will start in port number 8080
5. For Jenkins UI use this URL in browser http://localhost:8080/



Configure Jenkins:

Before creating any Jenkins job we need to perform some configuration steps.
1. Click on Manage Jenkins link on the left side of the page
2. Click on Configure System.
3. Navigate to JDK section and Click on Add JDK button
4. Uncheck Install automatically check box so Jenkins will only take java which we have mention above
5. Give the name as JAVA_HOME and Specify the JDK path


6. Add Maven. IF you already not downloaded maven, get it from here Download Maven


6. Click on Save button.


Create Jenkins Job:
1. Click on create new Jobs.
2. Enter Job description and select Maven Project
3. Go to Build section and Enter path of POM.xml in ROOT POM text box.
4. Click apply and Save,



Run Job:
Navigate to Home page of Jenkins, there you can see new Job is created. Click on Build now symbol

Maven will build the project. It will then have TestNG execute the test cases
Once the build process is completed, in Jenkins Dashboard click on the Job1 project






August 18, 2015

Create a Sample Maven Project

August 18, 2015 17
In this post i would like to discuss about Maven.

Here are few basic questions:

What is Maven?
What are the advantages of Maven.
How to use Maven in Selenium projects.
How to Create a maven project?


What is Maven:
Maven -- is a build tool and it is mainly used for Java projects. 
Maven is used to manage dependencies.
For example if you are using selenium latest version 2.47.1 and later point of time if you have to upgrade to newer version of selenium, then it can be manged very easily by using Maven dependencies.

What are the advantages of Maven.

It is a build tool, so it is used to setup everything which is required to run your java code independently.

Maven provides pom.xml which is core to any project.

Maven is used to manage dependencies.

Maven is a plugin for many of IDEs. (Eclipse, Netbeans, IntelliJ etc..)


Frequently used terms in Maven:

GroupID:
Group id refers to domain ID. For example you can use company name as groupID.

Artifact ID:
Name of the project. what ever the name you provide in artifact ID it is nothing but your project ID.

Local repository:

Maven downloads all required jar files and stores in local repository with folder name .m2 (C:\Users\username\.m2)


Maven Set Up:

Pre-requisites:
Make sure Java is installed
Make sure Java_Home and path are set under environmental properties.
Latest version of eclipse (Luna or Mars)

If you are using Luna or Mars you need not to install Maven plug in, bcs maven plug in is already installed in these versions of Eclipse EclipseIDE 


Verify Maven is already installed or not.
1. Open Eclipse, Click on Help ----> select About Eclipse..a window will open.

if you see m2 symbol there ..that means maven is installed.




Create Maven Project:

1. File ---New --Other ---Expand Maven and select Maven Project



2. Click Next in "New Maven Project Screen"

3. select "maven-archetype-quickstart" from list of artifacts. (be default quickstart will be selected)
4. Enter Group ID, Artifact ID Click Finish

5. Once you created a project in eclipse you can see the project




Add Dependencies:

Open pom.xml
Click on pom.xml tab
Add a testNG dependency.

  1. Navigate to MavenRepository and search for TestNG
  2. Select the desired version.
  3. Copy testNG dependency and paste it in pom.xml



4. Add Selenium related dependencies.

http://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/2.47.1


org.seleniumhq.selenium
selenium-java
2.47.1



org.seleniumhq.selenium
selenium-server
2.47.1

Allow some time to download those Jar files and these files will be automatically added to your project. Files will be stored under .m2 folder (C:\Users\username\.m2)

Now you can write your normal Selenium-TestNG program and run the script.





If you want to run test case from maven you need below dependencies:
Pre requisite: Create a testNG test suite. 


Add below plugins to POM.xml

  1. maven-compiler-plugin
  2. maven-surefire-plugin
  3. testng.xml
The maven-surefire-plugin is used to configure and execute tests. Here plugin is used to configure the testing.xml for TestNG test and generate test reports.

The maven-compiler-plugin is used to help in compiling the code and using the particular JDK version for compilation. Add all dependencies in the following code snippet, to pom.xml in the node

Maven-Compiler-plugin:

http://maven.apache.org/plugins/maven-compiler-plugin/usage.html

Maven-sure-fire plugin:
http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html


To run your test cases:

Right click on POM.xml--Run As ---mvn test

scripts which are in testNG.xml will be executed and results will be available under:
Project---target---surefire--report






POM.xml looks like this:










August 13, 2015

Introduction To Jenkins (Continuous Integration Tool)

August 13, 2015 1
In this post i would like to give some information what ever i know about Jenkins.

Frequently asked questions :

What is Jenkins?
What is Continuous Integration?
How to set up Jenkins?
Jenkins is it only for Developers or can testers also use it?
I am a Automation tester how can i use Jenkins?
What benefits / advantages i will get after using Jenkins?

In this article i am going to answer all the above questions...

What is Jenkins?

A simple answer every body gives to this questions is .... Jenkins is a Continuous Integration tool.

Jenkins is an open source tool to perform continuous integration. The basic functionality of Jenkins is to execute a predefined list of steps based on a certain trigger.

You can get more information about Jenkins here ...

About Jenkins

What is Continuous Integration? (CI)
CI is nothing but running your tests (unit tests /automation tests) automatically every time someone pushes new code into the source repository.

Ex:
If you are an automation tester and when you push some code to your source repository (SVN, GIT etc..) then your automation test cases will run automatically (if you configure like that) and will give you results. It gives you fast feed back about your test suite.

The fast feedback is important so you always know right after you broke the build . What you did that failed and how to revert it.

What benefits / advantages i will get after using Jenkins?
There are many advantages
1. When it is run automatically on every push then it is always pretty obvious what and who introduced the problem
2. Solves problems quickly
3. Automation of deployment.
4. Automated testing and Code control
5. Enables better project Visibility

Jenkins is it only for Developers or can testers also use it?

Jenkins is not only for developer even automation tester also can use Jenkins to test their automation scripts after each commit made by a team member or they can schedule their automation jobs to run daily at specific time.

How to set up Jenkins?

Here is the link to Create Jenkins:

Selenium-integration-with-jenkins.html

I am a Automation tester how can i use Jenkins?

Coming soon...