Software Testing
Software Testing
SOFTWARE • Why?
TESTING • When?
• Who?
What is Software Testing?
• To find out the errors in the software
• How?
Work Product?
• Test Specification documents
VERIFICATION AND VALIDATION
Solutions
• delay many tests until
stubs are replaced
Stubs are used in place with actual modules,
of subordinates of main • develop stubs that
perform limited
module functions
• integrate the software
from the bottom of
the hierarchy upward.
BOTTOM-UP INTEGRATION
Procedure
• Low-level components are combined into clusters
• A driver is written to coordinate test case input and
output.
• The cluster is tested.
• Drivers are removed and clusters are combined
moving upward
REGRESSION TESTING
A build includes all data files, libraries, reusable modules, and engineered
components that are required to implement one or more product
functions.
tests is designed to expose errors that will keep the build from properly
performing its function.
The build is integrated with other builds, and the entire product is smoke
tested daily.
VALIDATION TESTING
The function or performance characteristic conforms to specification and is accepted deviation from
specification is uncovered and a deficiency list is created.
SYSTEM TESTING
• Predicate Node
• Region
INDEPENDENT PROGRAM PATHS
Path 1: 1-11
Path 2: 1-2-3-4-5-10-1-11
Path 3: 1-2-3-6-8-9-10-1-11
Path 4: 1-2-3-6-7-9-10-1-11
1-2-3-4-5-10-1-2-3-6-8-9-10-1-11 ?????
How do you know how many paths to look for?
• software metric that provides a quantitative measure
CYCLOMATIC of the logical complexity of a program.
If (a<b)
F1 () ;
else
If (a<c)
F2 () ;
else
F3 () ;
CYCLOMATIC COMPLEXITY?
If (a<b)
F1 () ;
else
If (a<c)
F2 () ;
else
F3 () ;
1. begin int x, y, power;
2. float z;
3. input(x, y);
4. if(y<0)
5. power = -y;
6. else power = y;
7. z=1;
8. while(power!=0)
9. { z=z*x;
10. power=power-1;
11. } if(y<0)
12. z=1/z;
13. output(z);
14. end
int main()
{
1 int n, index;
2 cout << "Enter a number: " <> n;
3 index = 2;
4 while (index <= n - 1)
5 {
6 if (n % index == 0)
7 {
8 cout << "It is not a prime number" << endl;
9 break;
10 }
11 index++;
12 }
13 if (index == n)
14 cout << "It is a prime number" << endl;
15 } // end main
int main()
{
1 int n, index;
2 cout << "Enter a number: " <> n;
3 index = 2;
4 while (index <= n - 1)
5 {
6 if (n % index == 0)
7 {
8 cout << "It is not a prime number" << endl;
9 break;
10 }
11 index++;
12 }
13 if (index == n)
14 cout << "It is a prime number" << endl;
15 } // end main
CYCLOMATIC COMPLEXITY?
i = 0;
n=4; //N-Number of nodes present in the graph
while (i<n-1) do
j = i + 1;
while (j<n) do
if A[i]<A[j] then
swap(A[i], A[j]);
end do;
j=j+1;
end do;
CYCLOMATIC COMPLEXITY?
i = 0;
n=4; //N-Number of nodes present in the graph
while (i<n-1) do
j = i + 1;
while (j<n) do
if A[i]<A[j] then V(G) = 9 – 7 + 2 = 4
V(G) = 3 + 1 = 4 (Condition nodes are 1,2 and 3 nodes)
swap(A[i], A[j]); Basis Set – A set of possible execution path of a program
1, 7
end do; 1, 2, 6, 1, 7
j=j+1; 1, 2, 3, 4, 5, 2, 6, 1, 7
1, 2, 3, 5, 2, 6, 1, 7
end do;
GRAPH MATRICES
• focuses on testing each condition in the program to ensure that it does not contain errors
• The data flow testing method [Fra93] selects test paths of a program according to the locations of
definitions and uses of variables in the program.
• DEF(S) = {X | statement S contains a definition of X}
• Start at the innermost loop. Set all other loops to minimum values.
• Conduct simple loop tests for the innermost loop while holding the outer
• loops at their minimum iteration parameter (e.g., loop counter) values. Add other tests
for out-of-range or excluded values.
• Work outward, conducting tests for the next loop, but keeping all other outer loops at
minimum values and other nested loops to “typical” values.
• Continue until all loops have been tested.
CONCATENATED LOOPS
• It divides the input domain of a program into classes of data from which test cases can be derived.
• Guidelines
• Range- 1 valid and 2 invalid classes
• Specific values- 1 valid and 2 invalid classes
• Member of set, 1 valid and 1 invalid class
• Boolean, 1 valid and 1 invalid class
BOUNDARY VALUE ANALYSIS
• Guidelines
• i/p specified as range bounded by values a and b- just above and below
• Specified a number of values-Test cases should be designed to create an output report that
produces the maximum and minimum allowable number of table entries.
• Prescribed boundary, exercise that data structure at its boundary.
OTRTHOGONAL ARRAY TETSING
The function should take MembershipDuration as a input. The function should calculate the
discount percentage based on the MembershipDuration. The discount percentages for
different membership durations are predefined and stored in a lookup table or configuration
file. The function should retrieve the discount percentage corresponding to the
MembershipDuration from the lookup table or configuration file. The predefined discount
rate for membership duration 5>x>=1 is 10%, for membership duration 10 >x >= 5 year is
12%, for more than or equal to 10 year is 15%.
TEST CASES