Cyclomatic complexity (or conditional complexity) is a software metric (measurement). It was developed by Thomas J. McCabe, Sr. in 1976 and is used to measure the complexity of a program. It directly measures the number of linearly independent paths through a program's source code.
Cyclomatic Complexity metric is based on the number of decision in a program.
Cyclomatic Complexity :- The number of independent paths through a program.
Cyclomaticcomplexity is defined as: L – N + 2P
where-
L = the number of edges/links in a graph-
N = the number of nodes in a graph-
P = the number of disconnected parts of the graph (e.g. a called graph or subroutine)
It doesn't take place in Manual testing . Neither it is a part of White Box... In fact It is the Part of Verification Static testing , It is done with the help of Static Analysis tools..
Cyclomatic Complexity can be calculated using either of two rules
1) Formal Formula
2 ) Decision Point rule
Decision point rule : Which says CC = Total number of Decision Point + 1.
Ex 1 :- void test::Test3()
{
string a,b,c,d,e,f;
if(((a==b)&&(e==f))||(f==a)||(a==b))
c=d;
else
c=f;
}
To find the cyclomatic Complexity of the above program :-
Cyclomatic Complexity :- Total number of Condition + 1.
hence in this Example:- there is only one if condition so the Cyclomatic Complexity is : 1+ 1 = 2.
Ex 2:-
Cyclomatic complexity (or conditional complexity) is a software metric (measurement). It was developed by Thomas J. McCabe, Sr. in 1976 and is used to measure the complexity of a program. It directly measures the number of linearly independent paths through a program's source code.
void func1()
{
int a,b,c,d;
while (1)
{
if (a>b)
print a
else if (b>c)
print b
else
print c
}}
No comments:
Post a Comment