SlideShare a Scribd company logo
www.scmGalaxy.com
sG


              Author: Rajesh Kumar
              rajesh@scmGalaxy.com



                                     scmGalaxy
     scmGalaxy.com
What is Code Coverage

    Code Coverage is an important
  measurement in Software Quality
  Engineering. While Software testing
  ensures correctness of the
  applications, a metric is required to
  track the completeness and
  effectiveness of the testing
  undertaken.
    Code Coverage helps achieve
  reliable quality through identifying
  untested areas of the application.

                                   scmGalaxy.com
Why Code Coverage


 Software testing is a challenging function. The testers
 need to ensure complete functional and non-functional
 correctness of the product. Considering the complex
 workflows and use cases of modern day applications, the
 number of unique cases that the software can be used
 often run into millions, which is not feasible to be covered
 under testing exercise. The testers thus need to

 - While Planning Tests
 o Ensure covering all workflows in terms of decision trees
 in the code
 o Ensure covering all data values – by identifying patterns
 rather covering millions of values

 - While testing
 o Ensuring the testing is completely exercising the whole
 application with planned and exploratory tests.
                                                     scmGalaxy.com
Why Code Coverage cont…


 At the end of testing, the decision to stop testing and release the
 product still remains subjective, based on the presence or absence
 of bugs, inflow of new bugs, success rate of each test cycle,
 confidence rating of the testers or users, etc. Whereas the
 definitive metric of quantifying how much of the application was
 really tested, is missed.

 Code Coverage is measured as quantification of application code
 exercised by the testing activities. Code Coverage can be
 measured at various levels – in terms of programming language
 constructs – Packages, Classes, Methods, Branches or in terms of
 physical artifacts - Folders, Files and Lines. For Eg. A Line
 Coverage metric of 67% means the testing exercised 67% of all
 executable statements of the application. A Code Coverage metric
 usually is accompanied by Code Coverage Analysis Report – which
 helps identify the un-tested part of the application code, thereby
 giving the testers early inputs for complete testing.




                                                          scmGalaxy.com
Benefits of Code Coverage


 Objective Indicator of Test Coverage of application
  code
 Pointers to uncovered Packages / Classes / Methods
  / Branches
 Pointers to uncovered Folders / Files / Lines
 Drill down to untested part of source code and devise
  new tests
 Early Indicator for Testing Quality and Fixing it by
  adding new tests.
 Remove redundancy in testing
 Increased Confidence for Releases




                                               scmGalaxy.com
Test Your Test


             scmGalaxy.com
Typical Emotional Storyboard

Write Some code! Happy!
Does it work? Sad!
Write some test! Happy!
Do they really test the code? Sad!
Measure the Code Coverage! Happy!




                                scmGalaxy.com
Coverage Measurement

Shows Which line of code are
 executed
How much of your code is covered by
 your tests?
Your tests test your product
Coverage testing tests your tests




                               scmGalaxy.com
Goal

100%
  Coverage Ideal
  Not Always possible
  Can be expensive to achieve
  Design for testability




                                 scmGalaxy.com
Practical Goal

More Coverage is better: Good
Actual number does not matter
False quantifiability: bad
Use coverage results to understand
 your code




                                scmGalaxy.com
Good: Write more tests




   Only way to truly increase code
              coverage




                                scmGalaxy.com
Bad

      Excluding Code to boost
 Coverage




                                scmGalaxy.com
Types of Coverage

Statement Coverage
Branch Coverage
Path Coverage
Loop Path Coverage
Data – driven Code
Complex Conditionals
Hidden Branches




                        scmGalaxy.com
Code Coverage Terminologies

 Instrumentation
 Instrumentation is the process to add code to the
 application to be able to output Code Coverage data.
 Instrumentation can be done at Source Level or at
 Intermediate language level, and rarely at run-time as
 information collection.

 Source Level Instrumentation: Prior to compilation,
 instrumentation code are inserted by the code coverage
 tool to the application. This will be compiled into the
 application code.
 Object level Instrumentation: Post compilation of the
 Application, executable lines to collect Coverage data are
 injected into the Object code.

 Merge
 Ability to run tests in batches, or in different environments,
 yet consolidate the overall coverage reports. Most of good
 coverage tools support offline merge feature.



                                                      scmGalaxy.com
Tooling Infrastructure


For Code Coverage analysis the ideal
 infrastructure would be
- Integrated Instrumentation with the
 build process
