Here’s a mechanism to shorten the setup time for automated tests using Selenium inside a Jenkins pipeline
Something you often hear about Continuous Integration (CI) is that it helps identify problems earlier, but does it really? CI is a practice whereby a team of developers integrates code changes as often as possible, sometimes even several times a day. The idea behind this workflow is that by doing this, you can avoid the problems that arise when having to integrate multiple branches in a hurry, in order to meet a deadline. By reducing the time between branching and merging, the codebase isn’t allowed to change underneath our feet or at least not much, making the process of integrating changes much smoother.
But, CI by itself does not help identify problems earlier. It’s the tests that you add to run along the CI pipeline that do. Testing is CI’s best friend, since CI can be summarized as automatically validating that your code meets certain quality expectations.
At Abstracta, we often find ourselves working with the same recommended tool stack for different clients, and so, we got to thinking, how could we get test automation set up and running in CI/CD even faster?
In this post, we will share with you a helpful resource we’ve put together to help you save time.
Why Automate Testing in CI/CD?
First of all, let’s talk about why it’s so important to set up test automation in a CI/CD environment. The graphic below shows what the CI process entails:
In CI, there is a separate server which fetches the new changes from the source control server which makes a new build and tests it for each change in the code. This is done frequently, at least once a day, if not more.
When teams prepare the build automatically, they run the different tests that they’ve prepared and everyone receives a notification if anything has gone wrong or if everything is okay with the new build.
Every single test that runs alongside your pipeline adds robustness to the code that is entering your branch. Take automated Selenium UI tests for example, you can automatically add checks to see how your web app’s latest build has modified its behavior to avoid any unexpected outcomes. Or maybe you want to run some Gatling tests against your application to check that the new version hasn’t suffered any performance degradations.
The possibilities are endless, but the core idea is that the more testing you integrate into your CI pipeline, the better the quality of the product coming out of it will be.
This doesn’t mean that continuous integration is easy or quick to prepare and assemble. It’s not. When it comes to getting started, there’s a plethora of tools to choose from for almost every single task you would want to do inside your pipeline. There’s also quite a deal of setup that must take place beforehand.
We recommend using Ansible, as it’s a really powerful tool for managing configuration and provisioning on your servers, since it allows you to describe its desired state and then it takes care of making it happen for you. The way to use Ansible is by writing playbooks which are YAML files describing the desired state we just mentioned. One such playbook is what we we are sharing with you in this article.
We’ve made a playbook for provisioning a Jenkins server so that you don’t have to deal with the installation and setup process.
Why did we do this? Many times, a client of ours is already using Jenkins for some process inside their organization and wants to add test automation to an existing pipeline or by itself. Other times, they aren’t using the tool yet, but see its value and want to start running their tests using Jenkins and keep track of the results.
Whatever the case is, we will often find ourselves setting up pipelines to run tests or setting up Jenkins servers, so we decided we should streamline that process in order to get up and running within minutes instead of hours, giving us more time to focus on adding more and different tests in order to help improve the quality of the product.
Access the Playbook
You can head over to Abstracta’s Github repository which has a getting started section to help you get a feel for what you can do with these tools. This guide will walk you through the process of setting up your first Jenkins pipeline to run Selenium tests.
If you want to dive deeper, we have a few “How To” guides (that we are still adding to) in order to help you solve common problems often faced when building Jenkins pipelines.
We believe that teams should automate as much as possible in order to improve the effectiveness and efficiency in the process of adding value to the business and to users. We presented here a very easy way to have an automated pipeline with Jenkins and different testing tools, even if you have never heard of Ansible, Jenkins or Selenium.
We hope this helps you to adopt what we believe is part of the foundations of a modern software development process.
Recommended for You
Why is Automation essential in Shift-Left Testing?
It is a fact. When it comes to Shift-Left Testing, automation is an indispensable ally. But how does Shift-Left Testing specifically benefit from automation? Why is it not possible to perform Shift Left Testing without it? Find out in this article written by Matias Fornara….
Quality Sense Podcast: Bas Dijkstra – False Positives and Negatives in Test Automation
In this Quality Sense episode, Fede has a chat with Bas Dijkstra, a software test automation expert, consultant, and trainer from the Netherlands with over 14 years of experience in the field. Recently, Bas triggered an interesting conversation on Linkedin about software testers getting involved…