Lecture 4 Unit Testing Part 1
Lecture 4 Unit Testing Part 1
Note. This form of testing is focused on the input domain; however, it would be a good
supplement to apply this technique to develop range-based test cases as well.
Example 1: Robust Normal Boundary Value
Testing
The basic idea of robust normal boundary value testing is to use input
variable values at:
• just below the minimum,
• minimum,
• just above the minimum,
• a nominal value,
• just below their maximum,
• at their maximum,
• just above their maximum.
Again, single fault assumption is made.
It is not difficult to see that the number of cases will increase to 24.
Example 1: Worst-Case and Robust Worst-Case Boundary Value
Testings
• Rejection of single fault assumption significantly increases the number of
test cases.
• In Worst-Case Boundary Value Testing all combinations of 5 values for
each of the variables (minimum, just above the minimum, a nominal
value, just below their maximum, maximum) should be considered. We
also rule out the case where all variables have nominal values. This
gives cases.
• For Robust Worst-Case Boundary Value Testing the number of cases
will be .
Exercise 1. List Robust Normal Boundary Value Test cases for the Example 1.
Exercise 2. Show that some of 624 cases for Worst-Case Boundary Value Testing for
the Example 1 coincide (redundancy).
Limitations of Boundary Value Analysis
• Boundary value analysis works well when the program to be tested is a
function of several independent variables.
• This means that the function’s domain is a Cartesian product of the
domains of each of its parameters. E.g., in the Example 1 function
ITECH7409StudentGrade(lab_test, a1, a2, exam)
is defined on the set
• However, as you will see in the next example, even independency of the
parameters doesn’t guarantee that all “crucial” cases will be analysed in
Boundary Value Analysis.
Exercise 3. In the textbook find definition of Cartesian product, read and
understand it. In case you have questions, ask your tutor for assistance.
Limitations of Boundary Value Analysis: Example
2
Let’s assume we want to apply a boundary value analysis to a function
def is_ITECH7409_D_Student (lab_test, a1, a2, exam)
that takes marks of four assessment tasks in ITECH7409, calculates the grade,
and if the grade is D, returns True, otherwise, returns False.
It is not difficult to see that boundary value analysis is of little value in testing
this function:
• Expected outputs for the cases in the Normal Boundary Value Testing table
are all below C. There are no D’s.
• Most of the “interesting” cases consist of “nominal” (non-boundary) values.
Exercise 4. Explain, why in testing function, is_ITECH7409_D_Student, it is
important to consider cases consisting of non-boundary values of the
parameters.
Limitations of Boundary Value Analysis
Overall, boundary value analysis has the following significant limitations:
• Parameters of the tested function should be of comparable (say, numerical)
types.
• There could be significant redundancies in boundary value analysis, where
different cases are essentially the same or very close in meaning.
• Also, usually boundary value analysis doesn’t cover all suspicious cases,
i.e., there could be huge gaps in test coverage.
Boundary value analysis test cases are rudimentary because they are derived
with no consideration of the nature of the function, nor of the semantic
meaning of the variables.
Mathematical Detour: Relations
Definition Given two sets A and B, a relation R is a subset of the Cartesian
product A × B.
In other words, a relation R on the set A × B is a subset of the set of all
ordered pairs from A × B.
Two notations are popular:
• when we wish to speak about the entire relation, we usually just write R⊆
A × B.
• for specific elements a ∈ A, b ∈ B, we write a R b if (a,b) ⊆ A × B.
Examples:
• “=“ is reflexive, symmetric and transitive.
• “>” is antisymmetric and transitive.
• “≠” is symmetric.
Equivalence Relations and Partitions of Sets
Definition A relation R ⊆ A × A is an equivalence relation if R is reflexive,
symmetric, and transitive.
Definition Given a set A, and a set of subsets A1, A2, …, An of A, the subsets
are a partition of A iff A1 ∪ A2 ∪ … ∪ An = A, and i ≠ j ⇒ Ai ∩ Aj = ∅.
Exercise 6. What other test cases would you add to the table in the previous
slide? Explain your answer. Please be aware that there could be multiple
solutions.
Other Black-Box Testing Techniques: Special Value
Testing
• Special value testing, also called ad hoc testing, occurs when the test cases
are devised based on:
• domain knowledge,
• experience with similar programs,
• information about weak spots, etc.
• There are no guidelines used other than “best engineering judgment.”
• It is the most intuitive, least uniform and, probably, most widely practiced
form of functional testing.
• As a result, special value testing is very dependent on the abilities of the
tester.
Other Black-Box Testing Techniques: Random Testing
• In random testing the basic idea is that a random number generator is used
to pick test case values.
• The main question to be answered is: how many random test cases are
sufficient?
• To answer this question the tester requires expertise in probability and
statistics + the program domain knowledge.
Black-Box Testing: Decision Tables
Decision tables are used to represent and analyse complex logical
relationships. They are ideal for describing situations in which several
combinations of actions are taken under varying sets of conditions.
Below the basic decision table terms are illustrated:
Stab Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6
c1 T T T F F F
Conditions c2 T T F T T F
c3 T F - T F -
a1 X X X
a2 X X
Actions
a3 X X
a4 X X
Possible Decision Table for Example 1
Stab Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 8
T - - - - - - -
- T - - - - - -
- - T - - - - -
- - - T - - - -
- - - - T - - -
- - - - - T - -
- - - - - - T -
- - - - - - - T
Invalid X X
F X
MF X
P X
C X
D X
HD X