predicting class testability using object oriented metrics
Download
Skip this Video
Download Presentation
Predicting Class Testability using Object-Oriented Metrics

Loading in 2 Seconds...

play fullscreen
1 / 18

Predicting Class Testability using Object-Oriented Metrics - PowerPoint PPT Presentation


  • 156 Views
  • Uploaded on

Predicting Class Testability using Object-Oriented Metrics. M. Bruntink and A. van Deursen Presented by Tom Chappell. Goal. To assess the capability of certain object-oriented metrics to predict class testability Useful for: Planning Design Monitoring. Source Code Metrics.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Predicting Class Testability using Object-Oriented Metrics' - fionn


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
predicting class testability using object oriented metrics

Predicting Class Testability using Object-Oriented Metrics

M. Bruntink and A. van Deursen

Presented by Tom Chappell

slide2
Goal
  • To assess the capability of certain object-oriented metrics to predict class testability
  • Useful for:
    • Planning
    • Design
    • Monitoring
source code metrics
Source Code Metrics
  • LOCC – Lines of Code Per Class
    • The number of lines of source code,not including blank lines and comments
  • FOUT – Fan Out
    • The number of classes used by a class
source code metrics4
Source Code Metrics
  • NOM – Number of Methods
    • Counts the number of new methods declared by a class
    • Does not count methods inherited from superclass, even if overridden
source code metrics5
Source Code Metrics
  • NOF – Number of Fields
    • Counts the number of new fields(class variables and member variables) declared by a class
    • Does not count fields inherited from superclass
source code metrics6
Source Code Metrics
  • RFC – Response for Class
    • The number of methods in a class (including inherited methods) plus the number of methods of other classes invoked by that class
source code metrics7
Source Code Metrics
  • DIT – Depth of Inheritance Tree
    • The number of ancestors of a class
  • NOC – Number of Children Classes
    • Counts only the immediate subclasses,not all descendents
source code metrics8
Source Code Metrics
  • WMC – Weighted Methods per Class
    • The total of McCabe’s Cyclomatic Complexity for each method implemented by the class
    • Cyclomatic Complexity is the number of distinct execution paths in the method
source code metrics9
Source Code Metrics
  • LCOM – Lack of Cohesion of Methods
    • 0: every field of the class is used byevery method of the class (Lower Bound)
    • 1: every field of the class is used by one method of the class
    • n / (n-1): no field of the class is used by any of the n methods of the class (Upper Bound)
    • Defined for classes with at least 1 field andat least 2 methods
test suite metrics
Test Suite Metrics
  • dLOCC – Lines of Code for [Test] Class
    • The number of lines of source code in a test class, not including blank lines and comments
  • dNOTC – Number of Test Cases
    • The number of times that a test classcalls a JUnit assert method.
case studies
Case Studies
  • DocGen
    • Commercial documentation generator
    • 90,000 lines of Java code
    • 640 classes (138 with associated test classes)
    • Developed with XP methodology
    • Coding standard: method not allowed to exceed 12 lines
case studies12
Case Studies
  • Apache Ant
    • Open Source build tool (similar to “make”)
    • 170,000 lines of Java code
    • 887 classes (111 with associated test classes)
results
Results
  • Strong Predictors of High dLOCC(Lines of [Test] Class Code):
    • RFC – Response for Class
    • LOCC – Lines of [Source] Class Code
    • FOUT – Fan Out
    • WMC – Weighted Method Count
    • NOM – Number of Methods
    • NOF – Number of Fields
results14
Results
  • Strong Predictors of High dNOTC(Number of Test Cases):
    • RFC – Response for Class(DocGen Only)
    • LOCC – Lines of [Source] Class Code(DocGen Only)
results15
Results
  • LCOM – Lack of Cohesion of Methods
    • Moderately correlated to dLOCC/dNOTC in Ant
    • Much less strongly correlated in DocGen
    • DocGen’s “12 lines per method” coding standard increases LCOM
comments
Comments
  • Choice of Correlation Statistic
    • The authors use Spearman’s rank-order correlation coefficient ( rs )
    • This measures only rank-order correlation (“the class with the 13th-highest number of LOCC had the 13th-highest dLOCC”)
    • The degree that a change in LOCC would cause to change in dLOCC is not measured
comments17
Comments
  • Suggested Metric: %Interface Fan Out
    • Measures the percentage of fan-out references that refer to interfaces,rather than to classes
    • Designing APIs to use interfaces makes classes more flexible and makes it easier for the unit test to set up a test environment using test stub classes that implement required interfaces
ad