Presentation is loading. Please wait.

Presentation is loading. Please wait.

Phase Testing: More examples 1. Review: Selecting Glass box test cases  Determine what to test (select types of coverage)  Create a flowchart for code.

Similar presentations


Presentation on theme: "Phase Testing: More examples 1. Review: Selecting Glass box test cases  Determine what to test (select types of coverage)  Create a flowchart for code."— Presentation transcript:

1 Phase Testing: More examples 1

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) \2

3 Review: Select 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 \3

4 Using Black-Box Testing Strategy  Back to our FindMean( ) function …  Consider its parameter, the score file float FindMean( FILE scoreFile ) { /* Reads scores (floats) from file scoreFile */ /* 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

5 Equivalence classes for findMean( …) \5  5 equivalence classes have been defined for dataFile. 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 data file not opened validinvalid valid data file empty data file contains data >0 data file contains data <=0 valid Contains data 0 1 5 3 4 2

6 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:  variable of type FILE is null (e.g. score file does not exist, or could not be opened)  scoreFile is empty  scoreFile contains 1 score >0  scoreFile contains 1 score <0  scoreFile contains many scores > 0  scoreFile contains many scores < =0  scoreFile contains many scores both >0 and <=0 (mix?) \6

7 Back to Library Management System  … of textbook, at page 278, Figure 8.3 representing section of code of checkOutResource( ) method from the LibrarySystem class \7

8 Glass-Box Example: checkOutResource Public void checkoutResource(Patron patron, Resource resource) { if(patron.getTotalResourcesChecked() < 15) { if(resource.getStatus() == HAS_OVER_DUE); { if(resource.getStatus == AVAILABLE) { resource.checkout(patron); } else { new ErrorDialog("resource is NOT available"); } } else { newErrorDialog("Patron has Overdue Resources out"); } } else { newErrorDialog("Patron already has 15 items checked out"); } } \8 1 2 3 4 5 6 7

9 checkOutResource( ) Example \9............ T F F F T T b c e f d a 3 2 1 7 6 5 4 g h start finish

10 checkOutResource( ) Example - 1  Will need at least 4 unit test cases to test checkOutResource( ) method with Patron and Resource objects (statement coverage)  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  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  Test case id – 3: Patron has borrowed < 15 resources but at least one resource is overdue  Statement Coverage – Start-1-2-6-Finish  Test case id – 4: Patron has borrowed 15 or more resources  Statement Coverage – Start-1-7-Finish \10

11 checkOutResource( ) Example - 1  Will need at least 4 unit test cases to test checkOutResource( ) method with Patron and Resource objects (branch coverage)  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  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  Test case id – 3: Patron has borrowed < 15 resources but at least one resource is overdue  Branch Coverage – Start- a-c-g-h-Finish  Test case id – 4: Patron has borrowed 15 or more resources  Branch Coverage – Start- a-b-h-Finish \11

12 Library Management System  representing section of code of checkOutResource( ) method from the LibrarySystem class  Same 4 tests give 100% statement coverage and 100% branch coverage  Start- a-b-h-Finish  Start- a-c-g-h-Finish  Start- a-d-e-g-h-Finish  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

13 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

14 checkOutResource( ) Example  The impact of inheritance and polymorphism in unit testing the method checkOutResource( ) 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

15 checkOutResource( ) 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  test case id – 1.1 -> Faculty has borrowed less than 15 resources none of these resources are overdue, and the resource is available.  test case id – 1.2 -> Student has borrowed less than 15 resources  test case id – 1.3 -> Library Staff has borrowed less than 15 resources  test case id – 1.4 -> Local resident has borrowed less than 15 resources \15

16 checkOutResource( ) 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  test case id – 1.1.1 -> Faculty has borrowed less than 15 resources none of these resources are overdue, and the book is available.  test case id – 1.1.2 -> … and the video is available  test case id – 1.1.3 -> … and the CD is available  test case id – 1.1.4 -> … and the software is available  test case id – 1.1.5 -> … and the research material is available  test case id – 1.1.6 -> … and the on line research resource is available  test case id – 1.1.7 -> … and the reserve resource is available  For this test case there are at least 4*7=28 tests \16

17 checkOutResource( ) 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  test case id – 2.1 -> Faculty has borrowed less than 15 resources none of these resources are overdue, and the resource is not available.  test case id – 2.2 -> Student has borrowed less than 15 resources …  test case id – 2.3 -> Library Staff has borrowed less than 15 resources …  test case id – 2.4 -> Local resident has borrowed less than 15 resources … \17

18 checkOutResource( ) 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  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.  test case id – 2.1.2 -> … and the video is not available  test case id – 2.1.3 -> … and the CD is not available  test case id – 2.1.4 -> … and the software is not available  test case id – 2.1.5 -> … and the research material is not available  test case id – 2.1.6 -> … and the on line research resource is not available  test case id – 2.1.7 -> … and the reserve resource is not available  For this test case there are at least 4*7=28 tests \18

19 checkOutResource( ) 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  test case id – 3.1 -> Faculty has borrowed less than 15 resources and at least one of these resources is overdue  test case id – 3.2 -> Student has borrowed less than 15 resources and at least one of these resources is overdue  test case id – 3.3 -> Library Staff has borrowed less than 15 resources and at least one of these resources is overdue  test case id – 3.4 -> Local resident has borrowed less than 15 resources and at least one of these resources is overdue … \19

20 checkOutResource( ) Example  test case id – 4 -> Test case id – 4: Patron has borrowed 15 or more resources Branch Coverage – Start- a-b-h-Finish  test case id – 4.1 -> Faculty has borrowed 15 or more resources  test case id – 4.2 -> Student has borrowed 15 or more resources  test case id – 4.3 -> Library Staff has borrowed 15 or more resources  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

21 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  4*7+4*7+4+4=64 \21

22 Integration Test Cases  Four kinds of integration tests (read text)  Structure tests  Functional tests  Stress tests  Performance tests  For us, in 275, we shall focus on  Functional tests \22

23 Integration Test Case Example  Example of Thread implementation approach  Consider Deliverable 7.2 Implementation Plan Diagram, in textbook at page 246  Sub phase 1: CheckOutResource, CheckInResource  Sub phase 2: ManageResource  Sub phase 3: ManagePatron  Sub phase 4: BrowseResource, RequestResource, ReserveResource \23

24 LMS Implementation plan diagram  Order based on importance of each use case as expressed by the user/client \24 Library staff browseResource requestResource reserveResource manageResource checkInResource checkOutResource resource patron managePatron genFormLetter Overdue form letter Phase 4 Phase 1 Phase 2 Phase 3

25 Integration Test Case Example  Test id - 53A  Test purpose: Integration testing “ManageResource” build, specifically “RemoveResource” scenario  Requirement # 8, 9 10, 14, 15  Inputs: Quantum Physics book call # 165428-D  Testing procedure:  Evaluation: try to check out Quantum Physics book  Expected behaviours and results: call # is invalid  Actual behaviours and results \25

26 System Test Case  For us, in 275, our system test case is our User Manual \26


Download ppt "Phase Testing: More examples 1. Review: Selecting Glass box test cases  Determine what to test (select types of coverage)  Create a flowchart for code."

Similar presentations


Ads by Google