How to generate TestNG Report in Jenkins

HOME

In the previous tutorial, we have seen the Integration Of Jenkins With Selenium WebDriver. In this tutorial, we show you how to generate TestNG Reports Using Jenkins. 

Pre-Requisite:-

Jenkins installed and started on the computer

Implementation Steps

Step 1: Start the Jenkins server and open the browser and navigate to the localhost and the port in which Jenkins is running

http://localhost:8080/

Step 2: Log in to Jenkins UI

Provide a username and password and click on the Sign-in Button.

Step 3: Download and Install TestNG Results Plugin

Click on the Manage Jenkins. Choose Manage Plugins.

Step 4: Add the TestNG Report plugin

On the Plugins Page, go to the Available option

  1. Select the TestNG Report Plugin
  2. Click on Install without restart. The plugin will take a few moments to finish downloading depending on your internet connection, and will be installed automatically.
  3. You can also select the option Download now and Install after the restart button. In which plugin is installed after the restart
  4. You will be shown a “No updates available” message if you already have the TestNG Report plugin installed.

The plugin “TestNG Report” has been installed successfully.

Sometimes, the installation fails because of a network issue. You can try to reinstall it, and it should be successful.

Step 5: Restart Jenkins

Click on the checkbox “Restart Jenkins when installation is complete when no jobs are running“.

The Jenkins will be restarted. Again, login to Jenkins UI.

Step 6: Create a new project using the Maven project plugin.

  1. Give the Name of the project.
  2. Click on the Maven project. 
  3. Click on the OK button.

In the General section, enter the project description in the Description box.

Step 7: Build Management

Go to the Build section of the new job.

  1. In the Root POM textbox, enter the full path to pom.xml
  2. In the Goals and options section, enter “clean test

Click on the Advanced button.

Step 8: Select custom workspace

Mention the full path of the project in the directory.

Step 9: Select “Publish TestNG Results” from “Post Build Actions

Scroll down to Post Build Actions’ and click on the ‘Add Post Build Actions’ drop-down list.

Select “Publish TestNG Results“. 

Enter the TestNG XML Report Pattern as “**target/surefire-reports/testng-results.xml” and click on the “Save” button.

We have created a new project TestNGReport_Demo” with the configuration to run TestNG Tests and also to generate TestNG Reports after execution using Jenkins.

Step 10: Execute the tests

Let’s execute it now by clicking on the “Build Now” button. 

Right-click on Build Number (here in my case it is #4) and click on Console Output to see the result.

Once the execution is completed, we could see a link to view ‘TestNG Results’.

Step 11: View the TestNG Report

Click on the TestNG Results. It displays the summary of the tests.

This way, we could generate TestNG Reports using Jenkins.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s