7 2SoftwareTesting
7 2SoftwareTesting
• There are 520 paths from A to X after passing through the loop 20 times.
• There are 5 + 52 + 53 +…+ 520 = 100 trillion possible paths in this program.
• If you could test a path per second it would take more than 3 million years!
1
LECTURE 7: SOFTWARE TESTING
Black BOX TESTING
2
Black Box Testing
Black Box Testing is a software testing method in which the functionalities
of software applications are tested without having knowledge of internal code
structure, implementation details and internal paths.
• The Goal: Derive sets of input conditions (test cases) that fully exercise the
external functionality. Therefore, you can test any software system:
Windows OS, Google Website, an Oracle database.
Black Box Testing
• Black box testing tends to find different kinds of errors than white box
testing
– Wrong Functions
– Missing functions
– Usability problems
– Performance problems
– Concurrency and timing errors
– Initialization and termination errors
– …
• Unlike white box testing, black box testing tends to be applied later in the
development process, but its cases can be prepared earlier.
The Information Domain: inputs and outputs
• Inputs
– Individual input values
• Try many different values for each individual input
– Combinations of inputs
• Individual inputs are not independent from each other
• Programs process multiple input values together, not just one at a time
• Try many different combinations of inputs in order to achieve good coverage
of the input domain
• You have to select a relatively small number of test cases to actually run
• Two test cases are considered to be equivalent if we expect the program to process
them both in the same way (i.e., follow the same path through the code)
• If you expect the program to process two test cases in the same way, only test one
of them, thus reducing the number of test cases you have to run
Equivalence Partitioning
• First-level partitioning: Valid vs. Invalid test cases
Valid Invalid
? ?
A integer N such that:
-99 <= N <= 99
? ?
Phone Number
Area code: [200, 999]
Prefix: (200, 999]
Suffix: Any 4 digits
Equivalence Partitioning - examples
Valid ECs
M1 = {month has 30 days} M2 =
{month has 31 days} M3
={February}
D1={1<=day<=27}, D2={day=28}
D3= {day = 29}, D4= {day = 30}, D5 {day = 31}
Y1 = {year: year is a non-leap year} Y2 =
{year: year is a leap year}
Boundary Value Analysis
Boundary testing is the process of testing boundaries between partitions
of the input values. It focuses on the boundaries between ECs, simply
because that is where so many defects hide. Here is the Method:
1. Identify the equivalence classes.
2. Identify the boundaries of each EC.
3. Create test cases for each boundary value by choosing one point on the
boundary, one point just below, and one point just above the boundary.
Boundary Value Analysis
• Create test cases to test boundaries of equivalence classes
-1 0 1 15 16 17 17 18 19 54 55 56 98 99 100
Boundary Value Analysis - Exercise
Input Boundary Cases
?
A number N such that:
-99 <= N <= 99
Phone Number
Area code: [200, 999]
Prefix: (200, 999)
Suffix: Any 4 digits
?
Boundary Value Analysis - Solution
Input Boundary Cases
A number N such that: -100, -99, -98
-99 <= N <= 99 98, 99, 100
Phone Number Area code: 199, 200, 201
Area code: [200, 999] Area code: 998, 999, 1000
Prefix: [200, 999] Prefix: 199, 200, 201
Suffix: Any 4 digits Prefix: 998, 999, 1000
Suffix: 3 digits, 5 digits
• The decision table is a black box testing technique that is used to test
these complex business logic.
Limited entry
Rule 1- Rule 3 Rule 4 Rule 5- Rule 7 Rule 8 table –
2 6 conditions are
Married? Yes Yes Yes No No No binary only
# years >= 3 <3 <3 >= 3 <3 <3
C employed
Extended entry
Good student? - Yes No - yes No
table – conditions
A Discount 70 50 20 60 40 0
may take on
multiple values
• Intuition will often lead you toward boundary cases, but not always
• Some special cases aren't boundary values, but are mishandled by many programs
– Try exiting the program while it's still starting up
– Try loading a corrupted file
– Try strange but legal URLs: hTtP://Www.bYu.EDU/
Comparison Testing
• Also called Back-to-Back testing
• If you have multiple implementations of the same functionality, you can run test inputs
through both implementations, and compare the results for equality
• Test the system under extreme conditions (i.e., beyond the limits of normal use)
• Even if the system doesn't need to work in such extreme conditions, stress testing
is an excellent way to find bugs
Random Testing
• Randomly generate test inputs
– Could be based on some statistical model
• Get real users to sit down and use the software to perform some tasks
• Watch them performing the tasks, noting things that seem to give them trouble
• Get their feedback on the user interface and any suggested improvements
• Can the program recover if its configuration files have been corrupted or deleted?
• What about hardware failures? Does the system need to keep working when its
hardware fails? If so, verify that it does so.
Configuration Testing
• Test on all required hardware configurations
– CPU, memory, disk, graphics card, network card, etc.
Documentation Testing
• Test all instructions given in the documentation to ensure their completeness and
accuracy
• For example, “How To ...” instructions are sometimes not updated to reflect
changes in the user interface