Last Updated On
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
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
Step 2: Create a new FreeStyle project
- Give the Name of the project – JUnitReport_Demo
- Click on the Freestyle project.
- Click on the OK
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-18.png?w=1200)
In the General section, enter the project description in the Description box.
Select a custom workspace and provide the full path of the project.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-30.png?w=1200)
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-19.png?w=1200)
Select Source Code Management as None if the project is locally present on the machine
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-20.png?w=1000)
Step 3: Build Steps
In the Build Steps section, select Invoke top-level Maven targets.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-21.png?w=931)
The Build Steps window will extend. Mention the below details:-
Maven Version – MAVEN_HOME
Goals – clean test
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-22.png?w=1200)
Click on the Advanced button.
Step 4: Provide the full path to pom.xml
Specify the full path to pom.xml in POM.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-23.png?w=1200)
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“.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-24.png?w=985)
Enter the Result Path as “**/target/surefire-reports/*.xml”.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-25.png?w=989)
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.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-27.png?w=1106)
Step 6: Execute the tests
Let’s execute it now by clicking on the “Build Now” button.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-29.png?w=360)
Right-click on Build Number (here in my case it is #2).
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-34.png?w=346)
Click on Console Output to see the result.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-80.png?w=997)
Step 7: View the JUnit Report
Once the execution is completed, we could see a link to view the “Test Report“.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-32.png?w=1036)
Below is the summary of the Test Execution.
![](https://qaautomation.expert/wp-content/uploads/2022/12/image-33.png?w=1200)
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