what is cyclomatic complexity? plz explain with example

Answer Posted / deep singh kushwaha

Cyclomatic complexity is a software metric (measurement) developed by Thomas McCabe 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.
One of the ways is counting the number of closed loops in the flow graph, and incrementing the number by one.
i.e.
M = Number of closed loops + 1
where
M = Cyclomatic number.
Implications for Software Testing
M is a lower bound for the number of possible paths through the control flow graph.
M is an upper bound for the number of test cases that are necessary to achieve a complete branch coverage.
For example, consider a program that consists of two sequential if-then-else statements.
if (c1) {
f1();
} else {
f2();
}
if (c2) {
f3();
} else {
f4();
}
To achieve a complete branch coverage, two test cases are sufficient here.
For a complete path coverage, four test cases are necessary.
The cyclomatic number M is three, falling in the range between these two values, as it does for any program.

please suggest me if i m wrong..
e-mail-deepsingh.154@gmail.com

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define performance and stress testing?

751


what is sanity test (or) build test?

665


which test strategy your are fallowing in your company?which documents u r using in software development life cycle?

1840


Difference between smoke and sanity testing

1309


Hi there, I am new to the world of testing. Is there any place where I can have a look at an actual specification documents or test plans or test cases. This will help me in generating a level of confidence. Looking forward to your replies

1464






Scenario-based testing Option 1 concentrates on actor and software interaction Option 2 misses errors in specifications Option 3 misses errors in subsystem interactions Option 4 Both 1 abd 2

3053


Give me an example of something you tried at work but did not work out so you had to go at things another way.

1660


What is meant by entry criteria and exit criteria in software testing?

689


What is a test scenario?

716


HI FRNDS, I HAVE 2.5 years OF exp In Manual Testing,Plz let me know if thr r any oppurtunities in any company in Bangalore ID:dsnithi@gmail.com Thanks in Advance

1672


Describe to me what you see as a process. Not a particular process, just the basics of having a process.

1727


How could we start writing testcases without having the FRS,BRS Docs? My Project has some docs that are related to explain the operations which will be done in the application. It is deployed in UAT server and is a maintainance project. Tell me some technipues or best way to provide the quality to application?

1735


What is quality center? How many built in tables does quality center have?

819


9.Data – driver automation typically includes?

2929


Can anyone please answer the below question on Manual Testing: Tell me about atleast 5 bugs you come across in your last testing?

1602