Skip to main content

Install Jenkins and configure it to Run Maven with TestNg Selenium

Steps to Install Jenkins and configure it to Run Maven with TestNg Selenium


Installation
Step 1) Go to http://jenkins-ci.org/and download correct package for your OS. Install Jenkins.
Step 2) Unzip Jenkins to specified folder. Run exe file as shown in following screenshot:
Step 3) In Jenkins 1.607 Setup window click on Next button.
Step 4) Click on Install button in the end.
Step 5) Once installation is done, navigate to the Jenkins Dashboard (http://localhost:8080 by default) in the browser window.
Step 6) Click on the New Item link to create a CI job.
Step 7) Select the Maven project radio button as shown in the following screenshot:
Using the Build a Maven Project option, Jenkins supports building and testing Maven projects.
Step 6) Click on OK button. A new job with name "WebdriverTest" is created in Jenkins Dashboard.
Step 7) Go to Manage Jenkins => Configure System as shown in the following screenshot.
Click on JDK installations and configure JDK as in the following screenshot:

Step 8) Go to the Build section of new job.
  • In the Root POM textbox, enter full path to pom.xmlin
  • In Goals and options section, enter "clean test"

Step 9) Click on Apply button.
Step 10) On the WebdriverTest project page, click on the Build Now link.
Maven will build the project. It will then have TestNG execute the test cases.
Step 11) Once the build process is completed, in Jenkins Dashboard click on the WebdriverTest project
Step 12) The WebdriverTest project page displays the build history and links to the results as shown in the following screenshot:
Step 13) Click on the "Latest Test Result" link to view the test results as shown in the following screenshot:
Step 14). Select specific build, and you will see the current status by clicking on "console output".

Scheduling Jenkins for automatic execution.

Scheduling builds(Selenium Tests) is one of the important features of Jenkins where it automatically triggers the build, based on defined criteria. Jenkins provides multiple ways to trigger the build process under the Build Trigger configuration.
For example:
Enter 0 23 * * * in the Schedule textbox as shown in the following screenshot. This will trigger the build process every day at 11 p.m.

Using Jenkings without Maven

To run pure TestNg script in Jenkins, enter the following in build
D:>java -cp "Pathtolibfolder\lib\*;Pathtobinfolder\bin" org.testng.TestNG testng.xml
  • Click on Save button.
  • Note: The actual path of lib and bin folder need to add in above command.
  • After saving the command, Jenkins will build project in predefined time, and this command will be run using TestNG.
  • Result will be stored in custom report HTML file that can be sent via email with a Jenkin configuration
  • Output of the code will be

Benefits of using Jenkins

  1. Early issue finding – Bug can be detected in early phase of the software development
  2. Automatic integration – no separate effort required to integrate all changes
  3. Installer – a deployable system available at any point of development
  4. Records – part build records maintained
  5. Support and Plugins: One of the reasons for Jenkin's popularity is the availability of large community support. Also, lots of ready-made plugins are available which help you expand its functionality.

Comments

Popular posts from this blog

API Testing With Selenium WebDriver

REST API Testing Framework We will be creating a simple Rest Testing Framework in Java and JUnit that could be used for any testing scenarios. Rest Testing Framework Overview The framework should be able to execute the basic REST operations (GET, POST, PUT, PATCH, DELETE) and perform the validations on the code, message, headers and body of the response. The completed code can be accessed from my  GitHub account   from where you can collect and make modifications based on your requirements. Design We will be having three classes for the framework (in package com.axatrikx.controller ) RestExecutor  : Performs the HTTP operations using Apache Http Client RestResponse  : A javabean class to hold our response values (code, message, headers, body) RestValidator  : Validates the response with the expected values The package  com.axatrikx.test  holds the test scripts. Note: I will be using ‘ json-server ‘ to fake the REST API. Its a real handy tool to r

ExtentReports in Selenium Webdriver

ExtentReports in Selenium Webdriver What is ExtentReport? ExtentReports  is a HTML reporting library for Selenium WebDriver for Java which is extremely easy to use and creates beautiful execution reports. It shows test and step summary, test steps and status in a toggle view for quick analysis Download Download the jar below: Download ExtentReports 1.4 (1623)    Snapshot of Extent report After Executing the Script   Program Steps:  We are going to write three different testcases. Pass Warning Fail TestCase with Pass Result Navigate to http://www.guvi.in Click on Sign-in Enter the credientials Check the URL is correct or not after login   TestCase with Warning Result Verify with the Wrong URL (static String Afterloginfail="http://www.guvi.in/ ")    TestCase with fail Result Click on Menu Select Tech Challenges Verify With wrong URL. Source Code: import  java.io.File; import  java.io.IOException; import   java.sql

How to Compare Two Images in Selenium

How to Compare Two Images in Selenium Some time in testing we have to do image comparision as verification point. So, in this blog I expalin how to compare two images in selenium. I have created one function for compare two images. you can use directly into your framework. first of all you have to import below packages into your code. import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; Now, you can use below function for comparison of two images. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 public boolean mCompareImages ( BufferedImage img1 , BufferedImage img2 ) { boolean bCompareImage = true ; try { if ( img1 . getWidth () == img2 . getWidth () && img1 . getHeight () == img2 . getHeight ()) { for ( int i = 0 ; i < img1 . getWidth (); i ++) { for ( int j = 0 ; j < img1 . getHeight (); j ++) { if ( img1 . get