Knowledge share on code coverage

11
KNOWLEDGE SHARE ON CODE COVERAGE Magus Chen [email protected] http:// magustest.com/blog / Company Logo

description

Knowledge share on code coverage

Transcript of Knowledge share on code coverage

Page 1: Knowledge share on code coverage

KNOWLEDGE SHARE ON CODE COVERAGE

Magus [email protected]

http://magustest.com/blog/

Company Logo

Page 2: Knowledge share on code coverage

2

Agenda

• What is Code Coverage

• How it Works

• Common Mistakes

• Some Thoughts

• References

Page 3: Knowledge share on code coverage

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.

Page 4: Knowledge share on code coverage

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

Page 5: Knowledge share on code coverage

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

Page 6: Knowledge share on code coverage

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.

Page 7: Knowledge share on code coverage

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

Page 8: Knowledge share on code 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

Page 9: Knowledge share on code coverage

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)

Page 10: Knowledge share on code coverage

10

Q & A

Page 11: Knowledge share on code coverage

Thank you