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

Slides:



Advertisements
Similar presentations
Introduction to Software Engineering Lecture 11 André van der Hoek.
Advertisements

Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 13.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 6 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 223 Applied Software Design Techniques.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 223 Applied Software Design Techniques.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 11.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 ICS 52 Introduction to Software Engineering Lecture.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 3 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 4 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 8 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 10.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 11.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 14.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 2 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 6 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 7 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 223 Applied Software Design Techniques.
Informatics 43 – April 30, What is a test case? An input to a system, and the correct output. An “input” may be complex. Example: – What is an input.
Topic 13Summer ICS 52: Introduction to Software Engineering Lecture Notes for Summer Quarter, 2003 Michele Rousseau Topic 13 Partially based on.
© 2009 University of California, Irvine – André van der Hoek1June 29, 2015 – 10:35:56 Informatics 122 Software Design II Lecture 4 André van der Hoek &
Topic 12Summer ICS 52: Introduction to Software Engineering Lecture Notes for Summer Quarter, 2003 Michele Rousseau Topic 12 Partially based on.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Chapter 18 Testing Conventional Applications
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
System/Software Testing
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
White-box Testing Black-box Testing Extensions
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 14.
CMSC 345 Fall 2000 Unit Testing. The testing process.
Testing phases. Test data Inputs which have been devised to test the system Test cases Inputs to test the system and the predicted outputs from these.
9/18/2015CPSC , CPSC , Lecture 121 Software Engineering, CPSC , CPSC , Lecture 12.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 3 Duplication.
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 223 Applied Software Design Techniques.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
CS 217 Software Verification and Validation Week 7, Summer 2014 Instructor: Dong Si
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 2 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 11.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 291s Literature Survey in Software.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 7 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 11.
Software Construction Lecture 19 Software Testing-2.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Testing Data Structures Tao Xie Visiting Professor, Peking University Associate Professor, North Carolina State University
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 5 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 13.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 6 Duplication.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 223 Applied Software Design Techniques.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 5 Duplication.
CSC 395 – Software Engineering Lecture 27: White-Box Testing.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 121 Software Design I Lecture 13.
White-Box Testing Techniques. Definition of White-Box Testing Testing based on analysis of internal logic (design, code, etc.). (But expected results.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Dynamic Black-Box Testing Part 1 What is dynamic black-box testing? How to reduce the number of test cases using: Equivalence partitioning Boundary value.
White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, Ghezzi, C. et al., Fundamentals of Software Engineering.
The Joy of Breaking Code Testing Logic and Case Selection
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Whitebox Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

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.

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

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

Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 4 Example: Imagine we are testing the login functionality of an 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…)

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

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

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

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

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)

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

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

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

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

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

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

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

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}

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}

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 Test case: { 2 }

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 Test case: { 1, 2 }

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

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

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

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

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

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

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

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

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

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

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

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

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?

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

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

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)

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