Document

Phase
Testing
1
Overview of Implementation phase
Define Implementation
Plan (+ determine
subphases)
Create unit
Test plans
Create system
Test plan
System
Testing
\
Define Coding
Standards
Create Class
Skeletons
For each subphase
Release unit
for integration
Integration
Testing
Implement
Methods in class/es
Unit
test
Code
review
Create integration Test plan
2
Review: Selecting Glass box test cases
 Determine what to test (select types of
coverage)
 Create a flowchart for code to be tested
 Select test cases such that
\

For a method with only sequential statements, 100%
statement coverage will be achieved

For a method with sequential statements and branches
100% branch coverage will be achieved in addition to
100% statement coverage

For a method that also includes iterative statements try
to approach 100% path coverage as closely as possible
with a reasonable number of tests. (assure statement
and branch coverage)
3
Black Box Testing
 We treat software system as a black box
 We cannot see inside, i.e., we knows nothing about
 source code
 internal data
 design documentation
 So what do we know then?
 Public interface of the function or class (methods, parameters)
 Class skeleton (pre and post conditions, description, invariants)
 Test cases are selected based on
 input values or situation
\
 expected behaviour and output of methods
4
Select Set of Test Cases using
Black Box Testing Strategy
1.
Determine what to test

Which method of which class, type of test
2. For each parameter and object
a)
Establish the parameters equivalence classes OR consider that
various states of object

Determine all valid (invalid) values or all ranges of valid (invalid)
values, and boundaries between those ranges.

Determine valid and invalid states of objects (preconditions)
b) Select representative values for each equivalence class (one from
each range, and boundary values) to use as basis of your test
cases
\
5
Example Test case: (from text)
 Code being tested:
\

Method in a board game. setDot(…)

Turns dots in a grid on and off

Assuming that the grid is to be 15 by 15
6
From Skeleton: setDot(int i, int j, int c)
Public void setDot( int i, int j, int c)
// send message to the Graphical_Cell object which is the
//element at row i and column j in the grid array. Set the
// dot to color c.
i and j are both less than 15
//precondition: the 2_D array of Graphical_Cell objects
//has been instantiated. c has value 1 or 2
//postcondition: Graphical_Cell object shows that a dot at
//row i and column j is displayed with color c.

Use the information -1 < i,j < 15, and 0 < c < 3 to define
equivalence classes for the variables

Use the information Graphical_Cell object has been instantiated to
define equivalence classes for object Graphical_Cell
\
7
Equivalence classes for c, i and j
invalid
valid
invalid
<0
0-14
>14
i
invalid
valid invalid
invalid
valid
<0
0-14
<1
1-2
j
>14
invalid
>2
c
 3 equivalence classes have been defined for each variable. Each colored
bar shows one equivalence class. The equivalence classes define where
each variable is valid and invalid.
 Next, the equivalence classes can be used to help choose test values for
\
each variable
8
Choosing Representative test values i, j

invalid valid
invalid

<0
0-14 >14
How to choose representative values
for tests based on equivalence
classes:
Consider variables i and j:

Choose one value from each
equivalence class for i -3, 6,
18

Choose one value from each
equivalence class for j -4, 8,
17

Choose boundary values between
each pair of equivalence classes,
-1, 0 and 14, 15.
i or j
For variables i and j use test values

i:
-3, -1, 0, 6, 14, 15, 18

j:
-4, -1, 0, 8, 14, 15, 17
\
9
Choosing Representative test values c
invalid valid
<1
1-2
invalid

>2
Consider variable c

Choose one value from each
equivalence class -2, 2, 5

Choose boundary values between
each pair of equivalence classes,
0,1 and 2, 3.

i or j
For variable c use test values

-2, 0, 1, 2, 3, 5
\
10
Choosing Representative test values
Graphical_Cell
Not
instantiated
instantiated
valid
invalid
Graphical_Cell
Graphical_Cell has two possible states, instantiated (consistent with precondition) or
not instantiated (inconsistent with precondition)
Each colored bar shows one equivalence class
\
11
Equivalence classes for grid or
Graphical_Cell
Not
instantiated
instantiated
valid
invalid
Graphical_Cell
Consider the object, Graphical_Cell.
has two possible states, instantiated, not instantiated
In designing test cases use two possible states, instantiated, not instantiated
\
12
What test values have we selected?

For variable i use test values


For variable j use test values


