Run Calculator JUnit tests using Jenkins [ 2024 ]
Run Calculator JUnit tests using Jenkins.
In this post, you will learn how to run Calculator JUnit tests using Jenkins CI. Let’s build a Maven project with Calculator tests and configure the project in Jenkins CI.
Jenkins is an open-source automation server that continuously builds, tests, and deploys software. It enables developers to automate repetitive tasks and integrate changes quickly, enhancing productivity. To get started with Jenkins CI :
Prerequisites
Ensure that you have Jenkins installed and running. The steps to install Jenkins are as follows:
Ensure Java and Maven are installed on your Jenkins server.
Install Required Plugins
Go to Manage Jenkins > Manage Plugins and install the required plugins.
- JUnit Plugin: JUnit Plugin provides the capability to publish JUnit test results.
- Maven Integration Plugin: This plugin helps run Maven goals and publish test results.
Calculator Tests
Sample Calculator JUnit tests can be found here:
Create Maven Project
Create a Maven project using the quickstart archetype:
Configure Maven Project in Jenkins
Launch Jenkins.
Create New Project >> Click on New Item.
Configure Build Steps
Configure the project details. In the Build section, click the Add build step.
Specify pom.xml in the project. Specify the Maven goals for the build:
clean install
Click on the Save button.
Post-Build Actions
Scroll to the Post-build Actions section. Click Add post-build action and select Publish JUnit test result report. In the Test report XMLs field, enter **/target/surefire-reports/TEST-*.xml. This is the default path for Maven test reports.
Click Save to save the configuration.
Build the Project
Once you finish the configuration, click the Build Now link to run the project. Alternatively, you can schedule the build project.
Console Output
The console output windows display the project’s build information.
View Test Results
After the build is complete, you can view the test results by clicking on the build number and selecting Test Result from the build’s page.
Click on the Test Result link to view the JUnit test results of the build.
Jenkins Tutorials
Jenkins Tutorials on this website can be found at:
For more details on the Jenkins CI, visit the official website at: