Skip to main content

Tips on Writing Readable Code

Code readability may be defined as the convenience with which the source code is understood and modified. Code readability is of vital importance when maintaining larger legacy codebase and working in teams. If the code is easy to read, it would be easy to debug, refactor, enhance and maintain, thereby reducing the lifecycle cost of software product. As readability directly impacts software quality, researchers have proposed adding a separate phase during development focused on improving code readability. Although, code readability is subjective to human judgement, static analysis tools can provide a fair estimate on various factors impacting readability such as indenting, naming and commenting. As a programmer, follow the tips provided below to create self-documenting software program, which can be understood conveniently by other programmers during it's lifetime.

Reducing Regression Testing Time

Reducing Regression Testing Time

What is Regression Testing? 

Regression testing is a type of software testing which is carried out to confirm if the modifications in a software program have broken any existing functionality. Despite its importance, regression testing is costly, specifically for large codebase / test suite, as it consumes enormous amount of compute resources and time. To understand the scale of this problem, according to the statistics published in 2017 by Continuous Integration (CI) and testing group at Google, 150 Million tests are executed per day for 2 Billion Lines of Code (LOC). At this scale, chances of regression errors are increased, demanding implementation of efficient regression testing strategies. Imagine the waste of resources in this unlucky scenario: developer modifies only one line of code, pushes code to Version Control System (VCS), regression testing is triggered lasting around 9 - 10 hours, regression error is found in the last test case execution and the bug report is sent to the developer.

How to Reduce Regression Testing Time?

Researchers across the world have proposed a variety of techniques to reduce the effort involved in regression testing. Provided below are few of the guidelines on reducing the regression testing time: 

1. Automate. Manual regression testing is time consuming, costly and in-efficient. Automation of regression testing is a smart choice, which is now very common in industry. However, automation adds additional overhead of keeping the test suite up-to-date with frequent changes in software. There are plenty of tools and testing frameworks for specific domains to manage automated regression testing, few of which are mentioned below:

  • JUnit for Java and Android Applications
  • Espresso and UI Automator for Automated UI Testing of Android Applications
  • Selenium for Web Applications
  • Appium
  • TestComplete
  • Ra­­­­tional Functional Tester
  • Katalon Studio
  • QTP
Continuous Integration doesn’t get rid of bugs, 
but it does make them dramatically easier to find and remove.
Martin Fowler

2. Implement Continuous Integration. Automated regression testing eases out the effort involved in manual testing, however, it still requires human intervention to initiate the test run. Incorporating automated regression testing as part of CI / CD pipeline provides a lot of benefits, such as scheduling test run as a nightly job. Heart of CI is a server such as Jenkins, Bamboo or Team City and automated testing frameworks (Selenium, Junit) are integrated with the server as a plugin.

Typical CI Pipeline

3. Regression Test Selection (RTS). After you have automated the test execution and integrated it in CI pipeline, there are more ways to reduce the effort involved in regression testing. Regression Test Selection (RTS) is a heuristic based technique in which some of the tests that are affected by code changes are selected and executed. RTS can be manual as well as automated. RTS is efficient as there is no need to run the complete test suite and only a few relevant tests are executed. However, it is only efficient if the time required by RTS algorithm is smaller than running unselected tests. A number of RTS techniques have been proposed in research employing different heuristics, some of which are listed below:
  • Select Test Cases with Higher Failing History
  • Select Test Cases which Test Core Functionality
  • Select Test Cases which Test Features Affected by Recent Change
  • Select all Integration Tests
  • Select all Boundary Value Tests

4. Test Case Prioritization (TCP). Regression Test Selection (RTS) may be inaccurate because it can miss some potential bug triggering test cases. Test Case Prioritization (TCP) employs nearly similar heuristic based techniques to sort all the test cases based on priority. The objective of TCP algorithm is that the test cases with higher failing probability have higher priority and are executed before the other test cases. This can save a lot of time and compute resources by finding bugs early and not minimizing the test suite (as in RTS).   

5. Reduce Frequency of Test Execution. In order to save time and compute resources, one simple way is to execute regression tests after some major software change instead of carrying out after every code commit. 

6. Run Tests on Device Farms. There can be a substantial reduction in regression test effort if executed on a farm of real devices, typically connected in CI pipeline. 

Adopting above-mentioned techniques can substantially reduce the effort involved in regression testing, which is also cost-effective in long term.

Comments