Static & Dynamic Testing

Calculate Cyclomatic complexity for a code that accepts a positive integer and displays the square root of the same.

  • Cyclomatic Complexity testing is a process that measures the complexity of a program.
  • Calculating the Cyclomatic Complexity there are two methods available:

  • Method 1
    i. Draw flow chart.
    ii. Calculate: CC = P + 1 (where, P is number of predictions)

    Method 2
    i. Draw flow graph.
    ii. Calculate: CC = E – N + 2 (where, E is number of edges and N is number of nodes)
  • Cyclomatic Complexity of a program which accept positive integer and displays square root of that integer the flowchart and flow graph are as follows:
Method 1
Calculating the Cyclomatic Complexity using Flowchart are as follows:

CC Positive Integer Flowchart

Formula: CC = (P + 1)
Here number of predictions are 2

Therefore, CC = (2 + 1 ) = 3
Cyclomatic Complexity using Flow Chart = 3

Method 2
Calculating the Cyclomatic Complexity using Flowgraph are as follows:

CC Positive Integer FlowGraph

Formula: CC = (E - N + 2)
Here number of edges are 8 and number of nodes are 7

Therefore, CC = 8 – 7 + 2 = 3
Cyclomatic Complexity using Flow Graph = 3

Compare Static vs Dynamic Testing.

Sr. No.Static TestingDynamic Testing
1.Testing is done without executing the program.Testing is done by executing the program.
2.This testing does the verification process.This testing does the validation process.
3.It focuses on the prevention of the defects.It focuses on finding and fixing the defects.
4.It involves checklist and process to be followed.It involves test cases for execution.
5.More cost effective than dynamic testing.Less cost effective.
6.It requires loads of meetings.Comparatively it requires lesser meetings.
7.Testing can be performed before compilation.Testing is performed after compilation.
8.It gives an assessment of code and documentation.It gives bugs or bottlenecks in the software system.
9.It covers the structural and statement coverage testing.It covers the executable file of the code.
10.Return on investment will be high as this process involved at early stage.Return on investment will be low as this process involves after the development phase.

Calculate Cyclomatic complexity for checking even/odd number.

  • Cyclomatic Complexity testing is a process that measures the complexity of a program.
  • Calculating the Cyclomatic Complexity there are two methods available:

  • Method 1
    i. Draw flow chart.
    ii. Calculate: CC = P + 1 (where, P is number of predictions)

    Method 2
    i. Draw flow graph.
    ii. Calculate: CC= E – N + 2 (where, E is number of edges and N is number of nodes)
  • Cyclomatic Complexity of a program which accept positive integer and displays square root of that integer the flowchart and flow graph are as follows:
Method 1
Calculating the Cyclomatic Complexity using Flowchart are as follows:

Even Odd FlowChart

Formula: CC = (P + 1)
Here number of predictions are 2

Therefore, CC = (1 + 1) = 2
Cyclomatic Complexity using Flow Chart = 2

Method 2
Calculating the Cyclomatic Complexity using FlowGraph are as follows:

CC Even Odd FlowGraph

Formula: CC = (E - N + 2)
Here number of edges are 7 and number of nodes are 7

Therefore, CC = 7 – 7 + 2 = 2
Cyclomatic Complexity using Flow Graph = 2