Phase Testing More examples 1 Review Selecting Glass

![Review: Selecting Glass box test cases ] Determine what to test (select types of Review: Selecting Glass box test cases ] Determine what to test (select types of](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-2.jpg)

![Using Black-Box Testing Strategy ] Back to our Find. Mean( ) function … ] Using Black-Box Testing Strategy ] Back to our Find. Mean( ) function … ]](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-4.jpg)

![Using Black-Box Testing Strategy ] Consider the parameter , the score file ] Look Using Black-Box Testing Strategy ] Consider the parameter , the score file ] Look](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-6.jpg)
![Back to Library Management System ] … of textbook, at page 278, Figure 8. Back to Library Management System ] … of textbook, at page 278, Figure 8.](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-7.jpg)


![check. Out. Resource( ) Example - 1 ] Will need at least 4 unit check. Out. Resource( ) Example - 1 ] Will need at least 4 unit](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-10.jpg)
![check. Out. Resource( ) Example - 1 ] Will need at least 4 unit check. Out. Resource( ) Example - 1 ] Will need at least 4 unit](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-11.jpg)
![Library Management System ] representing section of code of check. Out. Resource( ) method Library Management System ] representing section of code of check. Out. Resource( ) method](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-12.jpg)
![Special Issues for Testing Object. Oriented Systems ] Inheritance and polymorphism makes testing more Special Issues for Testing Object. Oriented Systems ] Inheritance and polymorphism makes testing more](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-13.jpg)
![check. Out. Resource( ) Example ] The impact of inheritance and polymorphism in unit check. Out. Resource( ) Example ] The impact of inheritance and polymorphism in unit](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-14.jpg)
![check. Out. Resource( ) Example ] Test case id – 1: Patron has borrowed check. Out. Resource( ) Example ] Test case id – 1: Patron has borrowed](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-15.jpg)
![check. Out. Resource( ) Example ] Test case id – 1. 1: Faculty has check. Out. Resource( ) Example ] Test case id – 1. 1: Faculty has](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-16.jpg)
![check. Out. Resource( ) Example ] Test case id – 2: Patron has borrowed check. Out. Resource( ) Example ] Test case id – 2: Patron has borrowed](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-17.jpg)
![check. Out. Resource( ) Example ] Test case id – 2. 1: Faculty has check. Out. Resource( ) Example ] Test case id – 2. 1: Faculty has](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-18.jpg)
![check. Out. Resource( ) Example ] Test case id – 3: Patron has borrowed check. Out. Resource( ) Example ] Test case id – 3: Patron has borrowed](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-19.jpg)
![check. Out. Resource( ) Example ] test case id – 4 -> Test case check. Out. Resource( ) Example ] test case id – 4 -> Test case](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-20.jpg)
![Example Summary: Testing Object-Oriented Systems ] Inheritance and polymorphism makes testing more difficult by Example Summary: Testing Object-Oriented Systems ] Inheritance and polymorphism makes testing more difficult by](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-21.jpg)
![Integration Test Cases ] Four kinds of integration tests (read text) u Structure tests Integration Test Cases ] Four kinds of integration tests (read text) u Structure tests](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-22.jpg)
![Integration Test Case Example ] Example of Thread implementation approach ] Consider Deliverable 7. Integration Test Case Example ] Example of Thread implementation approach ] Consider Deliverable 7.](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-23.jpg)
![LMS Implementation plan diagram ] Order based on importance of each use case as LMS Implementation plan diagram ] Order based on importance of each use case as](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-24.jpg)
![Integration Test Case Example ] Test id - 53 A ] Test purpose: Integration Integration Test Case Example ] Test id - 53 A ] Test purpose: Integration](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-25.jpg)
![System Test Case ] For us, in 275, our system test case is our System Test Case ] For us, in 275, our system test case is our](https://slidetodoc.com/presentation_image_h/dd6b21bb34b0fbe66a9742d335a166c7/image-26.jpg)
- Slides: 26
Phase Testing: More examples 1
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 u For a method with only sequential statements, 100% statement coverage will be achieved u For a method with sequential statements and branches 100% branch coverage will be achieved in addition to 100% statement coverage u 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) 2
Review: Select Test Cases using Black Box Testing Strategy 1. Determine what to test u 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 3
Using Black-Box Testing Strategy ] Back to our Find. Mean( ) function … ] Consider its parameter , the score file float Find. Mean( FILE score. File ) { /* Reads scores (floats) from file score. File /* Sums and counts all positive scores /* Scores <=0 re not summed or counted /* Mean is 0 if count is 0, otherwise mean is /* sum/count */ */ */. } 4
Equivalence classes for find. Mean( …) invali d data file not opene 1 d valid data file empty 2 valid data file contains data >0 data file contains data <=0 valid 3 4 Contain s data <=0 and >50 ] 5 equivalence classes have been defined for data. File. 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 5
Using Black-Box Testing Strategy ] Consider the parameter , the score file ] Look at equivalence classes of the score file of type FILE (i. e. , all possible values that can be assigned to this parameter), then select representative values: u variable of type FILE is null (e. g. score file does not exist, or could not be opened) u score. File is empty u score. File contains 1 score >0 u score. File contains 1 score <0 u score. File contains many scores > 0 u score. File contains many scores < =0 u score. File contains many scores both >0 and <=0 (mix? ) 6
Back to Library Management System ] … of textbook, at page 278, Figure 8. 3 representing section of code of check. Out. Resource( ) method from the Library. System class 7
Glass-Box Example: check. Out. Resource Public void checkout. Resource(Patron patron, Resource resource) { if(patron. get. Total. Resources. Checked() < 15) { if(resource. get. Status() == HAS_OVER_DUE); { if(resource. get. Status == AVAILABLE) { resource. checkout(patron); } else { new Error. Dialog("resource is NOT available"); } 1 2 3 4 5 } else { new. Error. Dialog("Patron has Overdue Resources out"); } 6 } else { new. Error. Dialog("Patron already has 15 items checked out"); } } 7 8
check. Out. Resource( ) Example start T 1 a. . . F 2 c F b 7 h 6 g T d 3 e F 5 T f 4 . . . finish 9
check. Out. Resource( ) Example - 1 ] Will need at least 4 unit test cases to test check. Out. Resource( ) method with Patron and Resource objects (statement coverage) u Test case id – 1: Patron has borrowed < 15 resources, none of these resources are overdue, and the resource is available Statement Coverage – Start- 1 -2 -3 -4 -Finish u Test case id – 2: Patron has borrowed < 15 resources and none are overdue but the resource is not available Statement Coverage – Start- 1 -2 -3 -5 -Finish u Test case id – 3: Patron has borrowed < 15 resources but at least one resource is overdue Statement Coverage – Start-1 -2 -6 -Finish u Test case id – 4: Patron has borrowed 15 or more resources Statement Coverage – Start-1 -7 -Finish 10
check. Out. Resource( ) Example - 1 ] Will need at least 4 unit test cases to test check. Out. Resource( ) method with Patron and Resource objects (branch coverage) u Test case id – 1: Patron has borrowed < 15 resources, none of these resources are overdue, and the resource is available Branch Coverage – Start- a-d-f-g-h-Finish u Test case id – 2: Patron has borrowed < 15 resources and none are overdue but the resource is not available Branch Coverage – Start- a-d-e-g-h-Finish u Test case id – 3: Patron has borrowed < 15 resources but at least one resource is overdue Branch Coverage – Start- a-c-g-h-Finish u Test case id – 4: Patron has borrowed 15 or more resources Branch Coverage – Start- a-b-h-Finish 11
Library Management System ] representing section of code of check. Out. Resource( ) method from the Library. System class ] Same 4 tests give 100% statement coverage and 100% branch coverage u Start- a-b-h-Finish u Start- a-c-g-h-Finish u Start- a-d-e-g-h-Finish u Start- a-d-f-g-h-Finish ] What about path coverage? ] No loops in code being tested so do not need to consider path coverage. 12
Special Issues for Testing Object. Oriented Systems ] Inheritance and polymorphism makes testing more difficult by requiring more contexts (all sub classes) for testing an inherited module 13
check. Out. Resource( ) Example ] The impact of inheritance and polymorphism in unit testing the method check. Out. Resource( ) is such that the number of test cases will grow from 4 to 64: ] Let's look at each of the four test cases separately and determine how many test cases result when inheritance in considered ] For simplicity assume that borrowing limits are the same for each type of patron (15 maximum), that there are 4 types of patron and 7 types of resource 14
check. Out. Resource( ) Example ] Test case id – 1: Patron has borrowed < 15 resources, none of these resources are overdue, and the resource is available. There are 4 types of patron. Branch Coverage – Start- a-d-f-g-h-Finish u test case id – 1. 1 -> Faculty has borrowed less than 15 resources none of these resources are overdue, and the resource is available. u test case id – 1. 2 -> Student has borrowed less than 15 resources u test case id – 1. 3 -> Library Staff has borrowed less than 15 resources u test case id – 1. 4 -> Local resident has borrowed less than 15 resources 15
check. Out. Resource( ) Example ] Test case id – 1. 1: Faculty has borrowed < 15 resources (all of the same type), none of these resources are overdue, and the resource is available. There are 7 types of resource Branch Coverage – Start- a-d-f-g-h-Finish u test case id – 1. 1. 1 -> Faculty has borrowed less than 15 resources none of these resources are overdue, and the book is available. u test case id – 1. 1. 2 -> … and the video is available u test case id – 1. 1. 3 -> … and the CD is available u test case id – 1. 1. 4 -> … and the software is available u test case id – 1. 1. 5 -> … and the research material is available u test case id – 1. 1. 6 -> … and the on line research resource is available u test case id – 1. 1. 7 -> … and the reserve resource is available ] For this test case there at least 4*7=28 tests 16
check. Out. Resource( ) Example ] Test case id – 2: Patron has borrowed < 15 resources, none of these resources are overdue, and the resource is not available. There are 4 types of patron. Branch Coverage – Start- a-d-f-g-h-Finish u test case id – 2. 1 -> Faculty has borrowed less than 15 resources none of these resources are overdue, and the resource is not available. u test case id – 2. 2 -> Student has borrowed less than 15 resources … u test case id – 2. 3 -> Library Staff has borrowed less than 15 resources … u test case id – 2. 4 -> Local resident has borrowed less than 15 resources … 17
check. Out. Resource( ) Example ] Test case id – 2. 1: Faculty has borrowed < 15 resources (all of the same type), none of these resources are overdue, and the resource is available. There are 7 types of resource Branch Coverage – Start- a-d-e-g-h-Finish u test case id – 2. 1. 1 -> Faculty has borrowed less than 15 resources none of these resources are overdue, and the book is not available. u test case id – 2. 1. 2 -> … and the video is not available u test case id – 2. 1. 3 -> … and the CD is not available u test case id – 2. 1. 4 -> … and the software is not available u test case id – 2. 1. 5 -> … and the research material is not available u test case id – 2. 1. 6 -> … and the on line research resource is not available u test case id – 2. 1. 7 -> … and the reserve resource is not available ] For this test case there at least 4*7=28 tests 18
check. Out. Resource( ) Example ] Test case id – 3: Patron has borrowed < 15 resources, at least one of these resources is overdue, . There are 4 types of patron. Branch Coverage – Start- a-c-g-h-Finish u test case id – 3. 1 -> Faculty has borrowed less than 15 resources and at least one of these resources is overdue u test case id – 3. 2 -> Student has borrowed less than 15 resources and at least one of these resources is overdue u test case id – 3. 3 -> Library Staff has borrowed less than 15 resources and at least one of these resources is overdue u test case id – 3. 4 -> Local resident has borrowed less than 15 resources and at least one of these resources is overdue … 19
check. Out. Resource( ) Example ] test case id – 4 -> Test case id – 4: Patron has borrowed 15 or more resources Branch Coverage – Start- a-b-h-Finish u test case id – 4. 1 -> Faculty has borrowed 15 or more resources u test case id – 4. 2 -> Student has borrowed 15 or more resources u test case id – 4. 3 -> Library Staff has borrowed 15 or more resources u test case id – 4. 4 -> Local resident has borrowed 15 or more resources ] For this test case there are 4 tests. ] For this case the type of resource is not critical since no methods from class resource will be used 20
Example Summary: Testing Object-Oriented Systems ] Inheritance and polymorphism makes testing more difficult by requiring more contexts (all sub classes) for testing an inherited module ] In our example we see that the inheritance of patron (4 inherited cases) and resource (7 inherited cases) causes the number of test cases to increase from 4 to u 4*7+4+4=64 21
Integration Test Cases ] Four kinds of integration tests (read text) u Structure tests u Functional tests u Stress tests u Performance tests ] For us, in 275, we shall focus on u Functional tests 22
Integration Test Case Example ] Example of Thread implementation approach ] Consider Deliverable 7. 2 Implementation Plan Diagram, in textbook at page 246 u Sub phase 1: Check. Out. Resource, Check. In. Resource u Sub phase 2: Manage. Resource u Sub phase 3: Manage. Patron u Sub phase 4: Browse. Resource, Request. Resource, Reserve. Resource 23
LMS Implementation plan diagram ] Order based on importance of each use case as expressed by the user/client gen. Form. Letter patron browse. Resource resourc e Overdue form letter request. Resource reserve. Resource manage. Resource check. Out. Resource manage. Patron Phase 1 Phase 2 Phase 3 Phase 4 check. In. Resource Library staff 24
Integration Test Case Example ] Test id - 53 A ] Test purpose: Integration testing “Manage. Resource” build, specifically “Remove. Resource” scenario ] Requirement # 8, 9 10, 14, 15 ] Inputs: Quantum Physics book call # 165428 -D ] Testing procedure: <include steps of scenario here> ] Evaluation: try to check out Quantum Physics book ] Expected behaviours and results: call # is invalid ] Actual behaviours and results 25
System Test Case ] For us, in 275, our system test case is our User Manual 26