Testing Your Program: Input Space Partitioning

Slides:



Advertisements
Similar presentations
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Advertisements

Software Quality Assurance Inspection by Ross Simmerman Software developers follow a method of software quality assurance and try to eliminate bugs prior.
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
Testing Test Plans and Regression Testing. Programs need testing! Writing a program involves more than knowing the syntax and semantics of a language.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
TESTING.
Chapter 8 – Software Testing Lecture 1 1Chapter 8 Software testing The bearing of a child takes nine months, no matter how many women are assigned. Many.
Testing CSE 140 University of Washington 1. Testing Programming to analyze data is powerful It’s useless if the results are not correct Correctness is.
Testing Basics of Testing Presented by: Vijay.C.G – Glister Tech.
Testing -- Part II. Testing The role of testing is to: w Locate errors that can then be fixed to produce a more reliable product w Design tests that systematically.
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Today’s Agenda  HW #1  Finish Introduction  Input Space Partitioning Software Testing and Maintenance 1.
Software Construction Lecture 18 Software Testing.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
Software Testing Input Space Partition Testing. 2 Input Space Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
The Software Development Process
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
 Software Testing Software Testing  Characteristics of Testable Software Characteristics of Testable Software  A Testing Life Cycle A Testing Life.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
Software Development Process CS 360 Lecture 3. Software Process The software process is a structured set of activities required to develop a software.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
What is a software? Computer Software, or just Software, is the collection of computer programs and related data that provide the instructions telling.
CSC 108H: Introduction to Computer Programming
Introduction to Software Testing Part1 Summary & Terms
SOFTWARE TESTING Date: 29-Dec-2016 By: Ram Karthick.
Module A Fundamentals of Testing
Testing Tutorial 7.
Software Testing.
Testing and Debugging PPT By :Dr. R. Mall.
Software Testing Introduction CS 4501 / 6501 Software Testing
SOFTWARE TESTING OVERVIEW
ISP Coverage Criteria CS 4501 / 6501 Software Testing
Input Space Partition Testing CS 4501 / 6501 Software Testing
Software Testing An Introduction.
Verification and Testing
Testing UW CSE 160 Winter 2017.
Faults, Errors, Failures CS 4501 / 6501 Software Testing
Chapter 13 & 14 Software Testing Strategies and Techniques
Algorithm and Ambiguity
UNIT-1 SOFTWARE TESTING FUNDAMENTALS
Testing UW CSE 160 Spring 2018.
UNIT-1 SOFTWARE TESTING FUNDAMENTALS
Lecture 09:Software Testing
Testing UW CSE 160 Winter 2016.
Testing and Test-Driven Development CSC 4700 Software Engineering
CS 1111 Introduction to Programming Fall 2018
Coding Concepts (Basics)
ISP Coverage Criteria CS 4501 / 6501 Software Testing
Algorithm and Ambiguity
Baisc Of Software Testing
Welcome to Corporate Training -1
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Software Verification, Validation, and Acceptance Testing
CSE403 Software Engineering Autumn 2000 More Testing
Test Cases, Test Suites and Test Case management systems
Software Development Techniques
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Presentation transcript:

Testing Your Program: Input Space Partitioning CS 1110 Introduction to Programming Spring 2017

Software is Everywhere Software is a key ingredient in many of the devices and systems Software defines the behaviors of the systems. We use a lot of software CS 1110

Software Failures (1997) Ariane 5 explosion: Exception-handling bug forced self-destruct on maiden flight (64-bit to 16-bit conversion), causing $370 millions (1999) NASA’s Mars lander: Crashed due to a unit integration fault (2003) Northeast blackout: The alarm system in the energy management system failed due to a software error and operators were not informed of the power overload in the system – affected 40 million people in 8 US states, 10 million people in Ontario, Canada (2012) Knight Capital’s trading software: Faults in a new trading algorithm causes $440 millions (2014) Dropbox’s outage was due to a fault in a maintenance script (2016) Information lost after clicking the back button while using TurboTax web software Evidence shows huge lost due to software failures Why? Is it because programmers don’t test their software? Is it because programmers don’t test them properly? Is it because programmers don’t test them enough? One thing for sure, we need to test software to avoid/minimize failures This lecture will introduce you one common, simple, systematic approach to test software (i.e., your programs) Before we look at how we can test our programs, let’s agree on some terminologies CS 1110

Terminologies Software failures: external, incorrect behaviors with respect to the requirements or other descriptions of the expected behavior Example: A patient gives a doctor a list of symptoms (failures) Three kinds of failures we’ve seen Syntax failure Runtime failure Logical failure Software faults: static defects in the software Example: The doctor tries to diagnose the root cause (fault) Faults in software ≈ design mistakes in hardware. CS 1110