- Deployment of Code Coverage
 instrumented application
- Auto-Collection of Coverage data
 during testing
- Merge & Final Report automation
Code Coverage reports can be
 generated on every test cycle if tests.
                                  scmGalaxy.com
Code Coverage is NOT

 What Code Coverage is and is Not100% Code Coverage
  Does Not say the product is bug free, it ensures product is
  100% tested. If the product was tested wrongly, Code
  Coverage can’t help.
 Code Coverage testing does not require any special test
  methods – On the instrumented build – any testing that is
  carried out will generate coverage data. Regular using of
  the instrumented application will generate coverage
  information as well.
 Code Coverage is not about Whitebox testing. Code
  coverage is generated when you test the application in Any
  way. To analyse the code, the review happens at Code
  Level. It is not Whitebox testing.
 Code Coverage is not only through Unit Testing or
  Automated Testing.
 Code Coverage does not require extra testing efforts
 Code Coverage is not an end game activity, the earlier the
  better. It gives scope to improve tests and cover more
  code, thereby ensuring higher quality.
 Code Coverage instrumented builds can’t be used for
  Performance Testing. It will add performance overhead.

                                                     scmGalaxy.com
How?
       scmGalaxy.com
Coverage Tools

Clover
Cobertura
Emma




                 scmGalaxy.com
www.scmGalaxy.com

sG                   Author: Rajesh Kumar
                     rajesh@scmGalaxy.com




     scmGalaxy.com

More Related Content

PDF
Code Coverage
PPTX
Code Coverage
PPT
Code coverage
PDF
Introduction to CICD
PPTX
Introduction to software testing
PDF
INTEGRATION TESTING
PPTX
Sanity testing and smoke testing
PPT
Maven Introduction
Code Coverage
Code Coverage
Code coverage
Introduction to CICD
Introduction to software testing
INTEGRATION TESTING
Sanity testing and smoke testing
Maven Introduction

What's hot (20)

ODP
BDD with Cucumber
PPTX
Software testing and process
PDF
Test Automation - Keytorc Approach
PPTX
Code review
PDF
SAST vs. DAST: What’s the Best Method For Application Security Testing?
PPTX
White box testing
PDF
Code coverage
PDF
Continuous Integration/Deployment with Gitlab CI
PPTX
Regression testing
PPT
Security Testing
PDF
DevSecOps: Key Controls for Modern Security Success
PPTX
DevOps Training | DevOps Training Video | DevOps Tools | DevOps Tutorial For ...
PPT
State transition testing-software_testing
PPTX
PDF
Slide DevSecOps Microservices
PPTX
Cypress Automation
PPT
Basic software-testing-concepts
PPTX
DEVSECOPS.pptx
PPTX
Regression testing
PPTX
Nomad + Flatcar: a harmonious marriage of lightweights
BDD with Cucumber
Software testing and process
Test Automation - Keytorc Approach
Code review
SAST vs. DAST: What’s the Best Method For Application Security Testing?
White box testing
Code coverage
Continuous Integration/Deployment with Gitlab CI
Regression testing
Security Testing
DevSecOps: Key Controls for Modern Security Success
DevOps Training | DevOps Training Video | DevOps Tools | DevOps Tutorial For ...
State transition testing-software_testing
Slide DevSecOps Microservices
Cypress Automation
Basic software-testing-concepts
DEVSECOPS.pptx
Regression testing
Nomad + Flatcar: a harmonious marriage of lightweights
Ad

Viewers also liked (16)

PPSX
SCM Process and smartBuild
PPT
Configuration Management in Software Engineering - SE29
PPT
Software configuration management
PPT
Build And Automation
PPT
Configuration Management
PDF
Code Coverage Revised : EclEmma on JaCoCo
PDF
Software configuration management in deep
PDF
ISO 29119 and Software Testing - now what??
PPTX
Branching and Merging Practices
PPT
Why Scm
PDF
Fundamental of apache maven
PPTX
Software configuration management
PPT
Software Configuration Management And CVS
PPTX
Software Configuration Management (SCM)
PPT
Introduction To Software Configuration Management
PPT
Software Configuration Management
SCM Process and smartBuild
Configuration Management in Software Engineering - SE29
Software configuration management
Build And Automation
Configuration Management
Code Coverage Revised : EclEmma on JaCoCo
Software configuration management in deep
ISO 29119 and Software Testing - now what??
Branching and Merging Practices
Why Scm
Fundamental of apache maven
Software configuration management
Software Configuration Management And CVS
Software Configuration Management (SCM)
Introduction To Software Configuration Management
Software Configuration Management
Ad

