This is also a **software testing** type in which the source code of the software is checked line by line. The main objective is to check all the possible paths that the compiler may use to reach the output for the software.

Generally, path means the road or the way through the program control or data flows through a software. Basis path is based on the idea that a software has multiple entry and exit point. In this testing, this has to be checked that which entry and exit point is being followed by the software.

The aim of this testing is to check all the basis paths of the software.

To understand the software's basis path, we need to understand the **Cyclomatic Complexity** which is the metric to calculate all the independent paths inside the software.

This has to be understood that, **basis path testing is totally a white box testing**, as here the major concern is to test the source code and nothing is check in the outer part of the software or any part of the interface.

It is tested whether the data or the control flow follows all possible independent paths which are logically correct. This is a coverage based testing and tries to use the minimum number of test cases while executing the basis path.

Here, it is also checked that while following any of the** independent paths**, the software is able to reach a destination or a correct, consistent and atomic output.

Below with the help of a simple block diagram, we shall see how there can be more than one independent paths inside a software, which can be logically correct when the compiler scans the source code from either side.

As in the above diagram we have seen how the software is program control should reach the destination node which is **NODE 6**.

Here, it is clearly visible how there are different **independent routes** which can be chosen to reach the last or the destination node.

Here, we have seen that, the independent routes are: **1-2-3-4-5-6**, **1-7-5-6** and **1-8-5-6** respectively.

The basic and most common steps for performing basis path testing is:

- Creating
**CFG**(Control Flow Graph) to determine different independent paths. - Calculating the
**Cyclomatic Complexity**which is a metric to determine the number of independent logical routes. - Calculate a
**set of Basis set of paths**. - Create a
**test case**to execute the program flow for each path.

To understand **Cyclomatic Complexity**, we have to understand we should have an intuitive idea of software metric.

Software Metric is nothing but a quantity by which we can measure any property or attribute of a software in terms of **time, cost, size, **and** effort**.

Cyclomatic Complexity is a software metric for measuring the complexity of a program. This is used for calculation of independent path in a software or a program through which the program control may flow.

When we say independent path, it means that it is the path which has at least one edge which has not been traversed before any other paths.

Let us understand the notations first. Let us see the graph below.

Let us understand the flow graph notation:

The complexity of the code can be computed using the below formula:

V(G) = E - N + 2

Here, **E** is the number of edges.

**N** is the Number of Nodes.

V(G) = P + 1

Here, P is the number of predicate notes, which means that this node does not contain any condition.

Let us take an example of a program below:

```
a = 0;
n=4;
while (a<n-1) do
b = a + 1;
while (b<n) do
if A[a]<A[b] then
swap(A[a], A[b]);
end do;
a=a+1;
end do;
```

The graph for the above program will be:

Now let us compute, V(G) = 9-7+2 = 4. ** (**E-N+2**)**

Also, V(G) = 3+1. **(**P+1**)**.

Let us now see what are the **basis paths** of the program. The independent paths are:

1-7, 1-2-6-1-7, 1-2-3-4-5-2-6-1-7, 1-2-3-4-5-2-6-1-7 and 1-2-3-5-2-6-1-7.

We shall not go deeper into the study of Cyclomatic Complexity. As we are concerned only about the basis path and all out independent paths are out **basis paths**.

There are different tools for computing the **Cyclomatic Complexity** of a graph. They are:

**GMetrics:**This is used to find Matrix in Java-based applications.**DevMetrics:**This is used to find Matrix in C# based applications.**NDepends:**This is used to find Matrix in Java-based applications.**OCLint:**This is a static code analyzer for C and all its related languages.

- As it is a white box testing, therefore this is one of the core testings which helps to confirm and reassure all other white box testings.
- It takes care of the logic along with all the basis path testing and thus code-testing can be omitted.
- Test cases for this testing are designed in such a way so that all the paths are testing, and thus all the hidden error can also be found and seen.
- Helps to reduce other tests and reduce if there any chance of any deadlock in the software.

In Basis Path testing all the possible **independent-paths** through which the program or the software execution can flow and reach the output or the end. Different test cases are designed for executing different basis paths. **Basis Path testing is purely a white box testing and also performs all the logical checks.**

For finding the basis paths, we have to first compute the cyclomatic complexity and then the test cases are deployed. There are different tools to compute Basis Path Testing, they are: **GMetrics, DevMetrics, NDepends and OCLint**.

I am starting **new Protractor training batch on Weekends**. Course starts from __24-Aug-2019 [10am IST to 1 pm IST]__ based on online.

Interested people can confirm the seat by calling to +91 8971673487 or whatsapp to +91 9003381224.**You can attend first class(3 hours) for free. Only 10 Seats in Total**

Find the course content : View Content

Interested people can confirm the seat by calling to +91 8971673487 or whatsapp to +91 9003381224.

Find the course content : View Content