An Example in Python # Return index of the first occurrence of a letter in string, # Otherwise, return -1 def get_index_of(string, letter): index = -1 for i in range(1, len(string)): if string[i] == letter: index = i return index # Test1: inputs “python”, “z” print(get_index_of("python", "z")) # expected: -1, actual: -1 # Test2: inputs “python”, “z” print(get_index_of("python", "p")) # expected: 0, actual: -1 Fault: Should start at 0, not 1 Test1 Error: i is 1, not 0, on the first iteration Failure: none Test2 Error: i is 1, not 0, on the first iteration -- Error propagates to the variable index Failure: index is -1 at the return statement For simplicity, this example assumes a function accept a letter of size 1 CS 1110

Overview: Testing What is software testing? Why do we test software? When should we test software? Who should test software? How do we test software? Input space partitioning When do we stop testing? Good enough? CS 1110

Here! Test This! My first “testing” assignment A stack of computer printouts – and no documentation MicroSteff – big software system for the mac V.1.5.1 Jan/2007 1.44 MB MF2-HD DataLife Verdatim Big software program Jan/2011 CS 1110

What is Software Testing? Testing = process of finding input values to check against a software (today’s discussion) Debugging = process of finding a fault given a failure (out of today’s scope) Test case consists of test values and expected results Test values (inputs) Program Actual results Expected results vs Test is a process of finding input values that cause the software to fail To determine if the software fails, given the test inputs, we compare the actual results from running program with the expected results (= the result that will be produced when executing the test if the program satisfies it intended behavior) Testing is fundamentally about choosing finite sets of values from the input domain of the software being tested Give the test inputs, compare the actual results with the expected results CS 1110

Why do We Test Software? Goal of testing Not to prove correctness, but to increase our confidence in correctness Improve quality Reduce overall software development cost Preserve customer satisfaction Get good grades in this course (and any other courses) What fact does each test try to verify? Benefits You are not biased that your code works You will better understand what you need to build You will get insights on how to built it - Know what to check and whether your program handle that properly - Plan how much testing will be enough - Plan the budget CS 1110

When should We Test Software? Testing is the most time consuming and expensive part of software development. Not testing is even more expensive. If we have too little testing effort early, the cost of testing increases Planning for testing after development is prohibitively expensive Cost of late testing 60 50 40 30 20 10 Requirements Fault origin (%) Fault detection (%) Unit cost (X) Assume $1000 unit cost, per fault, 100 faults $6K $13K $20K $360K $250K $100K Integration Test System Test Post- Deployment Design Program/Unit test [source: wiki] An early start to testing reduces the cost and time to rework and produce error-free software that is delivered to the client. However in Software Development Life Cycle (SDLC), testing can be started from the Requirements Gathering phase and continued till the deployment of the software. It also depends on the development model that is being used. For example, in the Waterfall model, formal testing is conducted in the testing phase; but in the incremental model, testing is performed at the end of every increment/iteration and the whole application is tested at the end. Testing is done in different forms at every phase of SDLC: During the requirement gathering phase, the analysis and verification of requirements are also considered as testing. Reviewing the design in the design phase with the intent to improve the design is also considered as testing. Testing performed by a developer on completion of the code is also categorized as testing. Software Engineering Institute; Carnegie Mellon University; Handbook CMU/SEI-96-HB-002 CS 1110

Who should Test Software? CS 1110 students Software designers Software developers/programmers Software testers Project managers End users Basically, everyone involved CS 1110

How do We Test Software ? Acceptance testing (equivalence classes) Boundary testing (corner cases) Exception testing CS 1110

How do We Test Software ? Input Space Partitioning (ISP) – Choose Inputs Testing is fundamentally about choosing finite sets of values from the input domain of the software being tested Input space partitioning describes the input domain of the software Input domain contains all the possible values that the input parameters can have Input parameters can be Parameters to a function Data read from a file Global variables User level inputs Testing is all about choosing test input values to check against the software, If we choose test values randomly, our tests may not cover all scenarios we may extensively test our programs and still leave out some scenarios To systematically create meaningful tests, we can use a technique called input space partitioning Note: many testing techniques are available but we will only look at a common, simple one Domain for each input parameter is partitioned into regions At least one value is chosen from each region to create a meaningful test Each value is assumed to be equally useful for testing CS 1110

