Black Box Testing
Black Box Testing
Black Box Testing
• tester may have actually seen the code before ("gray box")
– but doesn't look at it while constructing the tests
3
Types of black-box
• requirements based
• positive/negative - checks both good/bad results
• boundary value analysis
• decision tables
• equivalence partitioning - group related inputs/outputs
• state-based - based on object state diagrams
• compatibility testing
• user documentation testing
• domain testing
4
bbt
5
Boundary testing
• boundary value analysis: Testing conditions on bounds
between classes of inputs.
6
Boundary example
• Imagine we are testing a Date class with a
daysInMonth(month, year) method.
– What are some conditions and boundary tests for this method?
• Possible answers:
– check for leap years (every 4th yr, no 100s, yes 400s)
– try years such as: even 100s, 101s, 4s, 5s
– try months such as: June, July, Feb, invalid values
7
Equivalence testing
• equivalence partitioning:
– A black-box test technique to reduce # of required test cases.
8
Example
• Suppose our spec says that the code accepts between
4 and 24 inputs, and each one is a 3-digit positive
integer
• One dimension: partition the number of inputs
– Classes are “x<4”, “4<=x<=24”, “24<x”
– Chosen values: 3,4,5, 14, 23,24,25
• Another dimension: partition the integer values
– Classes are “x<100”, “100<=x<=999”, “999<x”
– Chosen values: 99,100,101, 500, 998,999,1000
9
Example.2
• Similar approach can be used for the output: exercise
boundary values
• Suppose that the spec says “the output is between 3
and 6 integers, each one in the range 1000-2500
• Try to design input that produces
– 3 outputs with value 1000
– 3 outputs with value 2500
– 6 outputs with value 1000
– 6 outputs with value 2500
10
Scope and Focus
• Unit testing: scope = individual component
– Focus: component correctness
– Black-box and white-box techniques
• Integration testing: scope = set of interacting
components
– Focus: correctness of component interactions
– Mostly black-box, some white-box techniques
• System testing: scope = entire system
– Focus: overall system correctness
– Only black-box techniques
11