1 Phase Testing. \ 2 Overview of Implementation phase Create Class Skeletons Define Implementation...
-
Upload
blaise-flynn -
Category
Documents
-
view
214 -
download
2
Transcript of 1 Phase Testing. \ 2 Overview of Implementation phase Create Class Skeletons Define Implementation...
1
Phase
Testing
\
2
Overview of Implementation phase
Create Class Skeletons
Define Implementation Plan (+ determine subphases)
Define Coding Standards
For each subphase
ImplementMethods in class/es
Code review
Unit test
Create integration Test plan
Create unitTest plans
Release unit for integration
IntegrationTesting
System Testing
Create systemTest plan
\
3
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)
\
4
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
\
5
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
\ 6
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
\
7
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
\
8
Equivalence classes for c, i and j
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
0-14 >14
i j c
<0
validinvalid invalid
0-14 >14<0
validinvalid invalid
1-2 >2<1
validinvalid invalid
\
9
Choosing Representative test values i, j 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.
For variables i and j use test values i: -3, -1, 0, 6, 14, 15, 18
j: -4, -1, 0, 8, 14, 15, 17
0-14 >14
i or j
<0
validinvalid invalid
\
10
Choosing Representative test values c
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.
For variable c use test values
-2, 0, 1, 2, 3, 5
1-2 >2
i or j
<1
validinvalid invalid
\
11
Choosing Representative test values Graphical_Cell
Not instantiated
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
instantiated
valid invalid
\
12
Equivalence classes for grid or Graphical_Cell
Not instantiated
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
instantiated
valid invalid
\
13
What test values have we selected? For variable i use test values
-3, -1, 0, 6, 14, 15, 18
For variable j use test values -4, -1, 0, 8, 14, 15, 17
For variable c use test values -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.
\
14
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 ?
\
15
Proposed subset - 1 1 -- All variables in the valid range
i=6 j= 8 c = 1 Graphical_ Cell instantiated
2 -- All variables in the valid range
i=6 j= 8 c = 1 Graphical_ Cell not instantiated
3 – i, and c valid j invalid
i=6 j= 17 c = 1 Graphical_ Cell instantiated
4 – i, and c valid j invalid (different equivalence class value)
i=3 j= -4 c = 1 Graphical_ Cell instantiated
5 -- j, and c valid i invalid
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
\
16
Proposed subset - 2 7 -- i, and j valid c invalid
i=6 j= 8 c = 5 Graphical_ Cell instantiated
8 -- i, and j valid c invalid
i=6 j= 8 c = -2 Graphical_ Cell instantiated
9 – i, and c valid j invalid
i=15 j= 14 c = 1 Graphical_ Cell instantiated
10 – i, and c valid j invalid (different equivalence class value)
i=14 j= 15 c = 1 Graphical_ Cell instantiated
11 -- j, and c valid i invalid
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
\ 17
Proposed subset - 3
13 -- i, and j valid c invalid
i=0 j= 14 c = 0 Graphical_ Cell instantiated
14 -- i, and j valid c invalid
i=14 j= 0 c = 3 Graphical_ Cell instantiated
15 – i, and c valid j invalid
i=0 j= 14 c = 1 Graphical_ Cell instantiated
16 – i, and c valid j invalid (different equivalence class value)
i=14 j= 0 c = 2 Graphical_ Cell instantiated
\
18
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:
\
19
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:
\
20
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: