Software Engineering
LECTURE 20 – 21: SOFTWARE TESTING
1
White Box
Testing vs
Black Box
Testing
2
3
output
Black-Box Testing
requirements
events
input
Black Box
Testing
• Types of errors regarding functional requirements of software:
• -- Incorrect or missing functions
• -- Interface errors
• -- Error in data structure & external data base access
• -- Performance errors
• -- Initialization & termination errors
• No functional requirements NO Black Box Testing.
• Demonstrates that each function is fully operational.
• Uncovers different kind of errors than white box testing.
• Performed later in the testing process.
4
5
¨ Black box techniques derive a set of test cases
that satisfy the following criteria:
(1) Test cases reduce the number of
additional test cases that must be designed to
achieve reasonable testing
(2) Test cases that tell us something about the
presence or absence of classes of errors,
rather than errors associated only with the
specific test at hand.
¨ Black box techniques can supplement the test
cases generated by white box.
How to Design
Test Cases?
6
Equivalence
class
partitioning
Boundary
value
analysis
Cause /
effect
graphing (for
combination
s of input
conditions)
Error
Guessing
7
Equivalence Partitioning
• Type of Black Box Testing.
• select the right subset-the subset with the highest probability of finding
the most errors.
• The input domain of a program is partitioned into a finite number of
equivalence classes such that we can reasonably assume that a test of a
representative value of each class is equivalent to a test of any other value.
• By identifying this as an equivalence class, we are stating that if no error
is found by a test of one element of the set, it is unlikely that an error
would be found by a test of another element of the set.
Example
Travel service offers discounts to travelers based on their age.
◦ 0-4 years 100%
◦ 5-15 years 50%
◦ 16-64 years 0%
◦ 64 years and older 25%
Equivalence classes for age
◦ 0, 1, 2, 3, 4
◦ 5, 6, 7, …15
◦ 16, 17, 18, …64
◦ 65, 66, 67, …120
Similarly for destinations
◦ e.g., destination can be grouped based on regions (that have same fair)
Nothing special for name
8
9
Identifying Equivalence classes
 A key concept in the identification of classes is negation, i.e. If a
characteristic is identified as an equivalence class, then one should
immediately negate the characteristic in order to find examples of
classes which should cause the module to do something different such as
“generate an error message”.
 Partitioning each input condition into two or more groups.
 Two types of equivalence classes are identified:
