CMS, DevOps & Cloud Solutions, Quality Assurance

How Continuous Testing helps Business to achieve quality

How Continuous Testing helps Business to achieve quality?

Now a days, the customers are expecting products of high quality for their personal use or business purposes. A brand can lose a loyal customer if the purchased product is not enough value for money.  Business demands dynamic software teams having new, innovative, and effective strategies in order to keep pace with competition and expectations. Hence, delivery teams need to innovate and augment their development and testing methods to accelerate releases without losing sight on quality. With Agile and DevOps gaining ground, engineering teams are building features iteratively in smaller requirements and seeking early feedback from business. The success of continuous development is mainly dependent on effective application testing to ensure the high-quality code is deployed and maintained for every release. This technical blog provides insight into continuous testing and its benefits, along with the key components and the testing tools to support CI/CD delivery

 

What is Continuous Testing?

Continuous testing is the process of executing automated tests as part of the software delivery pipeline to obtain immediate feedback on the business risks associated with a software release candidate as early as possible.

The key principles of continuous testing are:

  1. Independent micro atomic test cases
  2. Fully automated test environment
  3. Ability to execute any kind of test cases at any given time.

 

Why Do We Need Continuous Testing?

In Continuous Integration, developers constantly build new features and check-in to the source repository very frequently. Hence, it is very essential to ensure that all such changes are thoroughly validated, so that they do not impact the existing functionality. Moreover, the early the defects caught, the less the time and cost involved to fix them.  This is where, continuous testing plays a vital role as it evaluates the product early and often throughout the software development life cycle. Continuous testing fits very well in Agile and DevOps and easily addresses the complexity and the pace of modern application delivery through test automation.

 

How to achieve Continuous Testing?

There are different tools available in market to support Continuous Testing. Here, in TA Digital, following resources are used to make continuous testing even faster.

  • GIT: Used as a code repository
  • Jenkins: Used for continuous integration to trigger CI/CD pipeline
  • Selenium: Used to automate web applications
  • ZALENDO: A flexible and scalable container-based Selenium Grid with video recording

How to Implement Continuous Testing:

In Jenkins, the best way to achieve CI/CD/CT is to prepare a build pipeline. A build pipeline has the following components.

  • Tool: Pre-requisite needs to be installed before the start of the pipeline
  • Environment: Environment under test
  • Stages: Defines which stage the job is
  • Steps: Defines what that step is about
  • Post: post job completion requirement to be covered

 

Below snippet shows how the Continuous testing is triggered and executed in Zalenium.

