SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Knowledge Share on Code Coverage Magus Chen maguschen@hotmail.com http://magustest.com/blog/
Agenda What is Code Coverage How it Works Common Mistakes Some Thoughts References 2
What is Code Coverage Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested.  3
What is Code Coverage Statement coverage Decision(Branch) coverage Condition coverage Condition/decision coverage Function coverage http://en.wikipedia.org/wiki/Code_coverage http://www.javaranch.com/journal/2004/01/IntroToCodeCoverage.html http://www.exampler.com/testing-com/writings/coverage-terminology.html 4
How does Code Coverage Works Essentially all code coverage tools instrument the code in order to check which parts of the code were executed. When test executed, code coverage tool will collect  Usually there are some tools can parse the coverage result data file and generate a report http://www.bullseye.com/paper.html 5
Common Mistakes Try to reach 100% coverage Some part of the code is hard to reach Non-critical code should be set low priority Follow the idea of the code The existence code looks good and we get 100% coverage, the problem is that feature cannot be found in the code(never written)  Confuse high coverage with high quality The most useful information of code coverage report can tell us is which lines in the application were not being test. 6
Some Thoughts Run the test against AUT Check code coverage report and retest Phase I Target on simple feature test Filter current feature related code and indentify the untest code (Line coverage) Add more test case to cover those untest code Phase II Target on most critical feature test Filter current feature related code and indentify the untest code (Branch coverage) Add more test case to fulfill the branch coverage 7
References on Tools http://ltp.sourceforge.net/coverage/lcov.php http://gcc.gnu.org/onlinedocs/gcc/Gcov.html http://www.bobah.net/d4d/tools/code-coverage-with-gcov http://www.network-theory.co.uk/docs/gccintro/gccintro_81.html http://open-tube.com/10-code-coverage-tools-c-c 8
Other Tool Candidates http://www.testcocoon.org/  (OPRE SOURCE) http://covtool.sourceforge.net/   (OPRE SOURCE) http://www.testwell.fi/ctcdesc.html  (commercial) http://www.bullseye.com/productInfo.html   (commercial) 9
Q & A 10
Thank you

Weitere ähnliche Inhalte

Andere mochten auch

Session 7 code_functional_coverage
Session 7 code_functional_coverageSession 7 code_functional_coverage
Session 7 code_functional_coverage
Nirav Desai
 
Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective   Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective
Engineering Software Lab
 
Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Gs Us Roadmap For A World Class Information Security Management System– Isoie...Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Tammy Clark
 
Finding Bugs Faster with Assertion Based Verification (ABV)
Finding Bugs Faster with Assertion Based Verification (ABV)Finding Bugs Faster with Assertion Based Verification (ABV)
Finding Bugs Faster with Assertion Based Verification (ABV)
DVClub
 
What's with All This Talk About Coverage?
What's with All This Talk About Coverage?What's with All This Talk About Coverage?
What's with All This Talk About Coverage?
DVClub
 

Andere mochten auch (19)

Session 7 code_functional_coverage
Session 7 code_functional_coverageSession 7 code_functional_coverage
Session 7 code_functional_coverage
 
Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective   Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective
 
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
 
Collection pipeline par Mathieu Godart
Collection pipeline par  Mathieu GodartCollection pipeline par  Mathieu Godart
Collection pipeline par Mathieu Godart
 
Couverture de code
Couverture de codeCouverture de code
Couverture de code
 
Automating The Process For Building Reliable Software
Automating The Process For Building Reliable SoftwareAutomating The Process For Building Reliable Software
Automating The Process For Building Reliable Software
 
Code Coverage Web Application
Code Coverage Web ApplicationCode Coverage Web Application
Code Coverage Web Application
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.
 
BT Global Services - Our approach to Innovation
BT Global Services - Our approach to InnovationBT Global Services - Our approach to Innovation
BT Global Services - Our approach to Innovation
 
