Knowledge share on code coverage
-
Upload
magus-chen -
Category
Technology
-
view
5.250 -
download
2
description
Transcript of Knowledge share on code coverage
2
Agenda
• What is Code Coverage
• How it Works
• Common Mistakes
• Some Thoughts
• References
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.
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/IntroTo
CodeCoverage.html• http://www.exampler.com/testing-com/writings/cov
erage-terminology.html
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
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.
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
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-cover
age-with-gcov
• http://www.network-theory.co.uk/docs/gccintro/gccintro_81.html
• http://open-tube.com/10-code-coverage-tools-c-c
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)
10
Q & A
Thank you