SEG 3150 Winter 2003 Telecom. Software Engineering

nutmegactΛογισμικό & κατασκευή λογ/κού

10 Νοε 2012 (πριν από 4 χρόνια και 7 μήνες)

182 εμφανίσεις

Clover


http://www.cenqua.com/clover


Commercial tool: requires license


Supports
method
,
statement
, and
branch

coverage


Reports its findings in multiple formats


From project level down to individual lines of
source code


Historical charting of code coverage and other
metrics


Plug
-
in versions available for Eclipse, NetBeans

Clover plugin for Eclipse

Clover coverage filters


One can choose not to instrument certain types of blocks in
the code (e.g. assertions and exception catching), in order to
focus on the coverage of interest.

Emma


Open
-
source tool


Supports class, method, “basic block”, and line
coverage.


“Fractional” line coverage supported, but not
branch coverage.


Standalone version works with Ant builds


http://emma.sourceforge.net


Eclipse plugin EclEmma also available


http://www.eclemma.org

Emma


Uses bytecode instrumentation.


Classes can be instrumented in advance, or
during class loading.


Tool keeps a metadata file to associate bytecode
with source code


A regular compile will allow for only limited
metadata.


A compile with debug option will provide more
information to support branch coverage.

Block Coverage


Block coverage assumes that if a block of statements
without branches is entered
and exited
, all statements in
the block were executed.


That is, the counter is at the end of the block, instead of
before the source code statement.


Result: If an exception occurs in the block, the
entire

block
is not recorded as having executed.


This may be fine for application source code, but it does
not work well with JUnit test source code.


JUnit throws exceptions internally when tests fail, so
the test may not have appeared to be executed.

Emma coverage report

Emma source code annotations

Fractional line coverage

Only part

of conditional

executed

Loop increment

not executed

Anomalies with byte code coverage


There are cases where the compiler may emit multiple
copies of object code for a single instance of source code.


In the above example, there is an instance variable
initialized for each of two constructors. However, only one
constructor is called.

Coverlipse


Open source Eclipse plug
-
in


http://coverlipse.sourceforge.net


Provides block coverage, all
-
uses data flow
coverage


No branch coverage


Uses Apache BCEL to instrument bytecode

Line coverage report

All
-
uses coverage report

All
-
uses coverage report

Cobertura


Open source tool for Java code coverage


http://cobertura.sourceforge.net


Measures line coverage, branch coverage, and McCabe
cyclomatic complexity metric for methods.


Branch coverage requires compilation with debug option.


Must be run as an Ant task, with four stages


Compile source code


Instrument classes


Run code


Generate report


Cobertura summary report

Cobertura detail report

References


Clover: http://www.cenqua.com/clover


Emma:


http://emma.sourceforge.net


http://www.eclemma.org


Coverlipse: http://coverlipse.sourceforge.net


Cobertura: http://cobertura.sourceforge.net


A. Glover, “Don’t be fooled by the Coverage Report”, IBM
developer works article

http://www
-
128.ibm.com/developerworks/java/library/j
-
cq01316


S. Gornett, “Code Coverage Analysis”


http://www.bullseye.com/coverage.html