- Selenium is used for testing and automating the web applications. We can run our tests with CI/CD tools such as Jenkins. In this blog we will see Jenkins Integration and reporting using Selenium 4.
Why is Jenkins integration required?
- Test automation helps us with continuous defects, errors, and bugs as early as possible. Earlier the issue is found, cheaper it is to fix it.
- With CI/CD integration this is possible, where we can run our tests after every build or after a set interval of time which will help us identify any issues.
- It is always faster to test the service manually or to run the regression manually. As it will run automatically without any human intervention. And a report will be generated at the end of it.
- So, that we can see if any tests are failing or not. If failing they can be easily fixed.
Requirements
- Jenkins
- JDK
- Maven
- Selenium project
Setting up Jenkins
We will be using a maven project and pom.xml class to execute our test. To do that we will be required to configure JDK and Maven in Jenkins.
- Log in into Jenkins and go to Manage Jenkins.

- Go to Global Tool Configuration.

- Go to JDK and click on Add JDK.

- Here you have 2 options either install it automatically by selecting a checkbox (Install automatically), selecting the version and entering your oracle account details. You are required to have a valid oracle account.

- Or you can unselect the checkbox and provide the name and path to your local JDK.

- Go to maven and click on Maven installations.

- Here you have 2 options either install it automatically by selecting a checkbox (Install automatically) and selecting the Maven version that you want.

- Or you can unselect the checkbox and provide the name and path to your local MAVEN_HOME.

- Save the configurations
- Again go to Manage Jenkins and click on Manage Plugins.

- Search and install: Maven Integration plugin for integrating a Maven project with pipeline and TestNG Results Plugin for generating reports.
Setting-up freestyle project
- Once plugins are installed go to Jenkins dashboard and create a new freestyle project.
- In the GIT section provide the link to your repository for cloning it automatically. If the repository is private then add your Git credentials else leave it as none.
- Go to the build section and Add the build step for Invoke top-level Maven targets.
- In the goals, section enters the following command.
clean test

- Normally a Maven command starts with mvn. But because we have already added a step to identifying this as a maven project so, we don’t need to add it. It will process this command as mvn clean test.
- Go to Post-build Actions and select Publish TestNG Results.
- This is to generate a report which will be stored after each run for a more detailed analysis.
- In the TestNG XML report pattern enter:
**/testng-results.xml
- Save the Jenkins project and click on Build now.

- Generated report.


- So, this is a short blog on how we can achieve Jenkins Integration and reporting using Selenium 4. See you in the next one.