1. Valid Equivalence Classes
2. Invalid Equivalence Classes
10
Identifying the Equivalence Classes
We have valid ECs and invalid Ecs
• Design tests such that each valid EC and each invalid EC are
included in at least one test case
• Test cases are based on the specifications not on code
• Better results are obtained in testing boundary values of ECs as
well.
• Very important to test boundaries. Rich source of very common
errors.
• More later on this.
11
Identifying the Equivalence Classes
• If an input condition specifies a range of values (for example, “the
item count can be from 1 to 999”), identify one valid equivalence
class (1 < item count < 999) and two invalid equivalence classes (item
count < 1 and item count > 999).
• If an input condition specifies the number of values (for example,
“one through six owners can be listed for the automobile”), identify
one valid equivalence class and two invalid equivalence classes (no
owners and more than six owners).
12
Identifying the Equivalence Classes
If an input condition specifies a set of input values and there is reason to
believe that the program handles each differently (e.g. “type of vehicle
must be BUS, TRUCK, TAXICAB, PASSENGER, or MOTORCYCLE”), identify a
valid equivalence class for each and one invalid equivalence class
(“TRAILER,” for example).
•If an input condition specifies a “must be” situation, such as “first
character of the identifier must be a letter,” identify one valid
equivalence class (it is a letter) and one invalid equivalence class (it is not
a letter)
13
Test Case and the Equivalence
Classes
•Formally, one test case per equivalence class should
be enough.
•A black box method aimed at increasing the
efficiency of testing and, at the same time, improving
coverage of potential error conditions
14
Test Case and the Equivalence
Classes
According to the equivalence class partitioning method:
• Each valid EC and each invalid EC are included in at least one test case.
• Note: equivalence CLASS!
• For an acceptable range of input integers is 1-10, we need at least one test with a value in the
range 1-10.
• Boundaries: 1 and 10
• Invalid EC classes might be EC with values < 1, another class > 10, another one - negative
numbers, ....
Definition of test cases is done separately for the valid and invalid ECs.
• Note: Run tests for invalid equivalence classes one at a time.
Weak/Strong Equivalence Classes
15
For an example SUT, suppose there are three input variables from three domains: A, B, C
A = A1 A
∪ 2 A
∪ 3 … A
∪ ∪ m where ai A
∈
B = B1 B
∪ 2 B
∪ 3 … B
∪ ∪ n where bi B
∈
C = C1 C
∪ 2 C
∪ 3 … C
∪ ∪ o where ci C
∈
Weak Equivalence Class Testing:
◦ Choosing one variable value from each equivalence class (one ai, bi, and ci) such that all classes are covered.
◦ # of test cases?
◦ max (|A|, |B|, |C|)
Strong Equivalence Class Testing:
◦ based on the Cartesian product of the partition subsets (A x B x C),
◦ i.e., testing all interactions of all equivalence classes.
◦ # of test cases?
◦ |A| x |B| x |C|
Example of Weak Equivalence Testing
Class (WETC) *
16
Number of WETCs need= Max number of equivalence classes among {A, B, C}
Given: |A| = 3, |B| = 4, |C| = 2
4 WETCs are enough
Example of Strong Equivalence Class
Testing (SECT)
17
|A| = 3,
|B| = 4,
|C| = 2
# of test cases
◦ 3x4x2= 24
Testing for Robustness
18
If error conditions are a high priority, we should extend strong
equivalence class testing to include both valid (E) and invalid inputs
(U)
◦ For example: age < 0 and age > 120
Again, robustness can be applied with WECT and SECT
NextDate Example
19
NextDate is a function with three variables: month, day, year. It returns the date of the day after
the input date.
◦ Limitation: 1812-2020
Treatment Summary:
◦ if it is not the last day of the month, the next date function will simply increment the day value.
◦ At the end of a month, the next day is 1 and the month is incremented.
◦ At the end of the year, both the day and the month are reset to 1, and the year incremented.
◦ Finally, the problem of leap year makes determining the last day of a month interesting.
Equivalence Classes
20
Valid Equivalence Classes
◦ M1 = {1 <= month <= 12}
◦ D1 = {1 <= day <= 31}
◦ Y1 = {1812 <= year <= 2020}
Poor Equivalence Classes
21
Valid Equivalence Classes
◦ M1 = {1 <= month <= 12}
◦ D1 = {1 <= day <= 31}
◦ Y1 = {1812 <= year <= 2020}
 Should take into account special cases
 Leap year, February
Better classes
22
Valid Equivalence Classes
◦ M1 = {1, 3, 5, 7,8, 10, 12}
◦ M2 = {4, 6, 9, 11}
◦ M3 = {2}
◦ D1 = {1 <= day <= 28}
◦ D2 = {29}
◦ D3 = {30}
◦ D4 = {31}
◦ Y1 = {year = 1900}
◦ Y2 = {1812 <= year <= 2020 AND (year != 1900) AND (year mod 4 = 0)}
◦ Y3 = {1812 <= year <= 2020 AND year mod 4 != 0 }
Weak Equivalent Class - Test cases
23
#test cases=maximum partition size (D)=4
Strong Equivalent Class Testing - Test cases
24
25
Black-Box Testing
Boundary-value Analysis
Boundary Value Analysis
The basic idea in boundary value testing is to select input variable values at
their:
Minimum
Just above the minimum
A nominal value
Just below the maximum
Maximum
26
27
Boundary-value Analysis
Boundary-value analysis differs from Equivalence Partitioning in two
respects:
1. Rather than selecting any element to represent an equivalence class,
boundary-value analysis requires that one or more elements be selected
such that each edge of the equivalence class is subjected to a test.
2. Rather than focusing attention on the input conditions (input space),
test cases are also derived by considering the result space (i.e., output
equivalence classes)
¨ if a module uses a file of records, how will program react if there are no records
on the file; also if a transaction file is used for updating a master file; have all
permutations of EOF conditions been considered.
¨ If a module is passed an array, what if it contains zero elements? when it
contains maximum number of elements, and so on a pointer to an array
accessing out side an array-boundary.
Errors at the boundaries
28
Experience indicates that programmers make mistakes in processing values at and near the
boundaries of equivalence classes.
◦ For example, suppose that method M is required to compute a function f1 when x≤ 0 is true and
function f2 otherwise.
◦ However, M has an error due to which it computes f1 for x<0 and f2 otherwise.
This fault is revealed when M is tested against x=0, but not if the input test set is, for
example, {-4, 7} derived using equivalence partitioning
In this example, the value x=0, lies at the boundary of the equivalence classes x≤0 and x>0.
Example
29
Function findPrice() has two parameters: an item code must be in the range 99..999 and
quantity in the range 1..100
Equivalence classes for code:
◦ E1: Values less than 99
◦ E2: Values in the range
◦ E3: Values greater than 999
Equivalence classes for qty:
◦ E4: Values less than 1.
◦ E5: Values in the range.
◦ E6: Values greater than 100
Example
30
An Address text box which allows maximum 500 characters. So, writing test cases for each
character once will be very difficult so that will choose boundary value analysis.
No characters
1 character
2 character
499 character
500 character
501 character
Example- Boundary Value Analysis
Equivalence and Boundary Value
Let's consider the behavior of
Order Pizza Text Box Pizza values
1 to 10 is considered valid. A
success message is shown.
31
Here is the test condition
Any Number greater than 10 entered in the
Order Pizza field(let say 11) is considered
invalid.
Any Number less than 1 that is 0 or below,
then it is considered invalid.
Numbers 1 to 10 are considered valid
Any 3 Digit Number say -100 is invalid.
Example- Boundary Value Analysis….
32
Construct Test sets
33
Test selection based on the boundary value analysis technique requires that tests must include,
for each variable, values at and around the boundaries
34
Advantages of EC and BVA
1. Reduces the number of test cases that must be run, thus reduces the cost
2. Eliminates the fuzzy criteria of test data selection that is inefficient
3. Helps identify the different classes for which the program is not working properly
35
Error-Guessing
Some people design the test cases by intuition and
experience.
The basic idea is to enumerate a list of possible errors and
then write test cases based on the list.
36

