::xounit
Class CoverageReport

Heritage:
::xotcl::Object
Direct Known Subclasses:
::xounit::DocumentationCoverageReport,

Class CoverageReport
superclass ::xotcl::Object,
CoverageReport is a collector of information
 about the coverage analysis and produces the
 formatted summary of that information
Variables
NameDefault ValueClassComment
failures  0  ::xounit::CoverageReport
 number of methods that are not covered
passes  0  ::xounit::CoverageReport
 number of methods that are covered
 
Methods
NameComment
add {class}   Adds a class to be watched during coverage analysis
addPackage {package}   Adds a package to be watched during coverage analysis
clear {}   Clears all old information from the CoverageReport
reportClass {class}   Builds the report of coverage for all methods in class
reportPackage {package}   Builds the report of coverage for all classes in package
reportPackages {packages}   Builds the report of coverage for all classes in packages
reportSummary {}   Builds the report summary for all classes included in this CoverageReport
start {}   Starts the recording of the CoverageReport
stop {}   Stops the recording of the CoverageReport
   
Methods from ::xotcl::Object
#, ., ?, ?code, ?methods, ?object, abstract, copy, coverageFilter, defaultmethod, extractConfigureArg, filterappend, garbageCollect, get#, getClean#, hasclass, init, methodTag, mixinappend, move, profileFilter, self, setParameterDefaults, shell, tclcmd, traceFilter,
 
Instproc Detail

add

Description:
 Adds a class to be watched during coverage analysis.
Arguments:
Code:
  ::xounit::CoverageReport instproc add {class}  {
   

        ::xounit::Coverage add $class
        my assertNotEquals [ lsearch [ $class info instfilter ] coverageFilter ] -1
    
}

addPackage

Description:
 Adds a package to be watched during coverage analysis.
Arguments:
Code:
  ::xounit::CoverageReport instproc addPackage {package}  {
   

        set namespace ::${package}

        puts "Searching $namespace"

        foreach class [ ::xox::ObjectGraph findAllInstances ::xotcl::Class $namespace ] {
            puts "Watching $class"
            my add $class
        }
    
}

clear

Description:
 Clears all old information from the CoverageReport
Code:
  ::xounit::CoverageReport instproc clear {}  {
   

        ::xounit::Coverage clear
        my passes 0
        my failures 0
    
}

reportClass

Description:
 Builds the report of coverage for all methods in class.
Arguments:
Code:
  ::xounit::CoverageReport instproc reportClass {class}  {
   

        if { [ string first  "::test::" $class ] != -1 } { return }
        if { "$class" == "::xounit::CoverageReport" } { return }

        foreach method [ $class info instprocs ] {

            if { ![ ::xounit::Coverage hasCoverage $class $method ] } {

                puts "Not Covered: $class $method"
                my incr failures
                continue
            }
            puts "Covered: $class $method [ ::xounit::Coverage getCoverage $class $method ]"
            my incr passes
        }
    
}

reportPackage

Description:
 Builds the report of coverage for all classes in package.
Arguments:
Code:
  ::xounit::CoverageReport instproc reportPackage {package}  {
   

        set namespace ::${package}

        foreach class [ ::xox::ObjectGraph findAllInstances ::xotcl::Class $namespace ] {

            my reportClass $class
        }
    
}

reportPackages

Description:
 Builds the report of coverage for all classes in packages.
Arguments:
Code:
  ::xounit::CoverageReport instproc reportPackages {packages}  {
   

        foreach package $packages {

            my reportPackage $package
        }
    
}

reportSummary

Description:
 Builds the report summary for all classes included in this
 CoverageReport
Code:
  ::xounit::CoverageReport instproc reportSummary {}  {
   

        my instvar passes failures

        set total [ expr { $passes + $failures } ]

        puts "\n\nTest Coverage Report Summary by Method"
        puts "=========================================="
        puts "Total:        $total"
        if { $total == 0 } { return }
        puts "Covered:      $passes - [ expr { floor ( 100.0 * $passes / $total ) } ]%"
        puts "Not Covered:  $failures - [ expr { ceil ( 100.0 * $failures / $total ) } ]%"
    
}

start

Description:
 Starts the recording of the CoverageReport
Code:
  ::xounit::CoverageReport instproc start {}  {
   

        ::xounit::Coverage start
    
}

stop

Description:
 Stops the recording of the CoverageReport
Code:
  ::xounit::CoverageReport instproc stop {}  {
   

        ::xounit::Coverage stop
    
}