-4, -1, 0, 8, 14, 15, 17
For variable c use test values


-3, -1, 0, 6, 14, 15, 18
-2, 0, 1, 2, 3, 5
For object, Graphical_Cell.

instantiated, not instantiated

For optimal testing coverage we would use all possible
combinations of these values (2*6*7*7=588 tests).

In practice will usually choose a subset of possible combinations
which reflects the best test coverage with a more reasonable
number of tests.
\
13
Choosing a subset: an example

You may wish to consider the following

Testing with all valid variables and preconditions

Testing with all valid variables and only one invalid
precondition (for each precondition in turn)

Testing with all valid preconditions and one invalid variable
(for each variable in turn, one sample from each invalid
equivalence class)

Testing with all valid preconditions and a boundary value for
each variable

Testing with pairs of invalid variables?

What else is needed ?
\
14
Proposed subset - 1

1 -- All variables in the valid range


j= 8
c = 1 Graphical_ Cell not instantiated
i=6
j= 17
c = 1 Graphical_ Cell instantiated
i=3
j= -4
c = 1 Graphical_ Cell instantiated
5 -- j, and c valid i invalid


i=6
4 – i, and c valid j invalid (different equivalence class value)


c = 1 Graphical_ Cell instantiated
3 – i, and c valid j invalid


j= 8
2 -- All variables in the valid range


i=6
i=-3
j= 8
c = 1 Graphical_ Cell instantiated
6 -- j, and c valid i invalid

i=18
j= 8
c=1
Graphical_ Cell instantiated
\
15
Proposed subset - 2

7 -- i, and j valid c invalid


j= 8
c = -2 Graphical_ Cell instantiated
i=15
j= 14
c = 1 Graphical_ Cell instantiated
i=14
j= 15
c = 1 Graphical_ Cell instantiated
11 -- j, and c valid i invalid


i=6
10 – i, and c valid j invalid (different equivalence class value)


c = 5 Graphical_ Cell instantiated
9 – i, and c valid j invalid


j= 8
8 -- i, and j valid c invalid


i=6
i=-1
j= 0
c = 2 Graphical_ Cell instantiated
12 -- j, and c valid i invalid

i=0
j= -1
c = 2 Graphical_ Cell instantiated
\
16
Proposed subset - 3

13 -- i, and j valid c invalid


i=14
j= 0
c=3
Graphical_ Cell instantiated
i=0
j= 14
c = 1 Graphical_ Cell instantiated
16 – i, and c valid j invalid (different equivalence class
value)

\
c = 0 Graphical_ Cell instantiated
15 – i, and c valid j invalid


j= 14
14 -- i, and j valid c invalid


i=0
i=14
j= 0
c = 2 Graphical_ Cell instantiated

17
Test Case Example
 Test id - 1
 Test purpose: Unit test Game2DClient class method setDot( ) (page271)
using Black box testing strategy
 Requirement # 4
 Inputs: i = 6, j = 8, c = 1 (blue), grid has been instantiated
 Testing procedure:
 Create an object of Game2DClient class type
 Show grid (to demonstrate dot is not set before call to setDot)
 Call setDot( i = 6, j = 8, c = 1 )
 Evaluation: Show grid
 Expected behaviours and results: blue dot now showing at location (6, 8)
on grid
 Actual behaviours and results:
\
18
Test Case Example
 Test id - 2
 Test purpose: Unit test Game2DClient class method setDot( )
(page271) using Black box testing strategy
 Requirement # 4
 Inputs: i = 6, j = 8, c = 1 (blue), grid has NOT been instantiated
 Testing procedure:
 Create an object of Game2DClient class type without a grid
 Call setDot( i = 6, j = 8, c = 1 )
 Evaluation: no step required
 Expected behaviours and results: message stating that grid does not
exist
 Actual behaviours and results:
\
19
Test Case Example
 Test id - 11
 Test purpose: Unit test Game2DClient class method setDot( ) (page271)
using Black box testing strategy
 Requirement # 4
 Inputs: i = -1, j = 0, c = 2 (blue), grid has been instantiated
 Testing procedure:
 Create an object of Game2DClient class type
 Show grid (could set other dots)
 Call setDot( i = -1, j = 0, c = 2 )
 Evaluation: Show grid
 Expected behaviours and results: grid should be unchanged and a
message stating that the location for the new blue dot is erroneous
 Actual behaviours and results:
\
20