Scertify™ Testability Metrics, a new product add-on of Scertify™ that measures the ability for a software artifact to be tested, has been released and is available for download. The add-on provides exclusive metrics and helps developers identifying software artifacts that are “refactoring-candidate”.
Scertify™ Testability Metrics is a product add-on and works with Scertify™ Professional (Eclipse) and Enterprise (Maven and CLI) editions.
Take a look at the features
- Exclusive metrics to measure the testability of software artifactsThe testability metric is a composite metric relying on three software quality metrics:
- Law of Demeter: The distance of the further object with which the method interacts. The distance of an object is computed by counting the number of method calls or field references required to access it. A low value is desirable. If the law of Demeter metric is too high, consider refactoring your code so that classes only communicate with their neighbors, which can mean delegating some logic to its neighbors.
- Injectability: Number of used instances that are non-injectable, per method. An injectable instances is an instance that can be provided to the method, either as a parameter, or via injection (constructor injection, setter injection, and field injection are all considered). A low value is desirable. If the injectability metric is too high, consider refactoring your code so that more instances are injectable. This will make your code less coupled and more testable.
- Cyclomatic Complexity: Evaluates the complexity of a method by counting the number of linearly independent paths. This is the number of test cases required to satisfy the “Basis Path Testing” strategy by McCabe, and is a good indicator for the number of test cases in general. A low value is desirable. If the cyclomatic complexity is too high, consider refactoring your code so that complex methods are modularized in several sub-methods. While the complexity of the algorithm remains, it makes the code easier to understand and test.
- Testability: The testability metrics aggregates the injectability, cyclomatic complexity, and law of Demeter metrics. The impact of the injectability metric is important and constant, as having too much non-injectables instances will increase the complexity of the test cases themselves. The impact of the cyclomatic complexity is fairly low with low values but grows exponentially with high values, as the cyclomatic complexity is only detrimental if it is fairly high. The law of Demeter metric has only a marginal impact on the final value. A low value is desirable. If the testability metric is too high, inspect the used metric to evaluate the required course of actions.
- Metrics computation for each project’s levelScertify™ Testability computes metrics values for each methods of a project, and provides the average at each level of a project: methods, classes, files and packages. This metric hierarchy helps developers quickly identifying a group of methods with potential testability problems.
- Identification of refactoring candidatesThanks to the testability metric computed by Scertify™, developers are able to easily identify the methods that potentially need to be refactored. Indeed, an artifact with both high complexity and having to call multiple other artifacts is a typical suspect for refactoring.
- Since metrics are managed the same way as rules with an MAJOR criticity, you’ll need to modify your project’s settings, in order to display the testability metric results. See how in this post
- In order to compute testability metrics with Scertify™ Professional, you’ll need to append your XML repository with the following lines:1234<Rules Priority="1" Criticity="MAJOR" Name="java::testability::LawOfDemeterMetric"/><Rules Priority="1" Criticity="MAJOR" Name="java::testability::TestabilityMetric"/><Rules Priority="1" Criticity="MAJOR" Name="java::testability::CyclomaticComplexityMetric"/><Rules Priority="1" Criticity="MAJOR" Name="java::testability::InjectabilityMetric"/>
About Scertify™ Professional