Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.

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 Testing.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
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.
Introduction to Software Engineering Lecture 11 André van der Hoek.
Ch6: Software Verification. 1 White-box testing  Structural testing:  (In)adequacy criteria  Control flow coverage criteria.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 16, 1999.
Ch6: Software Verification. 1 Statement coverage criterion  Informally:  Formally:  Difficult to minimize the number of test cases and still ensure.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Software Testing and Quality Assurance
CS 425/625 Software Engineering Software Testing
Testing an individual module
Chapter 18 Testing Conventional Applications
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
System/Software Testing
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
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.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
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.
Chapter 13: Implementation Phase 13.3 Good Programming Practice 13.6 Module Test Case Selection 13.7 Black-Box Module-Testing Techniques 13.8 Glass-Box.
CSC 480 Software Engineering Lecture 14 Oct 16, 2002.
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke.
Coverage – “Systematic” Testing Chapter 20. Dividing the input space for failure search Testing requires selecting inputs to try on the program, but how.
Introduction to Software Testing
CS /51 Illinois Institute of Technology CS487 Software Engineering Software Testing Techniques Mr. David A. Lash.
Requirements-based Test Generation for Functional Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 1 W. Eric Wong Department.
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
CS451 – Software Testing Technologies Blackbox Testing Equivalence Partitioning.
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.
Software Testing Yonsei University 2 nd Semester, 2014 Woo-Cheol Kim.
Black-box Testing.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
CS451 Lecture 10: Software Testing Yugi Lee STB #555 (816)
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. Black Box Testing  Black box testing is also called functional testing  Black box testing ignores the internal mechanism of a system or component.
1 Software Testing and Quality Assurance Theory and Practice Chapter 6 Domain Testing.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 © 2011 Professor W. Eric Wong, The University of Texas at Dallas Requirements-based Test Generation for Functional Testing W. Eric Wong Department of.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 23, 1999.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Software Testing. SE, Testing, Hans van Vliet, © Nasty question  Suppose you are being asked to lead the team to test the software that controls.
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
Functional testing, Equivalence class testing
CS223: Software Engineering
Software Testing.
Software Testing.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Software Engineering (CSI 321)
CompSci 230 Software Construction
Input Space Partition Testing CS 4501 / 6501 Software Testing
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 6 Domain Testing
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software testing.
Sudipto Ghosh CS 406 Fall 99 November 16, 1999
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 Testing “If you can’t test it, you can’t design it”
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999

11/09/99CS 406 Testing2 Learning objectives Functional testing Equivalence class partitioning Boundary value analysis Structural testing Control flow-based

11/09/99CS 406 Testing3 Testing for correctness Identify the input domain of P. Execute P against each element of the input domain. For each execution of P, check if P generates the correct output as per its specification S.

11/09/99CS 406 Testing4 Input domain The set of all valid inputs that a program P can expect is the input domain of P. The size of an input domain is the number of elements in it. An input domain could be finite or infinite. Finite input domains may be large!

11/09/99CS 406 Testing5 Identifying input domains For the sort program: N: size of the sequence, N < 3 Sequence of N integers, such that for any integer K, 0  K  (e –1), e = 3 K: each element in the sequence Some sequences are: [ ] : An empty sequence (N = 0) [0] : A sequence of size 1 (N = 1) [2 1] : A sequence of size 2 (N = 2)

11/09/99CS 406 Testing6 Size of input domain Suppose that 0  N  10 6 The size of the input domain is the number of all sequences of size 0, 1, 2… The size is computed as: To test for correctness, P needs to be tested on all inputs. How many years would that take?

11/09/99CS 406 Testing7 Exhaustive testing Previous example P is executed on all elements in the input domain. For most programs, exhaustive testing is not feasible What is the alternative?

11/09/99CS 406 Testing8 Partition testing Input domain is partitioned into a finite number of sub-domains. P is then executed on a few elements in each sub-domain. Four sub-domains for our example: [], [2], [2 0], [2 1 0] Reduced from 85 to 4 ! N=0 1 N=1 2 N=3 4 N=2 3

