DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Maintenance
  4. Code Churn — A Magical Metric for Software Quality

Code Churn — A Magical Metric for Software Quality

Learn about the code churn metric and how it helps pinpoint issues and protect software quality.

Lokesh Raj user avatar by
Lokesh Raj
·
Dec. 03, 18 · Tutorial
Like (2)
Save
Tweet
Share
12.49K Views

Join the DZone community and get the full member experience.

Join For Free

There are many ways of protecting the quality of the software and devising various techniques to ensure the right test plan for each software release. Based on my experience in many projects from small size to enterprise level, code churn-based analysis and testing are very effective in uncovering issues and protecting software quality. Code churn is nothing but code changes made for the software to achieve a certain functionality.

Code Churn

While designing test plans, the basic question to ask would be to find out what code changes are done in the software. There are multiple contexts to this; one is from the functional perspective and another from a code perspective.

The functional perspective would help to do black box testing. If you understand the functionality well and what has been changed in the current feature, then it would be easy to come up with an effective test plan to test the modified functionality.

However, in legacy or enterprise level software, it is not sufficient. The code written to change or add a functionality would have many side effects, like

  • Direct dependent code
  • Reused code
  • Business rules changing, especially various code paths

In such cases, black box testing would not be enough. It is important to know the code churn (changes).

What to Look for in Code Churn

Below are a couple of important takeaways we can derive from code churn:

  • Code churn size
  • Type of churn
  • Breadth of code churn
  • Depth of code churn

Let’s briefly understand them one by one.

Code Churn Size

In this metric, we mainly need to understand the number of lines changed to achieve the functionality. It will provide information like

  • If it's a completely new code (class, method).
  • Whether it requires unit-level tests to ensure it is tested for various inputs, output, and associated business rules.
  • What existing code was modified for specific (new or modified) business rules, data changes, etc.
  • The overall size of the code as a generic factor (e.g. for a story of size 5 point, are there 100 lines of code or few, etc.); it will give a sense of criticality of the change.

Types of Churn

This is mainly to understand the type of tests to include. Some of the important factors to understand are

  • Server-side change – Test cases required for application layer code and stored procedure changes.
    • Is it functional or non-functional?
  • Client-side change like HTML, JS, CSS, etc. — This will help us to put test cases related to UI responsiveness, multiple browser tests, accessibility tests, device tests, etc.

Breadth of Code Churn

It will help to identify a list of dependent functionalities and modules to be regressed. From a functional perspective, it might not be dependent on other modules, however, if the code is reused in other modules, then it may be required to consider them under regression tests.

If the code change is done in a utility function which is reused in multiple modules, it may be required to regress the dependent areas as well.

Depth of Code Churn

This will help testers to define what level of test cases are to be written. If the code is completely rewritten or changed on multiple levels, then unit-level, integration, and regression test cases are required. If it is just a specific area of code changed, then identify only the test cases specific to the area of the change.

Useful Tools

By looking at the above advantages of using code churn, it is easier said than done, unless we have the right tools to provide such useful information.

There are many tools we can use for such analysis, however, a few tools that we found to be very useful are listed below:

  • Git – code repository. We wrote a small tool that will connect to the git repository and pull the metrics for the given date period from the git repository range, like

    • List of files changed
    • Type of files changed based on file extensions like .vb, .cs, .js, .css, .html, etc.
    • Number of lines added
    • Number of lines modified
    • Total code churn
  • N-Cover — This is a comprehensive tool to identify code coverage. We will be able to identify how much of the code is tested through tests executed and any gaps in the testing. It adds more value to figure out the gaps in testing and filling those gaps immediately.

How to Use Code Churn Data

Effective use of code churn can be made in many ways.

  • The code churn report should be generated on a daily basis and should be used for BVT (Build, Verification, Test).
  • Code churn should be the basis for sprint tests so that each day of code is tested on a day-to-day basis.
  • The code churn report can be used for finalizing release-level test plans to identify the list of modules, components, and subcomponents to be regressed.
  • Code churn should be used during group technical reviews, as well, to understand the complexity, size, and dependency of code changes.

To summarize the benefits of code churn, it is like hitting the bull’s eye instead of executing test cases blindly based on merely functional aspects. Using a code churn-based test plan, it will test the exact code that is added/modified/deleted. This way, we will not be shooting in the dark.

Software Testing Software quality Metric (unit)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Front-End Troubleshooting Using OpenTelemetry
  • Comparing Map.of() and New HashMap() in Java
  • Specification by Example Is Not a Test Framework
  • Distributed Tracing: A Full Guide

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: