Back to Course
White Box Techniques

Cyclomatic Complexity

What is Cyclomatic Complexity?

Cyclomatic complexity is a software metric that measures the number of independent linear paths through a program's source code, used to gauge the complexity of a piece of code.

How It's Calculated

Using a Control Flow Graph (CFG), cyclomatic complexity is calculated as:

V(G) = E − N + 2, where E is the number of edges and N is the number of nodes in the graph.

Why It Matters for Testing

  • It indicates the minimum number of test cases needed to achieve full path coverage.
  • Higher complexity values suggest code that is harder to test, understand, and maintain.
  • It helps identify modules that may need to be refactored to reduce risk.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course