ISP: Choosing Test Inputs Identify inputs Find their characteristics Each characteristic allows the testers to define a partition. Partition each characteristic and identify values The partition must cover the entire domain; not overlap Two approaches Interface-based (simpler) Develop characteristics from individual input parameters Can be partially automated in some situations Functionality-based (harder) Develop characteristics from a behavior view May result in better tests, or fewer tests that are as effective Choose tests by combining values of inputs How does ISP work? Identify inputs, parameters, or other categorization  then find characteristics in the inputs Partition each characteristic, must not overlap  each partition represents each characteristic Choose combinations of values to create tests CS 1110

How do We Test Software ? Input Space Partitioning (ISP) – Compare Results Give the test inputs, compare the actual results with the expected results If the actual results == expected result, the program passes the test Otherwise, the program fails the test The test inputs reflect the characteristics of the input parameters The characteristics of the inputs signifies the kinds of faults/bugs in program The kinds of faults/bugs tell what to fix CS 1110

ISP: Example 1 (Interface-based) Choose Test Inputs # Return index of the first occurrence of a letter in string, # Otherwise, return -1 def get_index_of(string, letter): Identify inputs Two parameters: string , letter Find their characteristics C1 = string is empty C2 = letter is empty How to partitioning How to choose a value from each region CS 1110

ISP: Example 1 (Interface-based) Choose Test Inputs Partition each characteristic and identify values Choose tests by combining values of test inputs (assume choosing letter = "p") Characteristic P1 P2 C1 = string is empty True possible values: "" False possible values: "python" C2 = letter is empty possible values: "p" or "z" More blocks/partitions means more tests Test string letter T1 (C1=True, C2=True) "" T2 (C1=True, C2=False) "p" T3 (C1=False, C2=True) "python" T4 (C1=False, C2=False) CS 1110

ISP: Example 1 (Interface-based) Compare Results Specify the expected result of the given test inputs Test string letter Expected result T1 (C1=True, C2=True) "" -1 T2 (C1=True, C2=False) "p" T3 (C1=False, C2=True) "python" T4 (C1=False, C2=False) Put a test case T4 in Python print(get_index_of("python", "p")) # expected: 0 If actual result == expected result, the program passes the test Otherwise, the program fails the test Notice that we don’t even have to look at the code. We only rely on the specification (i.e., know what the program does) to come up with test inputs, With the given test inputs, we can identify the expected output Then use the test inputs, run the program  compare the actual output and the expected outputs We don’t even have to look at the code to come up with the test cases CS 1110

ISP: Example 1 (Functionality-based) Choose Test Inputs # Return index of the first occurrence of letter in string, # Otherwise, return -1 def get_index_of(string, letter): Identify inputs Two parameters: string , letter Find their characteristics C1 = number of occurrence of letter in string C2 = letter occurs first in string C3 = letter occurs last in string No need to look at the code to come up with the test cases. The specification is sufficient. CS 1110

ISP: Example 1 (Functionality-based) Choose Test Inputs Partition each characteristic and identify values Possible values Characteristic P1 P2 P3 C1 = number of occurrence of letter in string 1 > 1 C2 = letter occurs first in string True False C3 = letter occurs last in string C P1 P2 P3 C1 "intro to python", "z" or "intro to python", "" or "", "z" "intro to python", "r" "intro to python", "o" C2 "intro to python", "i" C3 "intro to python", "n" CS 1110

ISP: Example 1 (Functionality-based) Choose Test Inputs Choose tests by combining values of test inputs Choose a characteristic, then choose test values for the characteristic C P1 P2 P3 C1 T1("intro to python", "z") T2("intro to python", "") T3("", "z") T4("intro to python", "r") T5("intro to python", "o") C2 T6("intro to python", "i") C3 T7("intro to python", "n") CS 1110

ISP: Example 1 (Interface-based) Compare Results Specify the expected result of the given test inputs Test string letter Expected result T1 "intro to python" "z" -1 T2 "" T3 T4 "r" 3 T5 "o" 4 T6 "i" T7 "n" 14 print(get_index_of("intro to python", "z")) # expected: -1 … print(get_index_of("intro to python", "i")) # expected: 0 print(get_index_of("intro to python", "n")) # expected: 14 CS 1110

When do We Stop Testing? Time constraint Coverage (Assignments) due date Coverage Test cases cover all characteristics and partitions Characteristics and partitions determine the quality of test cases The quality of test cases determine how thorough the program is tested How do we know when to stop testing? How can we tell if we test enough? CS 1110

Note and Tip I didn’t fail the test. I just found 100 ways to do it wrong. – Benjamin Franklin Did you know? There is an actual tactic called “rubber duck debugging” where programmers verbally explain a broken code to a rubber duck in hopes of finding the solution by describing the problem CS 1110