Slice Based Testing

The slice based testing is a technique to slice the code in multiple parts in such a way that every part could be executed successfully with respect to the given variable and line number.
The notation used for slice based testing is as S(v,n). Where

S: stands for Slice the code
v: variable under consideration
n: line number.

To further explain the concept, let’s study an example.

Let’s slice the code with respect to the variable x at line 9. In slicing notation, we would write it as S(x,9). We have to find the variable and its related statements till statement 9. If we observe the code,  the x has its declaration at line 6, we would include it as well. S(x,9) has two lines

But the above two lines of S(x,9) can not be executed independently. To execute these two lines, we need to add the syntax that is compulsory for program execution e.g. headers , curly braces and the main function etc. so the final slice code for S(x,9) would be

S(x,9) =1,2,4,5,6,9,14,15.

and
S(x,14) = 1,2,4,5,6,9,11,14,15.

This concept can be further digested by the following solved examples. /* upload the class activity picture from directory */