BlackBox Testing in detail with examples.pptx

  • 1.
    Software Engineering LECTURE 20– 21: SOFTWARE TESTING 1
  • 2.
  • 3.
  • 4.
    Black Box Testing • Typesof errors regarding functional requirements of software: • -- Incorrect or missing functions • -- Interface errors • -- Error in data structure & external data base access • -- Performance errors • -- Initialization & termination errors • No functional requirements NO Black Box Testing. • Demonstrates that each function is fully operational. • Uncovers different kind of errors than white box testing. • Performed later in the testing process. 4
  • 5.
    5 ¨ Black boxtechniques derive a set of test cases that satisfy the following criteria: (1) Test cases reduce the number of additional test cases that must be designed to achieve reasonable testing (2) Test cases that tell us something about the presence or absence of classes of errors, rather than errors associated only with the specific test at hand. ¨ Black box techniques can supplement the test cases generated by white box.
  • 6.
    How to Design TestCases? 6 Equivalence class partitioning Boundary value analysis Cause / effect graphing (for combination s of input conditions) Error Guessing
  • 7.
    7 Equivalence Partitioning • Typeof Black Box Testing. • select the right subset-the subset with the highest probability of finding the most errors. • The input domain of a program is partitioned into a finite number of equivalence classes such that we can reasonably assume that a test of a representative value of each class is equivalent to a test of any other value. • By identifying this as an equivalence class, we are stating that if no error is found by a test of one element of the set, it is unlikely that an error would be found by a test of another element of the set.
  • 8.
    Example Travel service offersdiscounts to travelers based on their age. ◦ 0-4 years 100% ◦ 5-15 years 50% ◦ 16-64 years 0% ◦ 64 years and older 25% Equivalence classes for age ◦ 0, 1, 2, 3, 4 ◦ 5, 6, 7, …15 ◦ 16, 17, 18, …64 ◦ 65, 66, 67, …120 Similarly for destinations ◦ e.g., destination can be grouped based on regions (that have same fair) Nothing special for name 8
  • 9.
    9 Identifying Equivalence classes A key concept in the identification of classes is negation, i.e. If a characteristic is identified as an equivalence class, then one should immediately negate the characteristic in order to find examples of classes which should cause the module to do something different such as “generate an error message”.  Partitioning each input condition into two or more groups.  Two types of equivalence classes are identified: 1. Valid Equivalence Classes 2. Invalid Equivalence Classes
  • 10.
    10 Identifying the EquivalenceClasses We have valid ECs and invalid Ecs • Design tests such that each valid EC and each invalid EC are included in at least one test case • Test cases are based on the specifications not on code • Better results are obtained in testing boundary values of ECs as well. • Very important to test boundaries. Rich source of very common errors. • More later on this.
  • 11.
    11 Identifying the EquivalenceClasses • If an input condition specifies a range of values (for example, “the item count can be from 1 to 999”), identify one valid equivalence class (1 < item count < 999) and two invalid equivalence classes (item count < 1 and item count > 999). • If an input condition specifies the number of values (for example, “one through six owners can be listed for the automobile”), identify one valid equivalence class and two invalid equivalence classes (no owners and more than six owners).
  • 12.
    12 Identifying the EquivalenceClasses If an input condition specifies a set of input values and there is reason to believe that the program handles each differently (e.g. “type of vehicle must be BUS, TRUCK, TAXICAB, PASSENGER, or MOTORCYCLE”), identify a valid equivalence class for each and one invalid equivalence class (“TRAILER,” for example). •If an input condition specifies a “must be” situation, such as “first character of the identifier must be a letter,” identify one valid equivalence class (it is a letter) and one invalid equivalence class (it is not a letter)
  • 13.
    13 Test Case andthe Equivalence Classes •Formally, one test case per equivalence class should be enough. •A black box method aimed at increasing the efficiency of testing and, at the same time, improving coverage of potential error conditions
  • 14.
    14 Test Case andthe Equivalence Classes According to the equivalence class partitioning method: • Each valid EC and each invalid EC are included in at least one test case. • Note: equivalence CLASS! • For an acceptable range of input integers is 1-10, we need at least one test with a value in the range 1-10. • Boundaries: 1 and 10 • Invalid EC classes might be EC with values < 1, another class > 10, another one - negative numbers, .... Definition of test cases is done separately for the valid and invalid ECs. • Note: Run tests for invalid equivalence classes one at a time.
  • 15.
    Weak/Strong Equivalence Classes 15 Foran example SUT, suppose there are three input variables from three domains: A, B, C A = A1 A ∪ 2 A ∪ 3 … A ∪ ∪ m where ai A ∈ B = B1 B ∪ 2 B ∪ 3 … B ∪ ∪ n where bi B ∈ C = C1 C ∪ 2 C ∪ 3 … C ∪ ∪ o where ci C ∈ Weak Equivalence Class Testing: ◦ Choosing one variable value from each equivalence class (one ai, bi, and ci) such that all classes are covered. ◦ # of test cases? ◦ max (|A|, |B|, |C|) Strong Equivalence Class Testing: ◦ based on the Cartesian product of the partition subsets (A x B x C), ◦ i.e., testing all interactions of all equivalence classes. ◦ # of test cases? ◦ |A| x |B| x |C|
  • 16.
    Example of WeakEquivalence Testing Class (WETC) * 16 Number of WETCs need= Max number of equivalence classes among {A, B, C} Given: |A| = 3, |B| = 4, |C| = 2 4 WETCs are enough
  • 17.
    Example of StrongEquivalence Class Testing (SECT) 17 |A| = 3, |B| = 4, |C| = 2 # of test cases ◦ 3x4x2= 24
  • 18.
    Testing for Robustness 18 Iferror conditions are a high priority, we should extend strong equivalence class testing to include both valid (E) and invalid inputs (U) ◦ For example: age < 0 and age > 120 Again, robustness can be applied with WECT and SECT
  • 19.
    NextDate Example 19 NextDate isa function with three variables: month, day, year. It returns the date of the day after the input date. ◦ Limitation: 1812-2020 Treatment Summary: ◦ if it is not the last day of the month, the next date function will simply increment the day value. ◦ At the end of a month, the next day is 1 and the month is incremented. ◦ At the end of the year, both the day and the month are reset to 1, and the year incremented. ◦ Finally, the problem of leap year makes determining the last day of a month interesting.
  • 20.
    Equivalence Classes 20 Valid EquivalenceClasses ◦ M1 = {1 <= month <= 12} ◦ D1 = {1 <= day <= 31} ◦ Y1 = {1812 <= year <= 2020}
  • 21.
    Poor Equivalence Classes 21 ValidEquivalence Classes ◦ M1 = {1 <= month <= 12} ◦ D1 = {1 <= day <= 31} ◦ Y1 = {1812 <= year <= 2020}  Should take into account special cases  Leap year, February
  • 22.
    Better classes 22 Valid EquivalenceClasses ◦ M1 = {1, 3, 5, 7,8, 10, 12} ◦ M2 = {4, 6, 9, 11} ◦ M3 = {2} ◦ D1 = {1 <= day <= 28} ◦ D2 = {29} ◦ D3 = {30} ◦ D4 = {31} ◦ Y1 = {year = 1900} ◦ Y2 = {1812 <= year <= 2020 AND (year != 1900) AND (year mod 4 = 0)} ◦ Y3 = {1812 <= year <= 2020 AND year mod 4 != 0 }
  • 23.
    Weak Equivalent Class- Test cases 23 #test cases=maximum partition size (D)=4
  • 24.
    Strong Equivalent ClassTesting - Test cases 24
  • 25.
  • 26.
    Boundary Value Analysis Thebasic idea in boundary value testing is to select input variable values at their: Minimum Just above the minimum A nominal value Just below the maximum Maximum 26
  • 27.
    27 Boundary-value Analysis Boundary-value analysisdiffers from Equivalence Partitioning in two respects: 1. Rather than selecting any element to represent an equivalence class, boundary-value analysis requires that one or more elements be selected such that each edge of the equivalence class is subjected to a test. 2. Rather than focusing attention on the input conditions (input space), test cases are also derived by considering the result space (i.e., output equivalence classes) ¨ if a module uses a file of records, how will program react if there are no records on the file; also if a transaction file is used for updating a master file; have all permutations of EOF conditions been considered. ¨ If a module is passed an array, what if it contains zero elements? when it contains maximum number of elements, and so on a pointer to an array accessing out side an array-boundary.
  • 28.
    Errors at theboundaries 28 Experience indicates that programmers make mistakes in processing values at and near the boundaries of equivalence classes. ◦ For example, suppose that method M is required to compute a function f1 when x≤ 0 is true and function f2 otherwise. ◦ However, M has an error due to which it computes f1 for x<0 and f2 otherwise. This fault is revealed when M is tested against x=0, but not if the input test set is, for example, {-4, 7} derived using equivalence partitioning In this example, the value x=0, lies at the boundary of the equivalence classes x≤0 and x>0.
  • 29.
    Example 29 Function findPrice() hastwo parameters: an item code must be in the range 99..999 and quantity in the range 1..100 Equivalence classes for code: ◦ E1: Values less than 99 ◦ E2: Values in the range ◦ E3: Values greater than 999 Equivalence classes for qty: ◦ E4: Values less than 1. ◦ E5: Values in the range. ◦ E6: Values greater than 100
  • 30.
    Example 30 An Address textbox which allows maximum 500 characters. So, writing test cases for each character once will be very difficult so that will choose boundary value analysis. No characters 1 character 2 character 499 character 500 character 501 character
  • 31.
    Example- Boundary ValueAnalysis Equivalence and Boundary Value Let's consider the behavior of Order Pizza Text Box Pizza values 1 to 10 is considered valid. A success message is shown. 31 Here is the test condition Any Number greater than 10 entered in the Order Pizza field(let say 11) is considered invalid. Any Number less than 1 that is 0 or below, then it is considered invalid. Numbers 1 to 10 are considered valid Any 3 Digit Number say -100 is invalid.
  • 32.
    Example- Boundary ValueAnalysis…. 32
  • 33.
    Construct Test sets 33 Testselection based on the boundary value analysis technique requires that tests must include, for each variable, values at and around the boundaries
  • 34.
    34 Advantages of ECand BVA 1. Reduces the number of test cases that must be run, thus reduces the cost 2. Eliminates the fuzzy criteria of test data selection that is inefficient 3. Helps identify the different classes for which the program is not working properly
  • 35.
    35 Error-Guessing Some people designthe test cases by intuition and experience. The basic idea is to enumerate a list of possible errors and then write test cases based on the list.
  • 36.

