U3, Black Box Testing PDF
U3, Black Box Testing PDF
3
Black Box Testing
Introduction:
Consider an example of two variables, A and B. If we consider all the above combinations with
Nominal values, then following test cases (see Fig. 4.3) can be designed:
1. Anom, Bmin 4. Anom, Bmax– 7. Amax, Bnom
2. Anom, Bmin+ 5. Amin, Bnom 8. Amax–, Bnom
3. Anom, Bmax 6. Amin+, Bnom 9. Anom, Bnom
For n variables in a module, 4n + 1 test cases can be designed with BVC method.
Boundary Value Analysis (BVA)
2. Robust Testing Method:
When test cases are designed considering the below points in addition to BVC, it is called
Robustness testing.
In the previous example of two variables, A and B, the following test cases are added.
1. Anom, Bmin 4. Anom, Bmax– 7. Amax, Bnom 10. Amax+, Bnom 13. Anom, Bmin–
2. Anom, Bmin+ 5. Amin, Bnom 8. Amax–, Bnom 11. Amin–, Bnom
3. Anom, Bmax 6. Amin+, Bnom 9. Anom, Bnom 12. Anom, Bmax+
For n input variables in a module, 6n + 1 test cases can be designed with Robustness Testing.
Boundary Value Analysis (BVA)
3. Worst Case Testing Method:
If extended the concept of BVC by assuming more than one variable on the boundary. It is
called Worst Case Testing.
In the previous example of two variables, A and B, the following test cases are added:
1. Anom, Bmin 6. Amin+, Bnom 11. Amin+, Bmin 16. Amax, Bmin+ 21. Amin+, Bmax-
2. Anom, Bmin+ 7. Amax, Bnom 12. Amin, Bmin+ 17. Amax-, Bmin+ 22. Amax, Bmax
3. Anom, Bmax 8. Amax–, Bnom 13. Amin+, Bmin+ 18. Amin, Bmax 23. Amax-, Bmax
4. Anom, Bmax– 9. Anom, Bnom 14. Amax, Bmin 19. Amin+, Bmax 24. Amax, Bmax-
5. Amin, Bnom 10. Amin, Bmin 15. Amax-, Bmin 20. Amin, Bmax- 25. Amax-, Bmax-
for n input variables in a module, 5n test cases can be designed with Worst Case Testing.
Boundary Value Analysis (BVA)
Example 1: A program reads an integer number within the range [1,100] and determines whether it
is a prime number or not. Design test cases for this program using BVC, Robust Testing, andWorst Case
Testing methods.
i. Test cases using BVC:
Only ONE variable is used; Hence, total no. of test cases = 4n+1 = 4(1)+1 = 5
Min, Max & Nominal values: Min = 1, Min+ = 2, Max = 100, Max- = 99, Nom = 50 to 55
Hence, Test cases are: Test case ID Integer Value Expected Output
1 1 Not a Prime Number
2 2 Prime Number
3 100 Not a Prime Number
4 99 Not a Prime Number
5 53 Prime Number
Partition based on Valid & Invalid inputs: I3 = {<m, d, y> : 1900 ≤ y ≤ 2025} Valid
I4 = {<m, d, y> : m < 1} Invalid
I5 = {<m, d, y> : m > 12} Invalid
I6 = {<m, d, y> : d < 1} Invalid
Test cases are: I7 = {<m, d, y> : d > 31} Invalid
Test Expected Class Covered I8 = {<m, d, y> : y < 1900} Invalid
mm dd yy
case ID Result by the Test case
I9 = {<m, d, y> : y > 2025} Invalid
1 5 20 1996 20-5-1996 I1, I2, I3
2 0 13 2000 Invalid I4
3 13 13 1950 Invalid I5
4 12 0 2007 Invalid I6
5 6 32 1956 Invalid I7
6 11 15 1899 Invalid I8
7 10 19 2026 Invalid I9
State Table based Testing
Few basic terms:
1.Finite State Machine: An FSM is a behavioural model whose outcome depends upon
both previous and current inputs.
2.State Transition Diagrams / State Graphs: A system or its components may have a
number of states depending on its input and time. States are represented by Nodes and the
inputs causes a state to undergo a change and form into a new state. In such a case, it is said to
have a Transitions occurred. Example:
In the graph, each Arrow Link provides:
i. Transition Events like Admitted, Wait, etc.,
ii. The Resulting output because of the event
Like T1, T4, etc.,
3.State Table: State graphs are difficult to understand, hence convert it into a table, for
better convenience. Its conventions are:
Each row of the table corresponds to a state.
Each column corresponds to an input condition.
The box at the intersection of a row and a column specifies the next state (transition) and
the output, if any.
State Table based Testing
Few basic terms:
3.State Table:
A2 X X …
A3 X …
Condition stub: It is a list of input conditions for which the complex combination is made.
Action stub: It is a list of resulting actions which will be performed if a combination of input
condition is satisfied.
Condition entry: It is a specific entry in the table corresponding to input conditions
mentioned in the condition stub. When we enter TRUE or FALSE for all input conditions for
a particular combination, then it is called a Rule. Hence, a Rule may be defined as the
combination of conditions produces the resulting action.
Decision Table based Testing
When the condition entry takes only two values—TRUE or FALSE, then it is called Limited
Entry Decision Table. When the condition entry takes several values, then it is called
Extended Entry Decision Table.
In limited entry decision table, condition entry, which has no effect whether it is True or False,
is called a Don’t-Care state or immaterial state (represented by I). The state of a don’t-
care condition does not affect the resulting action.
Action entry: It is the entry in the table for the resulting action to be performed
when one rule (which is a combination of input condition) is satisfied. ‘X’ denotes the action
entry in the table.
Day
1 2 3 ID Hour Result
Stub
C3: Retailer F F T F T F T I
Stub
A2: Discount of 8% X X
A3: Discount of 10% X X X
A4: Discount of 12% X
A5: Discount of 15% X
Decision Table based Testing
Example 2: A wholesaler has three commodities to sell and has three types of customers. Discount is given as per the
following procedure: (i) For DGS & D orders, 10% discount is given irrespective of the value of the order. (ii) For orders of
more than Rs 50,000, agents get a discount of 15% and the retailer gets a discount of 10%. (iii) For orders of Rs 20,000 or
more and up to Rs 50,000, agents get 12% and the retailer gets 8% discount. (iv) For orders of less than Rs 20,000, agents
get 8% and the retailer gets 5% discount.These rules do not apply to the furniture items wherein a flat rate of 10% discount
is admissible to all customers irrespective of the value of the order. Design test cases using decision table testing.
Expected
Test Is the Order
Type of Discount
case Product Value
Customer (Expected
ID Furniture? (Rs.)
Result)
1 DGS & D No 51,000 10%
2 Agent No 52,000 15%
3 Retailer No 53,000 10%
4 Agent No 23,000 12%
5 Retailer No 27,000 8%
6 Agent No 15,000 8%
7 Retailer No 18,000 5%
8 Agent Yes 34,000 10%
Cause-Effect Graphing based Testing
Another way to consider all valid combinations of input conditions is, to consider all valid
combinations of the equivalence classes of input conditions. If there are n different input
conditions, such that a combination is valid, then 2n test cases are expected.
Cause-effect graphing techniques help in selecting combinations of input conditions in a
systematic way, so that the number of test cases do not become unmanageably large.
2. Not: if x is 1, y is 0; else y is 1.
3. Or: if x or y or z is 1, A is 1; else A is 0.
7. One and only One: one and only one of x & y must be 1.
9. Mask: if x is 1, y is forced to 0.
Cause-Effect Graphing based Testing
Example 1:A program has been designed to determine the nature of roots of a quadratic equation.The
quadratic equation takes three input values from the range [0,100]. Design the test cases using
cause-effect graphing technique. Figure 4.6 Cause-Effect Graph
Solution:
Cause and Effects of the problem:
C1: a ≠ 0
C2: b = 0
C3: c = 0
C4: D > 0 where D is b2 – 4ac
C5: D < 0
C6: D = 0
C7: a = b = c
C8: a = c = b/2
E1: Not a quadratic equation
E2: Real roots
E3: Imaginary roots
E4: Equal roots
Cause-Effect Graphing based Testing
R1 R2 R3 R4 R5 R6 R7
Solution: C1: a ≠ 0 T T T T T T F
C2: b = 0 F I I T F F I
Condition
C3: c = 0 I F I T F F I
Stub
C4: D > 0 where D is b2 – 4ac T F F F F F I
C5: D < 0 F T F F T F I
C6: D = 0 F F T T F T I
C7: a = b = c F I F F T F I
C8: a = c = b/2 F F I F F T I
A1: Not a quadratic equation X
Action Stub
For example, In the roots calculation of a quadratic equation, special cases are as follows:
What will happen when a = 0? Though, we do consider this case, there are chances that we
overlook it while testing, as it has two cases:
(i) If a = 0 then the equation is no longer quadratic.
(ii) For calculation of roots, division is by zero.
What will happen when all the inputs are negative?
What will happen when the input list is empty?