Information Technology Reference
In-Depth Information
LISTING 7-8
Generating a Simian HTML Report
1 <available property="simian.outputfile.present"
file="${simian.outputfile}"/>
2 <target name="simian-report" if="simian.outputfile.present">
3 <xslt
in="${simian.outputfile}"
out="${reports.simian.dir}/Simian-Report.html"
style="${config.dir}/simian/simian.xsl"/>
4 </target>
Line 1 —Checks for the existence of the Simian output file
(XML) and sets the simian.outputfile.present property if
the file exists.
Line 2 —Executes the simian-report target if the sim-
ian.outputfile.present has been set.
Line 3 —Generates the Simian report using the XSLT style sheet
provided with the Simian distribution.
Figure 7-5 is a sample report that Ant and Simian generated for the
code in Listing 7-7. Notice that the code in this example has 4.27%
duplication, given the line threshold of 4.
Assess Code Coverage
There are different types of coverage measurements, but most tools
focus on line coverage (also known as statement coverage ). Line
coverage simply indicates that a particular line of code was exercised.
You obtain a test coverage measurement by exercising a code base
with a test harness and capturing data that corresponds to code having
been “touched” throughout the lifetime of the test process. The data is
then synthesized to produce a coverage report. In Java shops, the test
harness is commonly JUnit and the coverage tool is usually something
like Cobertura, EMMA, or Clover. With .NET, NUnit may be the test-
ing framework, and NCover and Clover.NET are commonly used as
code coverage tools.
For example, if a method is ten lines long and seven lines of the
method were exercised in a test run, then the method has a line cover-
age of 70%. The process works at the aggregate level as well: If a class
 
Search WWH ::




Custom Search