11/09/99CS 406 Testing9 Confidence in your program Confidence is a measure of one’s belief in the correctness of the program Correctness is not measured in binary terms: a correct or incorrect program Measured as a probability of correct operation of a program when used in various scenarios Reliability Test completeness: Extent to which a program has been tested and errors have been found and removed

11/09/99CS 406 Testing10 Types of module testing “Informal testing” performed by programmer while developing module Methodical testing performed by SQA group Nonexecution-based testing Execution-based testing Haphazard data as input Systematically constructed test cases Testing to specifications Testing to code

11/09/99CS 406 Testing11 Testing to specifications Black-box testing Data-driven testing Input/output-driven testing Functional testing Code is ignored, i.e. the internal structure of the code is not important The specification document is the only information used for creating test cases

11/09/99CS 406 Testing12 Testing to code White-box testing Glass-box testing Logic-driven testing Path-oriented testing Specifications are not used to generate the test cases Test “to code,” i.e. the internal structure of the code is important

11/09/99CS 406 Testing13 What is functional testing? Functional testing tests how well a program meets the functionality requirements. When test inputs are generated using program specifications, we say that we are doing functional testing.

11/09/99CS 406 Testing14 Feasibility of functional testing Problem with exhaustive testing Very large (possibly infinite) number of test cases. Need to devise: Small, manageable set of test cases. Maximize the chances of detecting faults. Minimize the chances of wasting test cases by having more than one test case detecting the same fault.

11/09/99CS 406 Testing15 Equivalence class partitioning Divide the domain of all inputs into a set of equivalence classes. If any test in an equivalence class succeeds, then every test in that class will succeed. How would you get ideal equivalence classes? Difficult without looking at the internal structure Difficult even with the internal structure

11/09/99CS 406 Testing16 Equivalence class partitioning Set of all inputs Specifications Put those inputs together for which the behavior pattern of the module is specified to be different into similar groups Equivalence classes

11/09/99CS 406 Testing17 Rationale behind equivalence class partitioning We assume that if the specifications require exactly the same behavior from each element in a class of values, then the program is likely to be constructed so that it either succeeds or fails for each of the values in that class.

11/09/99CS 406 Testing18 Guidelines for partitioning For robust software, we must test for incorrect inputs too. For each equivalence class of valid inputs, we have equivalence classes of invalid inputs. Input condition specifies a range a  X  b. a  X  b (Valid case) X b (invalid cases) Input specifies a value create one for the valid value create two for incorrect (one above, one below)

11/09/99CS 406 Testing19 Guidelines for partitioning Input specifies a value (contd.) For boolean, only one value Input condition specifies a member of a set Create one for the valid value Create one for invalid value (not in the set) Example: Factorial (n), where n  0 Valid classes {0}, {x | x  1} Invalid class {x | x < 0}

11/09/99CS 406 Testing20 Non-overlapping partitions In the previous example, the equivalence classes were non-overlapping, i.e., the sub-domains were disjoint. It is sufficient to pick one test from each equivalence class to test the program. An equivalence class is considered covered if at least one test has been selected from it. Our goal is to cover all equivalence classes.

11/09/99CS 406 Testing21 Overlapping partitions Suppose a program P takes three integers, X, Y and Z. It is known that: X < Y Z > Y X < Y Z > Y X < Y X  Y Z  Y

11/09/99CS 406 Testing22 Overlapping partition:test selection Select 4 test sets as X=4, Y=7, Z=1 (satisfies X < Y) X=4, Y=2, Z=1 (satisfies X  Y) X=1, Y=7, Z=9 (satisfies Z > Y) X=1, Y=7, Z=2 (satisfies Z  Y) Can also reduce the number of test cases to 2 X=4, Y=7, Z=1 (satisfies X < Y and Z  Y) X=4, Y=2, Z=3 (satisfies X  Y and Z > Y)

11/09/99CS 406 Testing23 Boundary Value Analysis (BVA) Observation: Programs that work correctly for a set of values in an equivalence class, fail on some special values. These values lie on the boundary of the equivalence class. Choose an input from a test case from an equivalence class such that the input lies at the edge of the equivalence class. These test cases are “extreme cases”

