So I have known quite a few testers that have faced a really hard time when they were introduced to Cyclomatic Complexity. But I do believe that the thing is not larger than an intimidating name for a really useful metric. Let’s get started!
What are software metrics?
You can never fully understand Cyclomatic Complexity without full realization of what are software metrics exactly. Software metrics are simply units of measurement, and while mere measurement is simple quantitative indication of any value like size or capacity of something, software metrics are measurements of any attribute of the software and are calculated with respect to other values, such as schedules, end-price, quality, etc. Here is an example: hours are units of measurement, whilst required man-hours (amount of hours required for one individual to perform a task) are metrics.
Off, to the point we go now!
Cyclomatic Complexity is one of such software metrics. It is commonly used to measure program complexity. Literally, independent paths throughout your software’s source code are being measured.
Also here are several tips:
- What may be considered an independent path? Why any path that includes a minimum of one edge that hasn’t been travestied before.
- Cyclomatic Complexity may and should be measured and calculated with proper respect to modules, classes, methods and functions of the program.
- How to use this in testing? Ok, there is a thing called Basis Path Testing and it is done while White Box techniques are being used. So this Basis Path method guides you to testing of every single linearly independent path. And the precise number of necessary test cases will be the equivalent of your software’s complexity.
Now that wasn’t too hard, was it?