pipeline {

    agent any

    tools {nodejs ‘NODE10’}

    environment {

                 GIT_ID = ‘<repo id>’

              GIT_REPO = ‘<GIT repo address of the dev code>’

              BRANCH = ‘QA’

              SONAR_URL = ‘<Sonar server ip address>’

              SONAR_TOCKEN = ‘e5f3e4c9ff8bc7f1796a1b5e642ebea226980e05’

              ADMIN_EMAILS=’<stakeholder emails>’

              PROJECT = ‘<Project name in GIT repo>’

    }

    stages {

        stage(‘Code and Dependencies’){

            parallel{

            stage(‘Checkout Code’){

                steps{

                    git <Checkout dev code >

                }

            }

            stage(‘Install Dependencies’){

                steps{

                    sh ‘npm install’

                    sh ‘npm install wdio-allure-reporter –save-dev’

                    sh ‘npm install -g allure-commandline –save-dev’

                    sh ‘docker pull elgalu/selenium’

                    sh ‘docker pull dosel/zalenium’

                }

            }

            }

        }

            stage (‘Start Zalenium’){

                steps{

                    sh ‘echo “Zalenium Started”‘

                    //sh ‘docker run –rm -ti –name zalenium -d -p 4444:4444 -p 5555:5555 -e PULL_SELENIUM_IMAGE=true -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/videos:/home/seluser/videos –privileged dosel/zalenium start –maxDockerSeleniumContainers –seleniumImageName’                                

                }

            }

 

       stage(‘Unit Test’) {

           steps {

               sh ‘echo “unit test”‘

           }

        }

          stage(‘Sonar Scan’) {

           steps {

               sh ‘echo “sonar scan”‘

               // build job: ‘HRMQASonar’,  propagate: false

                      }

                      }

          stage(‘Deploy Build’) {

             steps {

                 sh ‘echo “Build Deployment & DB Setup”‘

                // build job: HRMQA, propagate :false

             }

         }

              stage(‘NFR Testing’) {

            steps {

                parallel(

                        a: {

                            echo “Reusable Scripts”

                            },

                        b: {

                            echo “This is NFR Testing”

                            //build job: ‘TANFR’,  propagate: false

                            }

                        )

                    }

                    }

         stage(‘Visual Regression’) {

            steps {

                   sh ‘echo “Visual Regression Test”‘

                 // build job: ‘VisualRegression’, propagate: false

                     }

                     }           

           stage(‘Regression Automation Test’) {

            steps {

                   //sh ‘echo “Regression Automation Test”‘

                  build job: ‘TIBARegressionSuite’, propagate: false

                     }

                     }

        stage(‘Copy Artifacts’){

           steps {

               sh ‘echo “Copy Artifacts”‘

           }

        }

              }

       post

       {

         always {

                emailext (

                   attachmentsPattern: ‘/var/lib/jenkins/workspace/TANFR/src/test/resources/testData/NFR/*_NFR_Report.xlsx, /var/lib/jenkins/workspace/TIBARegressionSuite/extentreport.html, /var/lib/jenkins/workspace/TIBARegressionSuite/target/surefire-reports/emailable-report.html’,

                   body: ‘${FILE,path=”/var/lib/jenkins/workspace/TIBARegressionSuite/extentreport.html”}’,

                   mimeType: ‘text/html’,

                   to:”$ADMIN_EMAILS”,

                   subject: “${currentBuild.currentResult}: ${env.JOB_NAME} – build ${currentBuild.number}”,

                   attachLog: false

                      )

           }

       }

}

How ZALENIUM helps in test Automation:

Zalenium is an open source tool combining Zalendo with selenium. This provides the required muscle to selenium tests to be executed in Unix machines by leveraging Selenium grid. All the tests are executed in dynamic docker containers, which can be scaled up/down easily. There is a provision to record and save test execution, that can be referenced in case of any failure.

Advantages of Continuous Testing:

Below are the advantages of Continuous Testing in software development life cycle

  1. Early feedback to developers and business
  2. Accelerate testing with improvement in quality
  3. Increase in test coverage
  4. Reduction in cost of development/maintenance
  5. Faster time to market
  6. Creates a “Quality First” culture with-in the team
  7. Eliminate silos between development, testing and operations teams

 

 

Do’s and Don’ts:

  1. Define Global details on top:
    1. Defining environment details on top section rules out any ambiguity. It also gives a clear picture to people at the time of audit and analysis. The clear mention of those global variables helps developer to check and modify if any changes required at one place.
  2. Execute independent test cases in parallel:
    1. Continuous testing should not become a time schedule bottleneck. To minimize the time taken for the testing, it’s recommended to define independent test cases into multiple parallel stages. This will save the time and effort in testing. The quicker the execution, the quicker and better the feedback cycle.
  3. Report every stage result to stakeholders:
    1. Reporting is the most vital part of continuous testing. Ensure all stages involved in the pipeline has reporting mechanism. The reporting stakeholders can be chosen wisely to reduce the confusion. Report should be clear on its result and bottleneck, if any. This will increase the confidence among stakeholders.

 

Conclusion:

FAIL EARLY…FAIL CHEAP

Continuous Testing not only helps in better quality but also helps in reducing the cost on code maintenance, defects etc. The better the continuous testing process defined, the better and qualitative it for product delivery.

About The Author