How to create JUnit Report in Jenkins

Last Updated On

HOME

In this tutorial, we show you how to generate JUnit Report Using Jenkins. In the previous tutorial, we generated a TestNG Report using Jenkins.

Table of Contents

  1. Prerequisite
  2. Implementation Steps
    1. Start the Jenkins server
    2. Create a new FreeStyle project
    3. Build Steps
    4. Provide the full path to pom.xml
    5. Select “Publish JUnit test result report” from “Post Build Actions”
    6. Execute the tests
    7. View the JUnit Report

Prerequisite

Jenkins installed and started on the computer

To generate JUnit Report, please refer to this tutorial to get the code – How to generate JUnit4 Report.

To generate a JUnit Report in Jenkins, we need to download the JUnit Plugin. Please refer to this tutorial to install the plugin – How to install Plugins in Jenkins

Implementation Steps

Step 1: Start the Jenkins server

Start the Jenkins server open the browser and navigate to the below endpoint

http://localhost:8080/

Step 2: Create a new FreeStyle project

  1. Give the Name of the project – JUnitReport_Demo
  2. Click on the Freestyle project. 
  3. Click on the OK

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

Select a custom workspace and provide the full path of the project.

Select Source Code Management as None if the project is locally present on the machine

Step 3: Build Steps

In the Build Steps section, select Invoke top-level Maven targets.

The Build Steps window will extend. Mention the below details:-

Maven Version – MAVEN_HOME

Goals – clean test

Click on the Advanced button.

Step 4: Provide the full path to pom.xml

Specify the full path to pom.xml in POM.

Step 5: Select “Publish JUnit test result report” from “Post Build Actions”

Scroll down to “Post Build Actions” and click on the “Add Post Build Actions“drop-down list. Select “Publish JUnit test result report“. 

Enter the Result Path as “**/target/surefire-reports/*.xml”.

Click on the Apply and Save buttons.

We have created a new Maven project JUnitReport_Demo” with the configuration to run the Selenium with JUnit Tests and also to generate JUnit Report after execution using Jenkins.

Step 6: 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 #2).

Click on Console Output to see the result.

Step 7: View the JUnit Report

Once the execution is completed, we could see a link to view the “Test Report“.

Below is the summary of the Test Execution.

This way, we could generate JUnit Report using Jenkins.

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

Additional Tutorials

Jenkins GitLab Integration
How to create Jenkins pipeline for Selenium tests
How to create Jenkins pipeline for Serenity tests
How to generate TestNG Report in Jenkins
How to create Jenkins pipeline for Extent Report
How to run parameterized Selenium tests in Jenkins

Leave a comment