6 Black&WhiteBox
6 Black&WhiteBox
6 Black&WhiteBox
Outline
■ Testing Types
■ Testing Techniques
■ White-box Testing
■ Black-box Testing
Black-box Testing 1
Inputs causing
anomalous
Input test data I behaviour
e
System
• Equivalence Partitioning
• Boundary Value Analysis
• Decision Tables
• Requirements Based Testing
• Positive and Negative Testing
• Graph-Based Testing or State Based Testing
• Compatibility Testing
• User Documentation Testing
• Domain Testing
Equivalence Partitioning 1
System
Outputs
Example 1
• Range (1..16,383) defines three different
equivalence classes:
– Equivalence Class 1: Fewer than 1 record
– Equivalence Class 2: Between 1 and 16,383
records
– Equivalence Class 3: More than 16,383
records
Guidelines for derivation of
Equivalence Classes
• If a range v1 ... v2,
then <v1, v1 ... v2, >v2
• If a value v, then <v, v, >v
• If a set S={ a, b, ..., x }, then S, any value
not in S
• If Boolean b, then b=true, b=false
WHY LEARN EQUIVALENCE
PARTITIONING?
• Equivalence partitioning drastically cuts
down the number of test cases required to
test a system reasonably.
• It is an attempt to get a good 'hit rate', to
find the most errors with the smallest
number of test cases.
DESIGNING TEST CASES USING
EQUIVALENCE PARTITIONING
• Identify the equivalence classes
• Design test cases
• STEP 1: IDENTIFY EQUIVALENCE CLASSES Take
each input condition described in the specification and
derive at least two equivalence classes for it. One class
represents the set of cases which satisfy the condition
(the valid class) and one represents cases which do not
(the invalid class )
• Following are some general guidelines for identifying
equivalence classes:
– a) If the requirements state that a numeric value is input to the
system and must be within a range of values, identify one valid
class inputs which are within the valid range and two invalid
equivalence classes inputs which are too low and inputs which
are too high.
• For example, if an item in inventory can have a
quantity of - 9999 to + 9999, identify the
following classes:
• 1. one valid class: (QTY is greater than or equal
to -9999 and is less than or equal to 9999). This
is written as (- 9999 < = QTY < = 9999)
• 2. the invalid class (QTY is less than -9999),
also written as (QTY < -9999)
• 3. the invalid class (QTY is greater than 9999) ,
also written as (QTY >9999)
• If the requirements state that the number of items input
by the system at some point must lie within a certain
range, specify one valid class where the number of
inputs is within the valid range, one invalid class where
there are too few inputs and one invalid class where
there are, too many inputs.
• For example, specifications state that a maximum of 4
purchase orders can be registered against anyone
product. The equivalence classes are : the valid
equivalence class: (number of purchase orders is greater
than or equal to 1 and less than or equal to 4 , also
written as (1 < = no. of purchase orders < = 4) the invalid
class (no. of purchase orders> 4) the invalid class (no. of
purchase orders < 1)
• If the requirements state that a particular input
item match one of a set of values and each case
will be dealt with the same way, identify a valid
class for values in the set and one invalid class
representing values outside of the set. For
example, if the requirements state that a valid
province code is ON, QU, and NB, then identify :
the valid class code is one of ON, QU, NB the
invalid class code is not one of ON, QU, NB
Grocery Store Example
• Consider a software module that is intended to accept
the name of a grocery item and a list of the different
sizes the item comes in, specified in ounces. The
specifications state that the item name is to be
alphabetic characters 2 to 15 characters in length. Each
size may be a value in the range of 1 to 48, whole
numbers only. The sizes are to be entered in ascending
order (smaller sizes first). A maximum of five sizes may
be entered for each item. The item name is to be entered
first, followed by a comma, then followed by a list of
sizes. A comma will be used to separate each size.
Spaces (blanks) are to be ignored anywhere in the input.
Derived Equivalence Classes
• Item name is alphabetic (valid) • Size value includes nonnumeric
• Item name is not alphabetic (invalid) characters (invalid)
• Item name is less than 2 characters in • Size values entered in ascending order
length (invalid) (valid)
• Item name is 2 to 15 characters in • Size values entered in nonascending
length (valid) order (invalid)
• Item name is greater than 15 • No size values entered (invalid)
characters in length (invalid) • One to five size values entered (valid)
• Size value is less than 1 (invalid) • More than five sizes entered (invalid)
• Size value is in the range 1 to 48 • Item name is first (valid)
(valid) • Item name is not first (invalid)
• Size value is greater than 48 (invalid) • A single comma separates each entry
• Size value is a whole number (valid) in list (valid)
• Size value is a decimal (invalid) • A comma does not separate two or
• Size value is numeric (valid) more entries in the list (invalid)
• The entry contains no blanks (???)
• The entry contains blanks (????)
Black Box Test Cases for the Grocery Item Example based on the Equivalence Classes Above.
Expected
# Test Data Classes Covered
Outcome
1,4,7,9,11,13,16,1
1 xy,1 T
8,20,22
AbcDefghijklmno,1 1,4,7,9,11,13,16,1
2 T
,2,3 ,4,48 8,20,23
3 a2x,1 F 2
4 A,1 F 3
5 abcdefghijklmnop F 5
6 Xy,0 F 6
7 XY,49 F 8
8 Xy,2.5 F 10
9 xy,2,1,3,4,5 F 14
10 Xy F 15
11 XY,1,2,3,4,5,6 F 17
12 1,Xy,2,3,4,5 F 19
13 XY2,3,4,5,6 F 21
14 AB,2#7 F 12
Boundary Value Analysis
• Select test cases on or just to one side of
the boundary of equivalence classes.
– This greatly increases the probability of
detecting a fault.
• Complements equivalence class testing.
Example 2.
(contd.)
Combinations • Components
Causes Values 1 2 3 4 5 6 7 8 • A decision table lists
Cause 1 Y, N Y Y Y Y NNNN
Cause 2 Y, N Y Y NNY Y NN causes and effects in
Cause 3 Y, N Y NY NY NY N a matrix. Each
Effects
Effect 1 X X X
column represents a
Effect 2 X X X unique combination.
• Purpose is to structure
logic
Cause = condition
Effect = action = expected results
Step 1: List all causes
Hints:
• Write down the values
Combinations
Causes Values 1 2 3 4 5 the
6 7 8cause/condition
Cause 1 Y, N Y Y Y Y NNNN
Cause 2 Y, N Y Y N N Y can
Y N N assume
Cause 3 Y, N Y NY NY NY N
Effects • Cluster related
Effect 1 X X X
Effect 2 X
causes
X X
• Put the most
dominating cause first
• Put multi valued
causes last
Step 2: Calculate combinations
Combinations
Causes Values 1 2 3 4 5 6 7 • Join columns where
Cause 1 Y, N Y Y Y NNNN
Cause 2 Y, N Y Y NY Y NN columns are
Cause 3 Y, N Y N - Y NY N identical
Effects
Effect 1 X X • Tip: ensure the
Effect 2 X X X
effects are the
same
Step 5: Check covered
combinations
• Checksum
• For each column calculate the
Combinations
Causes Values 1 2 3 4
combinations it represents
Cause 1 Y, N Y Y Y N • A ‘-’ represents as many
Cause 2 Y, N Y N N -
Cause 3 Y, N - Y N - combinations as the cause has
Effects
Effect 1 X X
• Multiply for each ‘-’ down the
Effect 2 column
Checksum 2 1 1 4 8
• Add up total and compare with
step 2
Step 6: Add effects to table
• Read column by
Combinations
Causes Values 1 2 3 4
column and
Cause 1 Y, N Y Y Y N determine the effects
Cause 2 Y, N Y N N -
Cause 3 Y, N - Y N •- One effect can occur
Effects in multiple test
Effect 1 X X
Effect 2 X X combinations
Checksum 2 1 1 4 8
Example
• A technical support company writes a
decision table to diagnose printer
problems based upon symptoms
described to them over the phone from
their clients.
Printer troubleshooter
Rules
Digit
+ or - Decimal
1 point Digit
2 3 Digit
4 5
Digit
Blank
Blank
6
State transition table
Current state Input Next state
1 Digit 2
1 + 2
1 - 2
2 Digit 2
2 Blank 6
2 Decimal point 3
3 Digit 4
4 Digit 5
5 Blank 6
General outline for using state
based testing methods w.r.t.
language processors
• Identify the grammar for the scenario
• Design test cases corresponding to each
valid state-input combination
• Design test cases corresponding to the
most common invalid combinations of
state-input
State graph to represent workflow
HR
Employe Eligible Manager
Verify
e desires ensure
eligibility Feasible
leave feasibility
Ineligible
Approve
Leave
application form Not
feasible
Reject
Compatibility Testing
• Test case result are compared with expected
results to conclude whether the test is
successful or not
• Test case results depend on
– the product for proper functioning
– Equally on the infrastructure for delivering
functionality
• When infrastructure parameters change product
is expected to still behave correctly and produce
the desired or expected results
• This testing ensures the working of the product with different infrastructure
components
• The parameters that generally affect the compatibility of the product are
– Processor and their number
– Architecture and characteristics of machine
– Resource availability on the machine
– Equipment e.g. printers, modems, routers etc.
– Operating system (windows, linux) and operating system services (DNS, FTP)
– Middle-tier infrastructure components such as web server
– Backend components such as database servers
– Services that require special hardware-cum-software solutions (cluster
machines, load balancing)
– Any software used to generate product binaries (compiler, linker)
– Various technological components used to generate components (SDK, JDK)
• Inorder to arrive at practical combinations
or the parameters to be tested, a
compatibility matrix is created
• Matrix has as its columns various
parameters the combinations of which
have to be tested
• Each row represents a unique combination
of a specific set of values of the
parameters
User Documentation Testing
• User documentation covers all the manuals,
user guides, installation guides, setup guides,
read me file, software release notes, and online
help that are provided along with the software to
help the end user to understand the software
system
• Objectives
– To check if what is stated in the document is available
in the product
– To check if what is there in the product is explained
correctly in the document
Advantages
• Aids in highlighting problems overlooked during reviews
• High quality ensures consistency of documentation and
product, thus minimizing possible defects reported by
customers
• Reduce the time of the support call
• Results in less difficult support calls
• New programmers and testers who join a project group
can use the documentation to learn the external
functionality of the product
• Customers need less training and can proceed more
quickly to advanced training and product usage if the
documentation is of high quality and is consistent with
the product.
• Defects found in user documentation need
to be tracked to closure like any regular
software defect.
Domain Testing
• White box testing required looking at the program code
• Black box testing performed testing without looking at
the program code but looking at the specifications
• Domain testing can be considered as the next level of
testing in which we don not look even at the
specifications of a software product but are testing the
product, purely based on domain knowledge and
expertise in the domain of application
• Requires business domain knowledge rather than the
knowledge of what the software specification contains or
how the software is written
• Domain testing is the ability to design and execute test
cases that relate to the people who will buy and use the
software
• It helps in understanding the problems they are trying to
solve and the ways in which they are using the software
to solve them
• It is also characterized by how well an individual test
engineer understands the operation of the system and
the business processes that system is supposed to
support
• Domain testing involves testing the product, not by going
through the logic built into the product. The business flow
determines the steps, not the software under test. This is
called “business vertical testing”
Example
• Step 1: go to the ATM
• Step 2: Put ATM card inside
• Step 3: Enter correct PIN
• Step 4: Choose cash withdrawal
• Step 5: Enter amount
• Step 6: Take the cash
• Step 7: Exit and retrieve the card
Scenarios for black box testing
techniques
When you want to test scenarios that The most effective black box testing
have… technique is likely to be…