CI (Continuous Integration) & CD (Continuous Delivery) has been gaining a lot of attention and is the most hyped topic in the technology world. It helps the companies to ship their products quickly and efficiently. Initially it was difficult to implement CI/CD in projects but now with a lot of tools available in the market, it is becoming quite easy to make your project implement continuous integration with ease and speed.
Among all the different types of tools available in the market, the most used one is Jenkins. In fact, as per Slintel data, Jenkins has a market share of 47.69%. But we can’t avoid the fact that some more tools like Bitbucket, CircleCI, TeamCity are also claiming their existence gradually.
The point to gain attention here is the use of Selenium tests in Jenkins. With the feasibility of CI/CD, a team would want the regression suite designed with Selenium to execute each time there is change in software code. To achieve the same, we need to integrate our automation suite into CI/CD tools to schedule the run.
Why we need CI/CD integration with automation testing
Due to the Agile process and frequent changes in features, the number of builds provided by developers has been exponentially increased. Continuous integration involves committing code changes to master regularly, triggering a build if applicable and testing the software each time.
To really get the benefits of CI, your team members should aim to commit changes at least daily. However, even on a small team, doing this level of CI/CD automation testing manually would involve a huge amount of repetitive work tasks. This is where the automated testing comes in.
If you’re manually running 10 builds a day at 10 minutes each, that’s 100 minutes wasted in deployment! Furthermore, testing the same again would be tedious, and due to multiple release cycles the quality would be compromised.
The above mentioned approach not only puts the developers behind the schedule, but it’s also going to impact their attempts to push changes to production due to delay in testing and at the end it will reduce the company’s bottom line with new products and features. So to resolve the same, we need to come up with processes which can help us to automate the deployment and testing process on the go, just like Jenkins pipeline does in the release cycle.
One of the major roles of CI/CD integration is when the team is working in multiple time zones. Working in different time zones increases the duration of testing without CI/CD. If the developer team pushes the code in PST, and then if the testing team works from IST, it will take the QA another 12 hours to start testing. So instead of manually testing or triggering the automation suite, we can use the CI/CD pipeline to trigger our automation suite after the code is being pushed by developers.
Steps to integrate AutomationSuite with Jenkins
In this section, we will integrate the Automation Suite with Jenkins job, so that whenever required we can trigger our test suites from the pipeline or even schedule the same. Remember that in the below demo we are using testNG.xml suite and the framework is designed with Maven pom.xml.
Prerequisite for running :
– Automation suite in testNG.xml
– Jenkins server access with valid credentials
Integrate testNG.xml suite with pom.xml. To do that, we have to pass the path of testNG.xml suite inside the suiteXmlFiles tag. We need to remember that the path which has been provided here is the path of testNG.xml suite used in our project, so you need to use the path as per the suite located on your setup. Instead of Regression we can also pass the path of Smoke, Sanity, BVT or Confidence suite.
<suiteXmlFile> tag of pom.xml:
To get the entire pom.xml with dependencies required in Selenium Automation Framework, refer the link below:
Go to your Automation project path and open the command prompt. As shown below, project name is “Task” and we have opened cmd @project location:
Enter maven goal for test as: “mvn clean test” in the command prompt and hit ENTER. This will execute all the test scripts present in our suite and provide the execution status. This step is very important before starting the integration with Jenkins.
If it fails while running in the command prompt then we need to make sure to fix all the issues before moving it to the Jenkins server.
Go to Jenkins, click on New Item as shown in below screenshot. This new item will help us to create a new Jenkins job where we can integrate the automation suite which has all the test scripts for the regression suite.
Provide the name for the job, in the below screenshot we have provided the project name as “UiAutomationG11” and select “Maven Project” click on OK button. We need to release that as our automation framework is in Maven so we are selecting Maven project, if you are using Gradle then you have to select accordingly.
Note: Always provide a meaningful name to the project with proper naming convention.
Go to Build Select “Invoke top-level Maven targets”, then enter the Goals as “clean test”, and put the pom.xml path of your project in the “POM” section as shown below. Now click on the “Save” button which is in the left bottom section.
Remember that as we are using it for demo so our pom.xml is in our local machine and we are providing path of the project in the POM section, but if you are trying to implement at project level then you need to integrate your GitHub repo link in Jenkins so the code will be pulled from repo directly.
To run the suite, click on the Build Now button as shown below, once you click it will trigger the automation suite and test scripts will get executed. After the execution will get completed we can see the status of the job run, and if it fails then the console output can be used to get the error logs for further fixes.
The most important benefit that the team will achieve is attaining the quality with the utmost pace. Below are some of the most important benefits of continuous integration with Automation Testing:
Faster release cycle
Pacing up the build and testing cycle will allow the team to get new features into production quicker. It also helps to reduce the testing execution exponentially by triggering from the pipeline. Pipeline helps the organization to accelerate the release rate.
Any software development process that includes continuous testing is on its way toward establishing a critical feedback loop to go fast and build effective software by making the automated suite part of the pipeline. As we run our suite after every change done by the developer team, it always provides a quality check of each and every code pushed to the code base. Most importantly, the pipeline with continuous testing builds quality into the CI/CD pipeline and reduces risk and waste in the software development lifecycle.
Integration of automation with the pipeline helps to put a check on code changes. If the tests fail, we can easily rollback the changes to working state. In most of the cases, we basically rollback to the last successful build.
Automated testing plays a key role in any CI/CD pipeline. Although creating automated test suites will take some time & money, making it part of the pipeline to run a check on every deployment soon pays for itself.
Whenever developers make some changes to the code base, pipeline integration helps to run the regression and make sure that new changes haven’t impacted the existing features. So apart from validation, the automation in the pipeline provides confidence to the development team.
In the current market scenario, if you are trying to move to a product company or SDET role, then knowledge in CI/CD is a very important attribute. If you want to explore opportunities in a similar field, do check Talent500
Talent500 helps to hire, build & manage globally distributed workforces, and has a large number of career-defining opportunities for tech professionals such as you.