11/09/99CS 406 Testing24 BVA examples Suppose the range is 0.0  X  (valid input) 1.0 (valid input) -0.1 (invalid input) 1.1 (invalid input) For a list first and last element of the list A program takes a string S and integer X as input such that a  X  b, and length(S)  100. Derive tests.

11/09/99CS 406 Testing25 BVA analysis A program takes two integers X and Y, such that a  X  b, c  Y  d. How many test cases do we get? ab c d

11/09/99CS 406 Testing26 Output variables Equivalence class partitioning can be applied to output variables BVA also can be applied to output data

11/09/99CS 406 Testing27 Testing functions Identify each function implemented in a module Devise test data to test each function separately Module may contain a hierarchy of lower level functions connected by program control structures Perform functional testing recursively Higher level: black-box Lower level: glass-box

11/09/99CS 406 Testing28 Problems with previous approach Usually higher level functions are not as structured Lower level functions are intertwined Functionality does not coincide with module boundaries Distinction between module testing and integration testing is blurred Testing one module is not possible without simultaneously testing other modules whose functionality is used

11/09/99CS 406 Testing29 Structural testing Intent is to exercise the different programming structures and data structures used in the program Intent is not to exercise all the different input and output conditions though this may be a by-product Achieve test cases that force the desired “coverage” of different structures Criteria are formal and precise

11/09/99CS 406 Testing30 Control-flow based criteria Statement coverage Run a series of test cases and ensure that every statement is executed at least once Simplest form of glass box testing What is the weakness? Consider the example: int abs (int x) { if (x >= 0) x = 0 - x; return x; } Error Test inputs: x = 5: What is coverage? x = 0: What is coverage?

11/09/99CS 406 Testing31 Statement coverage Not very strong, may leave errors undetected. Examples: if statement without else part conjunctions of predicates In all these cases, all branches were probably not exercised. Can you think of a better criterion based on the above observation?

11/09/99CS 406 Testing32 Branch coverage Require that every decision is evaluated to true and false values at least once during testing Branch coverage implies statement coverage Each statement is part of some branch

11/09/99CS 406 Testing33 Control flow graph of a program Let G be the graph of a program P. Node: Represents a block of statements that are always executed together Edge (i, j) from node i to node j: Represents a possible transfer of control after executing the last statement of the block represented by node i to the first statement in the block represented by node j.

11/09/99CS 406 Testing34 Control flow graph of a program Start node: Node corresponding to a block whose first statement is the start statement of P. Exit node: Node corresponding to a block whose last statement is an exit statement of P. Path: Finite sequence of nodes (n 1, n 2, …, n k ), k>1 such that there is an edge (n i, n i+1 ) for all nodes n i in the sequence, except the last node n k.

11/09/99CS 406 Testing35 Control flow graph of a program Complete Path: Path whose first node is a start node and the last node is an exit node. All-nodes criterion (statement coverage) All-edges criterion (branch coverage)

11/09/99CS 406 Testing36 An example (x y ) 1.scanf(x, y); if(y < 0) 2. pow = 0 – y; 3.else pow = y; 4.z = 1.0; 5.while(pow != 0) 6. { z = z * x; pow = pow – 1; } 7.if ( y < 0 ) 8. z = 1.0/z; 9.printf(z);

11/09/99CS 406 Testing37 Control Flow Graph of example

11/09/99CS 406 Testing38 Problems with branch coverage What if a decision has many conditions (using and, or) Decision may evaluate to true or false without actually exercising all the conditions int check (int x) { if ((x >= 5) && (x <= 200)) return TRUE; return FALSE; } Error (should be 100) Test inputs: x = 5: x = -5:

11/09/99CS 406 Testing39 Solution? Require all individual conditions to evaluate to true and false Problem: Even if individual conditions evaluate to true and false, the decision may not get both true and false values Solution: Require both decision / condition coverage!! Still there is a problem.

11/09/99CS 406 Testing40 Path testing Some errors are related to some combinations of branches. Presence revealed by an execution of a path that includes those branches. Solution: Require all possible paths in the CFG to be executed during testing. Path-coverage criterion, or all-paths criterion Path coverage implies branch coverage