Integration of Maven/TestNG/Jenkin/Selenium

Steps for achieving complete flow of integration.

  1. Maven project needs to be created

  2. Use test ng [for test cases] and selenium [for automation]

  3. Jenkins needs to configured and browse test cases there

    • Maven Project needs to be created. pom.xml should be proper.

    • Testing classes should be written with testing.xml

    • Jenkins should be installed and integrate with maven

    • Maven Project needs to created pom.xml should be proper



  • Create maven project in Eclipse.

    steps to create a maven project in eclipse

    steps to create a maven project in eclipse

    steps to create a maven project in eclipse

  • Project structure (as shown in below images):

    maven project structure

    add dependency in pom.xml file

  • Go to “pom.xml”

  • Add dependencies for required task.

  • Let’s say we have excel sheet operation then we need to go for jxl dependency.

  • In our case it is selenium jars.

  • Plugin needs to be added for testng integration.

  • Add path of “testng.xml” in “pom.xml” under “surefire” plugin

  • After adding above we can observe below.

  • add plugins in pom.xml file

  • Complete pom.xml will be look like as below.

  • Observe the below folder structure:

  • maven project structure

  • Testng classes should be written with “testng.xml”.

  • Create test-ng test cases for any website, in our example we have taken ‘www.javabykiran.com’.

  • Right-click on test folder and create testng class as shown below:

  • writing testng classes

    writing testng classes

  • Open “LoginTestCase.java”.

  • Write “test cases” code as shown below:

  • Run and test if it is running without maven integration

  • running test cases without maven integration

  • You will see the below shown output:

  • Run and test if it is running with maven integration

  • running test cases maven integration

  • You will see the below shown output:

  • Jenkins should be installed and integrated with maven.

  • Jenkins should be installed and opened in browser as per proper url.

  • jenkins integration with maven

  • Start jenkins from command prompt then open in browser.

  • Create new item

  • jenkins integration with maven

    jenkins integration with maven

  • Observe tabs after creating project.

  • jenkins integration with maven

  • Save all this configuration by clicking ‘save’.

  • jenkins integration with maven

  • After clicking build now you will see the below screen:

  • jenkins integration with maven

  • By clicking on this build now we will get to see what is happening inside this build in console.

  • jenkins integration with maven

  • After this you will see the following results:

  • jenkins integration with maven

How to see reports in Jenkins and why this is required?

While executing our tests on Jenkins many times test fails on particular build. Now if we want to check when a particular test-case, test-class or a test-package has failed we may need to go to each and every build report and check for the result.

This process is very cumbersome and may take a lot of time to get the report. So this plugin solves the above issue by showing the build result history of test-class, test-class and test-package in a tabular tree format. The plugin can be used for enabling the “Publish junit results” or “Publish TestNG results”(in case of TestNG) feature of Jenkins.

It allows users to filter the results based on passed, failed and skipped status.

There are many plugins available of which one is explained below.

test result analyzer plugin in jenkins

test result analyzer plugin in jenkins

Once installed you can just click on the “Test Results Analyzer” link on the left hand side of your job, as shown in the following image:

test result analyzer plugin in jenkin

Explore options on same page you will see many features.

test result analyzer plugin in jenkin