Presentation is loading. Please wait.

Presentation is loading. Please wait.

Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.

Similar presentations


Presentation on theme: "Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering."— Presentation transcript:

1 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering Lecture 7-2 November 12, 2015 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission of the professor is prohibited.

2 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 2 Today’s Lecture More black-box (specification-based) testing examples White-box (Structural) Testing Quiz 5 study guide

3 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 3 Today’s Lecture More black-box (specification-based) testing examples White-box (Structural) Testing Quiz 5 study guide

4 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 4 Example: Email Imagine we are testing the login functionality of an email program – Input: username, password – Output: login successful or error message Two users: – Mary; maryspassword – Joe; joespassword What possible bases can we use to divide our testing into partitions? – Whether the username and password match – Content of username (all letters, invalid characters…) – Content of password (all letters, invalid characters…)

5 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 5 Login SubdomainsTest Case Input DataExpected Output Password matches Mary, maryspassword Joe, joespassword Success Password matches another user Mary, joespassword Joe, maryspassword Error Password doesn’t match any user Mary, MarysPassword Joe, fjdkslfjkdjf Error Basis: whether or not the password matches the user

6 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 6 Example: Room Scheduler System Imagine we are testing a classroom scheduler program that handles M-F scheduling for five classrooms Room capacities – Room A: 500 – Room B: 300 – Room C: 100 – Room D: 50 – Room E: 20 All classes are 1-hour long, once per week, and can be scheduled between 8am-10pm

7 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 7 Example: Room Scheduler System Input – The current schedule – The number of students in the class to be scheduled – The desired time of the class to be scheduled Output – A list of available rooms that can hold the number of students, ordered from most appropriate (number of students is as close as possible to room capacity without going over) to least appropriate

8 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 8 Example: Room Scheduler System Example – Input: {Current schedule: Room A: M-F: 8-11am, 2-4pm Room B: T-F: 9-10am, 5-8pm Room C: F: 10am-3pm Room D: M-F: 8am-10pm Room E: M-F: 10am-5pm, 8pm-10pm; Num students: 73 Desired time: W 5-6pm} – Expected output: {Room C, Room A} Room capacities Room A: 500 Room B: 300 Room C: 100 Room D: 50 Room E: 20

9 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 9 Example: Room Scheduler System What possible bases can we use to divide our testing into partitions? – Desired time (morning, afternoon, evening, invalid time… AM/PM.. Early, mid-day, late) – Size of class/number of students (small, medium, large) – Fullness of schedule (empty, partially-full, completely full)

10 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 10 Schedule Room 1 SubdomainsTest Case Input DataExpected Output Empty schedule{EMPTY_SCHEDULE, 150, T 5-6pm} {Room B, Room A} Medium full schedule {SCHEDULE_A, 73, W 5- 6pm} {Room C, Room A} Completely full schedule {FULL_SCHEDULE, 425, F 9-10AM} No rooms available {} Basis: Fullness of schedule

11 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 11 Schedule Room 2 SubdomainsTest Case Input DataExpected Output Morning{SCHEDULE_A, 55, W 8- 9AM} Afternoon{SCHEDULE_A, 400, T 1- 2PM} Evening{SCHEDULE_A, 250, M 6- 7PM} Basis: Desired time

12 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 12 Schedule Room 3 SubdomainsTest Case Input DataExpected Output Invalid (<=0){SCHEDULE_A, -5, T 5- 6pm} Error small{SCHEDULE_A, 3, M 2- 3pm} {Room C, Room B} medium{SCHEDULE_A, 250, T 1- 2PM} {Room B, Room A} large{SCHEDULE_A, 500, M 8- 9PM} {Room A} Over capacity (>500) {SCHEDULE_A, 50000, F 3- 4PM} Error Basis: Class size

13 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 13 What are some possible bases for Homework 2? Use Case 1 (Calculate BMI) – Feet (magnitude/types of input) – Inches – Weight Use Case 2 (Find Earliest Available Appointments) – Fullness of schedule – Length of appointment – Number of preferred doctors chosen – Name of doctor

14 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 14 Today’s Lecture More black-box (specification-based) testing examples White-box (Structural) Testing Quiz 5 study guide

