Presentation is loading. Please wait.

Presentation is loading. Please wait.

Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test4: Category-Partition Method Marian Gheorghe ©University.

Similar presentations


Presentation on theme: "Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test4: Category-Partition Method Marian Gheorghe ©University."— Presentation transcript:

1 Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test4: Category-Partition Method Marian Gheorghe ©University of SheffieldCom1040 - Testing

2 Equivalence partition & Boundary conditions - recap Category-partition: principles and testing methodology Example Summary

3 Equivalence classes and boundaries Equivalence classes (or partitions) are defined according to various entities (variables) and certain functionality of a program Testing will identify equivalence classes and may add boundary conditions (test values around boundaries) Data set boundaries are either explicitly defined in the application or provided by the programming language constructs or the programming environment Two situations were analysed: simple data and multiple entities – triangle problem (similarly, structured data can be used) Somehow multiple entities define a simple case of what we discuss now…

4 Short characterisation: refinement of the partition-based method More precisely, it relies on: identifying properties of data and program behaviour defining partitions according to properties identified Example: A program reads data about people: year of birth and name; are listed those born after 2000 and called Smith. So, (1) the first category is given by year, leads to two classes – one containing values  2000 and another one with values <2000; (2) second category is name and consists of two classes as well: with Smith and without it. We combine these partitions and get 4 partitions …Category-partition method

5 Category-partition principles The method, mostly black box, but can be defined for white box as well, has three basic steps, of which consider two here: – Construct test cases for the preconditions associated to functions: two partitions – values satisfying conditions & the other values; the first class is further analysed in the next step –Construct test cases for the individual sets of items Consider sets of values occurring in many use cases (books, copies, lecturers, students, tennis players, tickets etc) -- these refer to data Consider the following situations: 1.the set is displayed as it is 2.process an element from the set 3.add a new element to the set -- the above refer to functionality

6 Size category When a set is displayed (case 1, on the previous slide) then, if there is no upper limit, the following three partitions are considered empty set: {} set containing one element: {a} set with more than one element: {a, b, …} When there is an upper limit, Max, then two more cases are considered: set with Max elements and with Max-1 The above characteristic refers to the size of a set of values and is called size category

7 Size category for the Library system Library system at https://www.dcs.shef.ac.uk/~ajc/campus_only/teach/com1030/libsystem/javacode/index.html uses Book, Copy and User business classes and, in SysData, collection classes Use cases requiring to browse through the book set or to get the books written by an author Test the system with empty collection collection with one Book object collection with more than one Book object

8 Position category for selected element When an item is selected (case 2) or it is added to a set (case 3) then the order of elements can be considered – position category. In case 2 the empty set and the set with one element remain the same, but the case of more than one element will change: selected element is the first selected element is the last selected element is in between We can also consider the upper limit and obtain three more cases similar to those above Total number of test cases 5 or 8 (if upper limit included)

9 Position category for added element When an item is added to a set (case 3) and the order of elements is considered then the empty set and the set with one element remain the same, but the case of more than one element will change: for the empty set - 1 test for one element – 2 tests: before and after the element for more than one – 3-5 tests: before the first/last, in the middle, after the first/last Boundary – i.e., upper limit can also be considered What about deleting an item?

10 Example An array, indexed 0..M-1, contains L ( 0≤L≤M ) pairs (age,name), where age is an integer in the range min..Max and name a string, stored between 0..L-1. A new pair (newAge,newName) is inserted after the element at position p ( -1 ≤p ≤L-1 ; p=-1 means insertion in the first position, 0 ). After insertion the string is filtered such as to contain only uppercase characters. Let us take L=4, M=20 and min=0, Max=100 Index: 0 1 2 3 4… 19 Age: 18 30 14 50 after p=1 insert 19 Name: JOHNJOHN LUCYLUCY JENNYJENNY SAMSAM AlexAlex

11 Example cont’d An array, indexed 0..M-1, contains L ( 0≤L≤M ) pairs (age,name), where age is an integer in the range min..Max and name a string, stored between 0..L-1. A new pair (newAge,newName) is inserted after the element at position p ( -1 ≤p ≤L-1 ; p=-1 means insertion in the first position, 0 ). After insertion the string is filtered such as to contain only uppercase characters. Now L=5, M=20 and min=0, Max=100 Index: 0 1 2 3 4… 19 Age: 18 30 19 14 50 Name: JOHNJOHN LUCYLUCY JENNYJENNY SAMSAM ALEXALEX

12 Example cont’d An array, indexed 0..M-1, contains L ( 0≤L≤M ) pairs (age,name), where age is an integer in the range min..Max and name a string, stored between 0..L-1. A new pair (newAge,newName) is inserted after the element at position p ( -1 ≤p ≤L-1 ; p=-1 means insertion in the first position, 0 ). After insertion the string is filtered such as to contain only uppercase characters. Categories: 1.properties of the pairs (newAge,newName) 2.properties of the array of pairs (age,name) wrt insertion at position p 3.properties implied by filtering Each category involves a partition and finally combine them (will see this is not the product of the partitions)

13 Example cont’d – categories 1 st category: properties of the added pair (newAge,newName) newAge - an integer in the range min..Max; generate the following 4 partitions (hence 4 tests) - preconditions: 1.values outside the range 2.{min} 3.{Max} 4.values between min and Max newName – string; one partition Total 4 tests

14 Example cont’d – categories 2 nd category: properties of the array containing L pairs (age,name); the insertion is after position p ; partitions: empty array ( L=0 ); insert in the first position – 1 test array with one element integer; insert before and after that element – 2 tests array with arbitrary elements (more than 1, but less than M ); insert on the first, after the first, after an arbitrary element and after the L -th, also outside the range of L elements – 5 tests array full ( L=M ); same as above, but no insertion is possible – 5 tests Total tests = 13 Combining the first two categories = 52

15 Example cont’d – categories 3 rd category: properties of the filtering function (transforms lowercase into uppercase of newName ) empty newName or containing only uppercases – 2 tests only one lowercase, arbitrary lowercases, all chars are lowercase elements - 3 tests So, total = 5 tests Is it necessary to combine the previous 52 tests with the current 5 ?? Explain why not

16 Equivalence partitions are generalised to category partitions Combine partitions to get final test sets Do not always combine all test cases Conclusions


Download ppt "Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test4: Category-Partition Method Marian Gheorghe ©University."

Similar presentations


Ads by Google