Prepared by: Dr.
Radziah Mohamad 1
Software Testing Tutorial
1. What is the difference between White Box and Black Box Testing?
2. You are asked to test a module, using Equivalence Partitioning and Boundary
Value Analysis, which calculates the cost of buying cans of soft drink from the
ABC Hypermarket. The basic cost per can is RM1, but discounts are available for
bulk orders. If you order between 20 and 199 cans you qualify for a 10 %
discount, while if you order 200 cans or more you qualify for a 20 % discount.
The module should take as input the required number of cans, and output the price
of the order.
3. You are shown the code for another module in the ABC Hypermarket system, this
time for calculating the cost of soft drink orders. The soft drink is sold in boxes of
12 bottles, and is of three types: A, B and C. The code is as follows:
Procedure CostOfSoft (in: no_of_boxA, no_of_boxB,
no_of_boxC; out: cost_to_customer) is
Begin
cost_of_boxA = 60;
cost_of_boxB = 80;
cost_of_boxC = 100;
if (no_of_boxA == 2)
discount = 5;
elsif (no_of_boxA == 1 AND no_of_boxB == 1)
discount = 8;
elsif (no_of_boxC == 3)
discount = 10;
else
discount = 0;
endif
cost_to_customer = ((no_of_boxA * cost_of_boxA) +
(no_of_boxB * cost_of_boxB) + (no_of_boxC *
cost_of_boxC)) * (100 - discount) / 100;
return (cost_to_customer);
end Procedure CostOfSoft;
a) Produce a flow graph for Procedure CostOfSoft.
b) Compute the cyclomatic complexity of procedure CostOfSoft and
explain how you arrived at your answer.
c) List all the independent path for the procedure CostOfSoft.
d) Provide test cases for the procedure CostofSoft, so that it can test at
least 50% of the statement coverage.
Prepared by: Dr. Radziah Mohamad 2
4.
Rectangle Module
Objective
To determine the type of square based on the input of its length of 4 sides
(A, B, C dan D):
If
A=B=C=D Square
A = B dan C = D Rectangle
Other than these 4 inputs
The type of the square can not be determined
(Pre-Condition)
The 4 inputs are positive integers
A , B , C, D > 0
(Post-Condition)
The type of square is determined
Or
The type of square is not determined
Referring to the Rectangle Module above:
a) By using the Equivalence Partitioning, identify how many input classes are
required to test the module. Name each class.
b) Give one example of the input value for each class you have identified in a).
c) By using the Boundary Value Analysis, identify the number of test data
required to perform a complete test.
d) List all the required test data.
Prepared by: Dr. Radziah Mohamad 3
5. Refer to Rectangle Module source code below, and answer question a), b), c) and
d)
#include <stdio.h>
#include <math.h>
void main()
{
int A,B,C,D,pilihan;
printf("\n\t\t**********************************");
printf("\n\t\CODE TO IDENTIFY TYPE OF RECTANGLE");
printf("\n\t\t**********************************");
printf ("\n\tEnter value A : ");
scanf ("%d",&A);
printf ("\n\tEnter value B : ");
scanf ("%d",&B);
printf ("\n\tEnter value C : ");
scanf ("%d",&C);
printf ("\n\tEnter value D : ");
scanf ("%d",&D);
if ((A==B) && (B==C) && (A==C) && (C==D))
printf ("\t Square\n");
else if ((A==B) && (C==D))
printf ("\t Rectangle\n");
else
printf("\n Unidentified rectangle \n");
a) Build a flow graph
b) Calculate the Cyclometic Complexity.
c) List all the independent paths.
d) Prepare test cases for the rectangle module.
Instruction:
1. Do this tutorial individually.
2. This tutorial MUST be submitted by Wednesday (9/04/2008) before 4 p.m. at my
office.
3. Failure to submit this tutorial on time will cost you 5 marks/day.