15 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 15 White-box / Structural Testing

16 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 16 White-box / Structural Testing Use source code to derive test cases – Build a graph model of the system – State test cases in terms of graph coverage Choose test cases that guarantee different types of coverage – Node/statement coverage – Edge/branch coverage – Loop coverage – Condition coverage – Path coverage

17 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 17 Example: Building the program graph 1Node getSecondElement() { 2 Node head = getHead(); 3 if (head == null) 4 return null; 5 if (head.next == null) 6 return null; 7 return head.next.node; 8} 13 2456 7

18 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 18 Example: Averaging quiz grades 1float quizAverage(float[] scores) { 2 float min = 99999; 3 float total = 0; 4 for (int i = 0 ; i < scores.length ; i++) { 5 if (scores[i] < min) 6 min = scores[i]; 7 total += scores[i]; 8 } 9 total = total – min; 10 return total / (scores.length – 1); 11} 137 824569 10

19 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 19 Node Coverage Select test cases such that every node in the graph is visited – Also called statement coverage Guarantees that every statement in the source code is executed at least once Selects minimal number of test cases 137 824569 10 Test case: { 2 }

20 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 20 Edge Coverage Select test cases such that every edge in the graph is visited – Also called branch coverage Guarantees that every branch in the source code is executed at least once More thorough than node coverage – More likely to reveal logical errors 137 824569 10 Test case: { 1, 2 }

21 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 21 Another White Box Example 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b

22 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 22 Another White Box Example 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

23 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 23 Another White Box Example What test cases are required to make sure every line of code is executed at least once? (Node coverage) 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

24 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 24 Another White Box Example What test cases are required to make sure every line of code is executed at least once? (Node coverage) b > 17 && b-3 > 17 or, b >= 21 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

25 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 25 Another White Box Example What test cases are required to make sure every line of code is executed at least once? (Node coverage) Test case: { 21 } 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

26 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 26 Another White Box Example What test cases are required to make sure every branch is taken at least once? (Edge coverage) 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

27 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 27 Another White Box Example What test cases are required to make sure every branch is taken at least once? (Edge coverage) b > 17, b <= 17 b-3 > 17, b-3 <= 17 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

28 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 28 Another White Box Example What test cases are required to make sure every branch is taken at least once? (Edge coverage) Test case: { 17, 21 } 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

29 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 29 Another White Box Example What test cases are required to make sure that all possible exceptions are thrown? (Fault injection) 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

30 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 30 Another White Box Example What test cases are required to make sure that all possible exceptions are thrown? (Fault injection) b – 50 = 0 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

31 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 31 Another White Box Example What test cases are required to make sure that all possible exceptions are thrown? (Fault injection) Test case: { 50 } 1 a = 17 2 read b from console 3 if a < b 4 while a < b-3 5 a = a / (b–50) 6 print a, b 13 2456

32 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 32 Other Coverage Criteria Loop coverage – Select test cases such that every loop boundary and interior is tested Boundary: 0 iterations Interior: 1 iteration and > 1 iterations – Watch out for nested loops – Less precise than edge coverage Condition coverage – Select test cases such that all conditions are tested if (a > b || c > d) … – More precise than edge coverage

33 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 33 Other Coverage Criteria Path coverage – Select test cases such that every path in the graph is visited – Loops are a problem 0, 1, average, max iterations – Most thorough… – …but is it feasible?

34 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 34 Challenges White-box/structural testing can cover all nodes or edges without revealing obvious faults Some nodes, edges, or loop combinations may be infeasible – Unreachable/unexecutable code “Thoroughness” – A test suite that guarantees edge coverage also guarantees node coverage… – …but it may not find as many faults as a different test suite that only guarantees node coverage

35 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 35 Today’s Lecture More black-box (specification-based) testing examples White-box (Structural) Testing Quiz 5 study guide

36 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 36 Quiz 5 study guide Black-box testing – Equivalence class partitioning – Boundary value analysis White-box testing – Node coverage – Edge coverage – Relative thoroughness of different types of coverage (node, edge, path)

37 Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 37 Next Time Software process models


Download ppt "Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering."

Similar presentations


Ads by Google