Word

advertisement
FOR0383 Software Quality Assurance
Laboratory 11 Input Space Partition Exercises (pen and paper lab)
ISP Coverage Criteria Subsumption
All Combinations
Coverage
AC
T-Wise
Coverage
TW
Multiple Base
Choice Coverage
MBC
Pair-Wise
Coverage
PW
Base Choice
Coverage
BC
Each Choice
Coverage
EC
© Ammann & Offutt
Introduction to Software Testing (Ch 4), www.introsoftwaretesting.com
34
Examples by Andrew Brooks
(i)
Suppose a method has the following specification:
int getArea()
//specification: length * breadth
In the event of an incalculable area, a code of -999 is returned.
Assume length and breadth are integer values that are known to lie between -4 and +4
(inclusive). Identify blocks in a partition of a suitable characteristic for length and breadth.
Define values for the blocks. Define a set of test cases that satisfies (i) Each Choice Coverage
(EC) and (ii) Pair-Wise Coverage (PW).
(ii)
Suppose a method has the following specification:
int getPerimeter()
//specification: 2*(length + breadth)
In the event of an incalculable perimeter, a code of -999 is returned.
Assume length and breadth are integer values that are known to lie between -4 and +4
(inclusive). Identify blocks in a partition of a suitable characteristic for length and breadth.
Define values for the blocks. Define a set of test cases that satisfies (i) Each Choice Coverage
(EC) and (ii) Pair-Wise Coverage (PW).
1
FOR0383 Software Quality Assurance
Examples by Paul Ammann and Jeff Offutt
(from Introduction to Software Testing, by Paul Ammann and Jeff Offutt , Cambridge University Press 2008)
Section 4.1
1. Answer the following questions for the method search() below:
public static int search (List list, Object element)
// Effects: if list or element is null throw NullPointerException
// else if element is in the list, return an index
// of element in the list; else return -1
// for example, search ([3,3,1], 3) = either 0 or 1
// search ([1,7,5], 2) = -1
Base your answer on the following characteristic partitioning:
Characteristic: Location of element in list
Block 1: element is first entry in list
Block 2: element is last entry in list
Block 3: element is in some position other than first or last
(a) “Location of element in list” fails the disjointness property.
Give an example that illustrates this.
(b) “Location of element in list” fails the completeness property.
Give an example that illustrates this.
(c) Supply one or more new partitions that capture the intent of “Location of e in list” but do
not suffer from completeness or disjointness problems.
2
FOR0383 Software Quality Assurance
Section 4.2
5. Derive input space partitioning tests for the BoundedQueue class with the following
signature:
public BoundedQueue (int capacity);
public void Enqueue (Object X);
public Object Dequeue ();
public boolean IsEmpty ();
public boolean IsFull ();
Assume the usual semantics for a queue with a fixed, maximal capacity. Try to keep your
partitioning simple–choose a small number of partitions and blocks.
(a) Identify all of the variables. Don’t forget the state variables.
(b) Identify several characteristics that suggest partitions.
(c) Identify the blocks in the partition for each characteristic. Designate one block in each
partition as the “Base” block.
(d) Define values for the blocks.
(e) Define a test set that satisfies Base Choice (BCC) coverage.
3
Download