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

Slides:



Advertisements
Similar presentations
Lecture 2: testing Book: Chapter 9 What is testing? Testing is not showing that there are no errors in the program. Testing cannot show that the program.
Advertisements

SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Informatics 43 – May 5, Restatement of goals Want to verify software’s correctness  Need to test  Need to decide on test cases  No set of test.
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.
Testing an individual module
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.
Chapter 18 Testing Conventional Applications
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
Software Testing and QA Theory and Practice (Chapter 4: Control Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Systems Verification and Validation Laboratory Assignment 3
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
CMSC 345 Fall 2000 Unit Testing. The testing process.
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.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
1 Software testing. 2 Testing Objectives Testing is a process of executing a program with the intent of finding an error. A good test case is in that.
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.
Agenda Introduction Overview of White-box testing Basis path testing
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
White-box Testing.
CS 217 Software Verification and Validation Week 7, Summer 2014 Instructor: Dong Si
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Test Case Designing UNIT - 2. Topics Test Requirement Analysis (example) Test Case Designing (sample discussion) Test Data Preparation (example) Test.
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.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Theory and Practice of Software Testing
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Testing Data Structures Tao Xie Visiting Professor, Peking University Associate Professor, North Carolina State University
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Week 6 MondayTuesdayWednesdayThursdayFriday Testing III Reading due Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
Informatics 43 – May 3, Restatement of goals Want to verify software’s correctness  Need to test  Need to decide on test cases  No set of test.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
White-Box Testing Techniques. Definition of White-Box Testing Testing based on analysis of internal logic (design, code, etc.). (But expected results.
Defect testing Testing programs to establish the presence of system defects.
CS223: Software Engineering Lecture 26: Software Testing.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Testing Data Structures
Software Testing.
White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, Ghezzi, C. et al., Fundamentals of Software Engineering.
Software Testing.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
CompSci 230 Software Construction
Input Space Partition Testing CS 4501 / 6501 Software Testing
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Structural testing, Path Testing
White-Box Testing Techniques
CHAPTER 4 Test Design Techniques
Informatics 43 – May 3, 2016.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
Informatics 43 – April 28, 2016.
CSE403 Software Engineering Autumn 2000 More Testing
Software Testing COM /12/2019 Testing/Spring 98.
Paul Ammann & Jeff Offutt
Whitebox Testing.
CSE 1020:Software Development
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Unit III – Chapter 3 Path Testing.
Presentation transcript:

Introduction to Software Engineering Lecture 11 André van der Hoek

Today’s Lecture Structural testing Specification-based testing

Testing Exercise a module, collection of modules, or system Use predetermined inputs (“test case”) Capture actual outputs Compare actual outputs to expected outputs Actual outputs equal to expected outputs  test case succeeds Actual outputs unequal to expected outputs  test case fails

Two Approaches White box testing Structural testing Test cases designed, selected, and ran based on structure of the source code Scale: tests the nitty-gritty Drawbacks: need access to source Black box testing Specification-based testing Test cases designed, selected, and ran based on specifications Scale: tests the overall system behavior Drawback: less systematic

Structural Testing Use source code to derive test cases Build a graph model of the system Control flow Data flow State test cases in terms of graph coverage Choose test cases that guarantee different types of coverage Node coverage Edge coverage Loop coverage Condition coverage Path coverage

Example 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}

Example 1float homeworkAverage(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}

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 }

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 }

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

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?

Challenges Structural testing can cover all nodes or edges without revealing obvious faults No matter what input, program always returns 0 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

More Challenges Interactive programs Listeners or event-driven programs Concurrent programs Exceptions Self-modifying programs Mobile code Constructors/destructors Garbage collection

Specification-Based Testing Use specifications to derive test cases Requirements Design Function signature Based on some kind of input domain Choose test cases that guarantee a wide range of coverage Typical values Boundary values Special cases Invalid input values

“Some Kind of Input Domain” Determine a basis for dividing the input domain into subdomains Subdomains may overlap Possible bases Size Order Structure Correctness Your creative thinking Select test cases from each subdomain One test case may suffice

Example 1float homeworkAverage(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}

Possible Bases Array length Empty array One element Two or three elements Lots of elements Input domain: float[] Basis: array length one small empty large

Possible Bases Position of minimum score Smallest element first Smallest element in middle Smallest element last Input domain: float[] Basis: position of minima somewhere in middle first last

Possible Bases Number of minima Unique minimum A few minima All minima Input domain: float[] Basis: number of minima all data equal 1 minimum 2 minima

Testing Matrix Test case (input) Basis (subdomain) Expected output Notes

homeworkAverage 1 Test case (input) Basis: Array lengthExpected output Notes EmptyOneSmallLarge ()x ! (87.3)x87.3 crashes! (90,95,85)x92.5 (80,81,82,83, 84,85,86,87, 88,89,90,91) x86.0

homeworkAverage 2 Test case (input) Position of minimumExpected output Notes FirstMiddleLast (80,87,88,89)x88.0 (87,88,80,89)x88.0 (99,98,0,97,96)x97.5 (87,88,89,80)x88.0

homeworkAverage 3 Test case (input) Number of minimaExpected output Notes OneSeveralAll (80,87,88,89)x88.0 (87,86,86,88)x87.0 (99,98,0,97,0)x73.5 (88,88,88,88)x88.0

Avoids Problems of Structural Testing Interactive programs Listeners or event-driven programs Concurrent programs Exceptions Self-modifying programs Mobile code Constructors/destructors Garbage collection

Your Tasks 1. Read and study slides of this lecture 2. Read chapter 13 of van Vliet