Blogs

Get useful information on apps testing and development

Role of Containerization in Automation Testing

Sidharth Shukla | Posted on | 2 min Read

Role of Containerization in Automation Testing

In the present world the demand for containerization has been exponentially increased, and the reason behind it is quite the same. Containerization has completely revolutionised how organisations develop and manage complex applications. The ability to enhance application scalability and reduce overhead has now made it the industry standard deployment over the previously used traditional monoliths. In this post we will explore Containerization and explore Docker since it is synonymous with Containers. Along with that we will also learn how we can use containers for different scenarios related to Automation testing. The most important point which needs to be considered is that Containerization is not for testing but it is used in every phase of Software release life cycle. Let’s deep dive to containerization and explore ways to implement the same for testing.


What is Containerization?


Containerization in simple terms is the packaging together of software code with all its important components like libraries, frameworks, and other dependencies so that they are isolated in their own “container.” This is so that the software or application within the container can be moved and run consistently in any environment and on any infrastructure, independent of that environment or infrastructure’s operating system. The container acts as a computing environment surrounding the application and keeping it independent of its surroundings. It’s basically a fully functional and portable computing environment.


Docker For Containerization


One strange thing is that the idea of process isolation has been around for years in the industry, but when Docker introduced Docker Engine in 2013, it set a standard for container use with tools that were easy for developers to use, as well as a universal approach for packaging, which then accelerated the adoption of container technology Due to the Docker containerization has been widely implemented with ease for software releases.  If we go with the definition then Docker is a set of platform as a service products that uses OS-level virtualization to deliver software in packages called containers. The software that hosts the containers is basically called Docker Engine.


Containerization in Automation Testing


In recent market use, the practice of containerization has increased exponentially. In almost all types of automation we can find Docker implementation. In this section we will discuss the areas where containerization can be used.   Lets first take Web Automation Testing and check how we can docker with web automation. The best use of containerization in web automation is based on integration of docker with selenium grid. It basically helps to perform parallel & cross browser testing with less time.  To implement the same we need to take help of some docker images as mentioned below: Before proceeding further and working on setup make sure to install docker: Download docker in windows HERE. Go to docker hub link and search for images to pull into your local machine:  

Firstly let’s pull all the below three images using docker cmd:



Now simply we can run below three commands to create the containers from the images downloaded



Once containers are created we can pass the path of hub in the webdriver instance as shown below:



Now we are all set to run the web automation selenium test scripts using containerization for parallel execution. We will take one more example of containerization usage in Automation, and the automation type is Mobile Testing. Basically in Mobile Automation containers can be used for many scenarios, but we will check one example where we will try to create emulators by using Docker image for Appium Android Emulator. Without this approach, we need to do each of the automation setup steps manually; which can be slow, error prone and also high maintenance efforts.


Pull Docker Image



Run Docker Image



To check android emulator status



Check Logs



Apart from the emulator Mobile device containerization is also happening while executing Appium test scripts in parallel with different emulator setup. We can discuss this topic separately in another post.


Benefits


The simple and  portability characteristic of containers comes from their ability to share the host machine’s operating system kernel, negating the need for a separate operating system for each container and allowing the application to run the same on any infrastructure—bare metal, cloud—even within virtual machines (VMs). Similarly, developers can use the same tools when working with containers in one host environment as they’d use in another, which makes the development and deployment of containerized apps across operating systems much more simple. One of the best things is we do have the flexibility of geographic limitations, and that is possible as the applications are abstracted from the host operating system, they can be launched from any device across different platforms. This makes application deployment consistent, portable and stable. As in recent times, lots of containers are getting used, so to maintain or manage those containers there are many orchestration tools such as Kubernetes, containers can be re-deployed instantly in the event of a server crash or network outage.  No matter where the app is deployed, containers ensure the application remains consistent, resulting in increased productivity, less time troubleshooting, and more time launching and creating new features.


Conclusion


Containerization solves many  problems in continuous testing. Perhaps most useful is that it helps put end-users, testers and programmers on a more level of environment setup  so that  they all see — and test — the same application. This eliminates the problem where some code is working in the developers machine but not working in the QA environment. When we use containers then we can use the same setup for both Dev and QA environments, as a result it reduces the number of loose ends facing a development team.  

Automate with Selenium

Sidharth Shukla

Currently working as a SDET. He is an Automation enabler who provides solutions that mitigates quality risk. Passionate about technical writing and contribution towards QA community.