Editor's Notes

  • #8 an application collects some data about a traveler using the dialog box shown in the diagram. When the OK button is pressed the component calculates a fare from the current location using the input values.
  • #15 Equivalence classes can be of multiple types: weak, strong, robust?? SUT (sys under test), ai, bi, ci, Bi, Ci Should not A1 ∪ A2 ∪ A3 be a1, a2, a3 (lower cases)
  • #16 Suppose Max values of each domain is: |A| = 3, |B| = 4, |C| = 2 So max # of classes is = max input values (among all) B = 4 * Notation is different at different places?
  • #17 Like a loop outermost A, inner B, inner most C
  • #21 Data??
  • #22 Explanation of Y1, Y2 ?? 1900? Y2k problem??
  • #23 4 (because max set requires for day=4; see prev slide) mini one input from each. WETC3: Feb 30 not possible WETC4: June 30 not possible
  • #24 Repeate all-3 values of Y for every value of D, and repeat all Ds for all Ms
  • #25 For Example, if you divided 1 to 1000 input values invalid data equivalence class, then you can select test case values like 1, 11, 100, 950, etc. Same case for other test cases having invalid data classes
  • #27 previous example >> customer-acc-number
  • #28 Should: f1 when x≤ 0 is true and function f2 x>0 By error: f1 when x < 0 is true and function f2 x≥0 TC = {-4, 7} wont catch error TC= {0} will execute f2; and will catch error being 0 at boundary for this test