Predicting class testability using object oriented metrics
Download
1 / 18

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


  • 157 Views
  • Updated 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.

Related searches for Predicting Class Testability using Object-Oriented 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 l.jpg

Predicting Class Testability using Object-Oriented Metrics

M. Bruntink and A. van Deursen

Presented by Tom Chappell


Slide2 l.jpg
Goal

  • To assess the capability of certain object-oriented metrics to predict class testability

  • Useful for:

    • Planning

    • Design

    • Monitoring


Source code metrics l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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