Pages

Wednesday, September 8, 2010

Software Testing Techniques used in 'Online Fresh Food Store'

Software testing is a critical element of software quality assurance and represents the ultimate review of specification, design, and code generation. The increasing visibility of software as a system element and the attendant costs associated with a software failure are motivating forces for well planned, through testing.
The main objectives of testing are listed below:
  • Testing is a process of executing a program with the intent of finding an error.
  • A good test case is one that has a high probability of finding an as-yet-undiscovered error. 
  • A successful test is one that uncovers an as-yet-undiscovered error.
Software is tested from two different perspectives: (1) internal program logic is exercised using "white-box" test case design techniques. (2) Software requirements are exercised using "black-box" test case design techniques. In both cases, the intent is to find the maximum number of errors with the minimum amount of effort and time.

Following are the two types of techniques, which have been used to test this project:
  • White-box testing
  • Black-box testing
  • Condition Testing
The condition testing method focuses on testing each condition in the program. Condition testing is a test case design method that exercises the logical conditions contained in a program module. A simple condition is a Boolean variable or a relational expression, possibly preceded with one NOT (-) operator. A relational expression takes the following form:
E1 < relational operator> E2

Where E1 and E2 are arithmetic expressions and <relational-operator> is one of the following: <, ³ , =, ¹ , £ , >. A compound condition is composed of two or more simple conditions, Boolean operators, and parentheses. A condition without relational expressions is referred to as a Boolean expression. The possible types of elements in a condition include a Boolean operator, a Boolean variable, a pair of Boolean parentheses, a relational operator, or an arithmetic operator. If a condition is incorrect, then at least one component of the condition is incorrect. Therefore, types of errors in a condition include the following
  • Boolean operator error
  • Boolean variable error 
  • Boolean parenthesis error 
  • Relational operator error
  • Arithmetic expression error
The purpose of condition testing is to detect not only errors in the conditions of a program but also other errors in the program. A number of condition testing strategies have been proposed. Branch testing is the simplest condition testing strategy. For a compound condition C, the true and false branches of C and every condition in C need to be executed at least once. Domain testing requires three or four tests to be derived for a relational expression. For a relational expression of the form.
E1 <relational operator> E2
Three tests are required to make the value of E1 grater than, equal to, or less than that of E2. If relational operator is incorrect and E1 and E2 are correct, then these three tests guarantee the detection of the relational operator error.
For a Boolean expression with n variables, all of 2n possible tests are required (n>0). This strategy can detect Boolean operator, variable, and parenthesis errors, but it is practical only if n is small. Error-sensitive tests for Boolean expressions can be derived. For a singular Boolean expression, we can easily generate a test set with less than 2n tests such that this test set guarantees the detection of multiple boolean operator errors and is also effective for detecting other errors.
For example, in this project, the following code segment checks if an item is already present in the shopping cart then instead of adding the same product again, the quantity is incremented.
if ( !bAlreadyInCart ) {
      iNumberOrdered++;
}
A technique called BRO (branch and relational operator) testing technique guarantees the detection of branch and relational operator errors in a condition provided that all Boolean variables and relational operators in the condition occur only once and have common variables. The BRO strategy uses condition constraints for a condition C. A condition constraint for C with n simple conditions is defined as (D1, D2, …, Dn), where Di (0 < i £ n) is a symbol specifying a constraint on the outcome of the ith simple condition in condition C. A condition constraint D for condition C is said to be covered by an execution of C if, during this execution of C, the outcome of each simple condition in C satisfies the corresponding constraint in D.

For a Boolean variable, B, we specify a constraint on the outcome of that states that B must be either true or false. Similarly, for a relational expression, the symbols >, =, < are used to specify constraints on the outcome of the expression. Consider the following example:
C1 : B1 & B2

Where B1 and B2 are Boolean variables. The condition constraint C1 is of the form (D1, D2), where each D1 and D2 is t or f. The value (t, f) is a condition constraint for C1 and is covered by the test that makes the value of B1 to be true and all the value of B2 false. The BRO testing strategy requires that the constraint set {(t, t), (f, t), (t, f)} be covered by the executions of C1. If C1 is incorrect due to one or more Boolean operator errors, at least one of the constraint set will force C1 to fail.