Tma World Viewpoint: Building Global Alignment Through Enterprise Wide Learning
Tma World Viewpoint: Building Global Alignment Through Enterprise Wide LearningTma World Viewpoint: Building Global Alignment Through Enterprise Wide Learning
Tma World Viewpoint: Building Global Alignment Through Enterprise Wide Learning
 
Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Gs Us Roadmap For A World Class Information Security Management System– Isoie...Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Gs Us Roadmap For A World Class Information Security Management System– Isoie...
 
Finding Bugs Faster with Assertion Based Verification (ABV)
Finding Bugs Faster with Assertion Based Verification (ABV)Finding Bugs Faster with Assertion Based Verification (ABV)
Finding Bugs Faster with Assertion Based Verification (ABV)
 
Fight your technical debt with Jenkins, Jacoco and Sonar
Fight your technical debt with Jenkins, Jacoco and SonarFight your technical debt with Jenkins, Jacoco and Sonar
Fight your technical debt with Jenkins, Jacoco and Sonar
 
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
 
Unit Testing Done Right
Unit Testing Done RightUnit Testing Done Right
Unit Testing Done Right
 
What's with All This Talk About Coverage?
What's with All This Talk About Coverage?What's with All This Talk About Coverage?
What's with All This Talk About Coverage?
 
Comparing model coverage and code coverage in Model Driven testing: an explor...
Comparing model coverage and code coverage in Model Driven testing: an explor...Comparing model coverage and code coverage in Model Driven testing: an explor...
Comparing model coverage and code coverage in Model Driven testing: an explor...
 
Presentation slides: "How to get 100% code coverage"
Presentation slides: "How to get 100% code coverage" Presentation slides: "How to get 100% code coverage"
Presentation slides: "How to get 100% code coverage"
 
Functional Coverage Development Tips - Mentor Graphics
Functional Coverage Development Tips - Mentor GraphicsFunctional Coverage Development Tips - Mentor Graphics
Functional Coverage Development Tips - Mentor Graphics
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Knowledge share on code coverage

  • 1. Knowledge Share on Code Coverage Magus Chen maguschen@hotmail.com http://magustest.com/blog/
  • 2. Agenda What is Code Coverage How it Works Common Mistakes Some Thoughts References 2
  • 3. What is Code Coverage Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. 3
  • 4. What is Code Coverage Statement coverage Decision(Branch) coverage Condition coverage Condition/decision coverage Function coverage http://en.wikipedia.org/wiki/Code_coverage http://www.javaranch.com/journal/2004/01/IntroToCodeCoverage.html http://www.exampler.com/testing-com/writings/coverage-terminology.html 4
  • 5. How does Code Coverage Works Essentially all code coverage tools instrument the code in order to check which parts of the code were executed. When test executed, code coverage tool will collect Usually there are some tools can parse the coverage result data file and generate a report http://www.bullseye.com/paper.html 5
  • 6. Common Mistakes Try to reach 100% coverage Some part of the code is hard to reach Non-critical code should be set low priority Follow the idea of the code The existence code looks good and we get 100% coverage, the problem is that feature cannot be found in the code(never written) Confuse high coverage with high quality The most useful information of code coverage report can tell us is which lines in the application were not being test. 6
  • 7. Some Thoughts Run the test against AUT Check code coverage report and retest Phase I Target on simple feature test Filter current feature related code and indentify the untest code (Line coverage) Add more test case to cover those untest code Phase II Target on most critical feature test Filter current feature related code and indentify the untest code (Branch coverage) Add more test case to fulfill the branch coverage 7
  • 8. References on Tools http://ltp.sourceforge.net/coverage/lcov.php http://gcc.gnu.org/onlinedocs/gcc/Gcov.html http://www.bobah.net/d4d/tools/code-coverage-with-gcov http://www.network-theory.co.uk/docs/gccintro/gccintro_81.html http://open-tube.com/10-code-coverage-tools-c-c 8
  • 9. Other Tool Candidates http://www.testcocoon.org/ (OPRE SOURCE) http://covtool.sourceforge.net/ (OPRE SOURCE) http://www.testwell.fi/ctcdesc.html (commercial) http://www.bullseye.com/productInfo.html (commercial) 9
  • 10. Q & A 10