Similar to Code coverage & tools (20)

PDF
Code Coverage vs Test Coverage_ A Complete Guide.pdf
PDF
Code Coverage vs Test Coverage_ A Complete Guide.pdf
PPTX
Top 5 Code Coverage Tools in DevOps
PPTX
Software testing and quality assurance
PDF
End to End Cloud App Deployment Solution
PDF
[India Merge World Tour] Coverity
PDF
Security Validation as Code.pdf
PDF
Security Validation as Code
PPTX
Coding and testing in Software Engineering
PPTX
To Improve Code Quality in Your Software Development Projects- Code Brew Labs...
PPTX
Automating The Process For Building Reliable Software
PDF
Certified Software Testing Professional
PPTX
Zero-bug Software, Mathematically Guaranteed
PDF
Software Testing Certification
PPTX
SOFTWARE TESTING.pptx
PDF
Improving ROI with Scriptless Test Automation
PPT
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
PDF
How Does No Code Testing Work........pdf
PDF
Welcome to International Journal of Engineering Research and Development (IJERD)
PDF
Security Validation
Code Coverage vs Test Coverage_ A Complete Guide.pdf
Code Coverage vs Test Coverage_ A Complete Guide.pdf
Top 5 Code Coverage Tools in DevOps
Software testing and quality assurance
End to End Cloud App Deployment Solution
[India Merge World Tour] Coverity
Security Validation as Code.pdf
Security Validation as Code
Coding and testing in Software Engineering
To Improve Code Quality in Your Software Development Projects- Code Brew Labs...
Automating The Process For Building Reliable Software
Certified Software Testing Professional
Zero-bug Software, Mathematically Guaranteed
Software Testing Certification
SOFTWARE TESTING.pptx
Improving ROI with Scriptless Test Automation
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
How Does No Code Testing Work........pdf
Welcome to International Journal of Engineering Research and Development (IJERD)
Security Validation

More from Rajesh Kumar (20)

PDF
Git and github fundamental
PDF
Tools for quality matrix and kloc
PDF
Cast vs sonar
PDF
Cast vs sonar
PDF
Testing in a glance
PDF
Rpm cheatbook
PDF
Scm process assessment guide
PPT
Cruise control
PPT
Cloud computer
PPT
Version Control With CVS
PPT
Using Ant To Build J2 Ee Applications
PPT
Scm With Mks Integrity
PPT
Introduction To Ant
PPT
Introduction To Ant1
PPT
Apache Ant
PPT
Process
PPT
PPT
Ood Post1
PPT
Ooa 1 Post
PPT
Ooa 2 Post1
Git and github fundamental
Tools for quality matrix and kloc
Cast vs sonar
Cast vs sonar
Testing in a glance
Rpm cheatbook
Scm process assessment guide
Cruise control
Cloud computer
Version Control With CVS
Using Ant To Build J2 Ee Applications
Scm With Mks Integrity
Introduction To Ant
Introduction To Ant1
Apache Ant
Process
Ood Post1
Ooa 1 Post
Ooa 2 Post1

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Machine learning based COVID-19 study performance prediction
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
KodekX | Application Modernization Development
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Encapsulation theory and applications.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Machine learning based COVID-19 study performance prediction
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Digital-Transformation-Roadmap-for-Companies.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
KodekX | Application Modernization Development
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Encapsulation theory and applications.pdf
Spectroscopy.pptx food analysis technology
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Chapter 3 Spatial Domain Image Processing.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Code coverage & tools

  • 1. www.scmGalaxy.com sG Author: Rajesh Kumar rajesh@scmGalaxy.com scmGalaxy scmGalaxy.com
  • 2. What is Code Coverage  Code Coverage is an important measurement in Software Quality Engineering. While Software testing ensures correctness of the applications, a metric is required to track the completeness and effectiveness of the testing undertaken.  Code Coverage helps achieve reliable quality through identifying untested areas of the application. scmGalaxy.com
  • 3. Why Code Coverage Software testing is a challenging function. The testers need to ensure complete functional and non-functional correctness of the product. Considering the complex workflows and use cases of modern day applications, the number of unique cases that the software can be used often run into millions, which is not feasible to be covered under testing exercise. The testers thus need to - While Planning Tests o Ensure covering all workflows in terms of decision trees in the code o Ensure covering all data values – by identifying patterns rather covering millions of values - While testing o Ensuring the testing is completely exercising the whole application with planned and exploratory tests. scmGalaxy.com
  • 4. Why Code Coverage cont… At the end of testing, the decision to stop testing and release the product still remains subjective, based on the presence or absence of bugs, inflow of new bugs, success rate of each test cycle, confidence rating of the testers or users, etc. Whereas the definitive metric of quantifying how much of the application was really tested, is missed. Code Coverage is measured as quantification of application code exercised by the testing activities. Code Coverage can be measured at various levels – in terms of programming language constructs – Packages, Classes, Methods, Branches or in terms of physical artifacts - Folders, Files and Lines. For Eg. A Line Coverage metric of 67% means the testing exercised 67% of all executable statements of the application. A Code Coverage metric usually is accompanied by Code Coverage Analysis Report – which helps identify the un-tested part of the application code, thereby giving the testers early inputs for complete testing. scmGalaxy.com
  • 5. Benefits of Code Coverage  Objective Indicator of Test Coverage of application code  Pointers to uncovered Packages / Classes / Methods / Branches  Pointers to uncovered Folders / Files / Lines  Drill down to untested part of source code and devise new tests  Early Indicator for Testing Quality and Fixing it by adding new tests.  Remove redundancy in testing  Increased Confidence for Releases scmGalaxy.com
  • 6. Test Your Test scmGalaxy.com
  • 7. Typical Emotional Storyboard Write Some code! Happy! Does it work? Sad! Write some test! Happy! Do they really test the code? Sad! Measure the Code Coverage! Happy! scmGalaxy.com
  • 8. Coverage Measurement Shows Which line of code are executed How much of your code is covered by your tests? Your tests test your product Coverage testing tests your tests scmGalaxy.com
  • 9. Goal 100%  Coverage Ideal  Not Always possible  Can be expensive to achieve  Design for testability scmGalaxy.com
  • 10. Practical Goal More Coverage is better: Good Actual number does not matter False quantifiability: bad Use coverage results to understand your code scmGalaxy.com
  • 11. Good: Write more tests Only way to truly increase code coverage scmGalaxy.com
  • 12. Bad Excluding Code to boost Coverage scmGalaxy.com
  • 13. Types of Coverage Statement Coverage Branch Coverage Path Coverage Loop Path Coverage Data – driven Code Complex Conditionals Hidden Branches scmGalaxy.com
  • 14. Code Coverage Terminologies Instrumentation Instrumentation is the process to add code to the application to be able to output Code Coverage data. Instrumentation can be done at Source Level or at Intermediate language level, and rarely at run-time as information collection. Source Level Instrumentation: Prior to compilation, instrumentation code are inserted by the code coverage tool to the application. This will be compiled into the application code. Object level Instrumentation: Post compilation of the Application, executable lines to collect Coverage data are injected into the Object code. Merge Ability to run tests in batches, or in different environments, yet consolidate the overall coverage reports. Most of good coverage tools support offline merge feature. scmGalaxy.com
  • 15. Tooling Infrastructure For Code Coverage analysis the ideal infrastructure would be - Integrated Instrumentation with the build process - Deployment of Code Coverage instrumented application - Auto-Collection of Coverage data during testing - Merge & Final Report automation Code Coverage reports can be generated on every test cycle if tests. scmGalaxy.com
  • 16. Code Coverage is NOT  What Code Coverage is and is Not100% Code Coverage Does Not say the product is bug free, it ensures product is 100% tested. If the product was tested wrongly, Code Coverage can’t help.  Code Coverage testing does not require any special test methods – On the instrumented build – any testing that is carried out will generate coverage data. Regular using of the instrumented application will generate coverage information as well.  Code Coverage is not about Whitebox testing. Code coverage is generated when you test the application in Any way. To analyse the code, the review happens at Code Level. It is not Whitebox testing.  Code Coverage is not only through Unit Testing or Automated Testing.  Code Coverage does not require extra testing efforts  Code Coverage is not an end game activity, the earlier the better. It gives scope to improve tests and cover more code, thereby ensuring higher quality.  Code Coverage instrumented builds can’t be used for Performance Testing. It will add performance overhead. scmGalaxy.com
  • 17. How? scmGalaxy.com
  • 19. www.scmGalaxy.com sG Author: Rajesh Kumar rajesh@scmGalaxy.com scmGalaxy.com