Classical Test Design Techniques

Slides:



Advertisements
Similar presentations
Testing and Inspecting to Ensure High Quality
Advertisements

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.
Test Case Design Methodologies (Black-box methods)
Coverage Criteria Drawn mostly from Ammann&Offutt and Pezze&Yooung.
Unit Testing CS 4311 Hans Van Vliet, Software Engineering, Principles and Practice, 3rd edition, John Wiley & Sons, Chapter 13.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Nov R McFadyen1 A Traditional Software Development Process Unit test Integration test System test Detailed design Architectural design Analysis.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 16, 1999.
Software Testing. Testing Levels (McConnel) Unit Testing Single programmer involved in writing tested code Component Testing Multiple programmers involved.
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
Testing an individual module
Chapter 18 Testing Conventional Applications
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
TEST CASE DESIGN Prepared by: Fatih Kızkun. OUTLINE Introduction –Importance of Test –Essential Test Case Development A Variety of Test Methods –Risk.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
System/Software Testing
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.
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.
© Andrew IrelandSoftware Design F28SD2 Software Design (F28SD2): Life-Cycle Perspective - Part 2 Andrew Ireland School of Mathematical & Computer Sciences.
1 Testing Course notes for CEN Outline  Introduction:  terminology and philosophy  Factors that influence testing  Testing techniques.
CSC 480 Software Engineering Lecture 14 Oct 16, 2002.
Testing with Formal Methods Ed Brinksma course 2004 A Formal Framework.
CS /51 Illinois Institute of Technology CS487 Software Engineering Software Testing Techniques Mr. David A. Lash.
Software Testing Testing types Testing strategy Testing principles.
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.
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.
Black Box Testing Techniques Chapter 7. Black Box Testing Techniques Prepared by: Kris C. Calpotura, CoE, MSME, MIT  Introduction Introduction  Equivalence.
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.
Black-box Testing.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
Testing Techniques Testing with Finite State Machines Ed Brinksma course 2004.
White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 111 W. Eric Wong Department of Computer Science The.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
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.
CS451 Lecture 10: Software Testing Yugi Lee STB #555 (816)
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.
CSC 395 – Software Engineering Lecture 27: White-Box Testing.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Defect testing Testing programs to establish the presence of system defects.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
White Box Testing. Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A.
Testing Integral part of the software development process.
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.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
TQS - Teste e Qualidade de Software (Software Testing and Quality) Test Case Design – Black Box Testing João Pascoal Faria.
Functional testing, Equivalence class testing
TQS - Teste e Qualidade de Software (Software Testing and Quality) Test Case Design: White Box Testing João Pascoal Faria.
TQS - Teste e Qualidade de Software (Software Testing and Quality) Test Case Design João Pascoal Faria
Software TestIng White box testing.
TQS - Teste e Qualidade de Software (Software Testing and Quality) Test Case Design: White Box Testing João Pascoal Faria.
TQS - Teste e Qualidade de Software (Software Testing and Quality) Test Case Design: White Box Testing João Pascoal Faria.
Decision Table Testing
Software Testing.
Software Engineering (CSI 321)
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
Testing Approaches.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Unit III – Chapter 3 Path Testing.
Presentation transcript:

Classical Test Design Techniques Testing Techniques Classical Test Design Techniques Ed Brinksma course 2004

Classical Test Design Techniques Literature : Test Case Design Chapter 4 of Glenford J. Myers, The Art of Software Testing, Wiley & Sons, 1979. Black-box testing: Equivalence partitioning Boundary value analysis White-box testing Coverage : statement- / branch- / decision- / condition- / path- coverage Black-box and white-box test case design in combination Basics : heuristics and experience TT 2004, Classical Techniques 2

TT 2004, Classical Techniques 3 Types of Testing Level of detail system integration module unit Accessibility security robustness white box black box performance usability reliability functional behaviour Characteristics TT 2004, Classical Techniques 3

Development of Test Cases Complete testing is impossible  Testing cannot guarantee the absence of faults  How to select subset of test cases from all possible test cases with a high chance of detecting most faults ?  Test Case Design Strategies Because : if we have good test suite then we can have more confidence in the product that passes that test suite TT 2004, Classical Techniques 4

Black-Box Testing: Equivalence Partitioning Divide all possible inputs into classes (partitions) such that : There is a finite number of input equivalence classes You may reasonably assume that the program behaves analogously for inputs in the same class one test with a representative value from a class is sufficient if the representative detects a fault then other class members would detect the same fault all inputs i1 i4 i2 i3 TT 2004, Classical Techniques 5

Black-Box Testing : Equivalence Partitioning Strategy : Identify input equivalence classes Based on conditions on inputs/outputs in specification/description Both valid and invalid input equivalence classes Based on heuristics and experience : “input x in [1..10]”  classes : x  1, 1  x  10, x  10 “enumeration A, B, C"  classes : A, B, C, not{A,B,C,} "input integer n"  classes : n not an integer, nmin, minn0, 0nmax, nmax …… Define one/couple of test cases for each class Test cases that cover valid classes Test cases that cover at most one invalid class TT 2004, Classical Techniques 6

Example : Equivalence Partitioning Test a function for calculation of absolute value of an integer x Equivalence classes : Condition Valid eq. classes Invalid eq. Classes nr of inputs 1 0 , > 1 input type integer non-integer particular abs < 0 , >= 0 (1) (2) (3) (4) (5) (6) (7) Test cases : x = -10 (1,4,6) x = 100 (1,4,7) x = - (2) x = “XYZ” (5) x = 10 20 (3) TT 2004, Classical Techniques 7

Example : Equivalence Partitioning Test a program that computes the sum of the first N integers as long as this sum is less than maxint. Otherwise an error should be reported. If N is negative, then it takes the absolute value |N |. Formally: Given integer inputs N and maxint compute result : result = if this <= maxint, error otherwise  K=0 |N| k TT 2004, Classical Techniques 8

Example : Equivalence Partitioning Equivalence classes : Condition Valid eq. classes Invalid eq. classes . nr of inputs 2 < 2, > 2 type of input int int int no-int, no-int int abs(N ) N  0, N  0 maxint  k  maxint,  k > maxint Test Cases : maxint N result . Valid 100 10 55 100 -10 55 10 10 error Invalid 10 - error 10 20 30 error “XYZ” 10 error 100 9.1E4 error TT 2004, Classical Techniques 9

Black-Box Testing : Boundary Value Analysis Based on experience / heuristics : Testing boundary conditions of eq. classes is more effective i.e. values directly on, above, and beneath edges of classes Choose input boundary values as tests in input classes instead of, or additional to arbitrary values Choose also inputs that provoke output boundary values ( values on the boundary of output classes ) Example strategy as extension of equivalence partitioning: choose one (n) arbitrary value(s) in each eq. class choose values exactly on lower and upper boundaries of eq. class choose values immediately below and above each boundary ( if applicable ) TT 2004, Classical Techniques 10

Example : Boundary Value Analysis |x| Test a function for calculation of absolute value of an integer Valid equivalence classes : Condition Valid eq. classes Invalid eq. Classes particular abs < 0, >= 0 Test cases : class x < 0, arbitrary value: x = -10 class x >= 0, arbitrary value x = 100 classes x < 0, x >= 0, on boundary : x = 0 classes x < 0, x >= 0, below and above: x = -1, x = 1 TT 2004, Classical Techniques 11

Example : Boundary Value Analysis Given inputs maxint and N compute result : result = if this <= maxint, error otherwise  K=0 |N| k Valid equivalence classes : condition valid eq. classes . abs(N) N  0, N  0 maxint  k  maxint,  k > maxint Can be extended with maxint<0, maxint >= 0, max integer, …… TT 2004, Classical Techniques 12

Example : Boundary Value Analysis  K=0 |N| k Valid equivalence classes : condition valid eq. classes . abs(N) N  0, N  0 maxint  k  maxint,  k > maxint Test Cases : maxint N result maxint N result 55 10 55 100 0 0 54 10 error 100 -1 1 56 10 55 100 1 1 0 0 0 … … … How to combine the boundary conditions of different inputs ? Take all possible boundary combinations ? This may blow up …… TT 2004, Classical Techniques 13

Black-Box Testing : Cause Effect Graphing Black-box technique to analyse combinations of input conditions Identify causes and effects in specification   inputs outputs current state new state Make Boolean Graph linking causes and effects Annotate impossible combinations of causes and effects Develop decision table from graph with in each column a particular combination of inputs and outputs Transform each column into test case TT 2004, Classical Techniques 14

Black-Box Testing : Cause Effect Graphing  k  maxint  k  maxint N  0 N  0  k error and xor causes  k  maxint 1 1 0 0 inputs  k  maxint 0 0 1 1 N  0 1 0 1 0 N  0 0 1 0 1 effects  k 1 1 0 0 outputs error 0 0 1 1 TT 2004, Classical Techniques 15

Black-Box Testing : Cause Effect Graphing Systematic method for generating test cases representing combinations of conditions Combinatorial explosion of number of possible combinations Some heuristics to reduce this combinatorial explosion Starting point is effects (outputs) then working ‘backwards’ ‘light-weight’ formal methods: transformation into semi-formal Boolean graph A technique : to be combined with others TT 2004, Classical Techniques 16

Black-Box Testing : Error Guessing Just ‘guess’ where the errors are …… Intuition and experience of tester Ad hoc, not really a technique But can be quite effective Strategy: Make a list of possible errors or error-prone situations ( often related to boundary conditions ) Write test cases based on this list TT 2004, Classical Techniques 17

Black-Box Testing : Error Guessing More sophisticated ‘error guessing’ : Risk Analysis Try to identify critical parts of program ( high risk code sections ): parts with unclear specifications developed by junior programmer while his wife was pregnant …… complex code : measure code complexity - tools available (McGabe, Logiscope,…) High-risk code will be more thoroughly tested ( or be rewritten immediately ……) TT 2004, Classical Techniques 18

Black-Box Testing: Which One ? Black-box testing techniques : Equivalence partitioning Boundary value analysis Cause-effect graphing Error guessing ………… test derivation from formal specification Which one to use ? None of them is complete All are based on some kind of heuristics They are complementary TT 2004, Classical Techniques 19

Black-Box Testing: Which One ? Always use a combination of techniques When a formal specification is available try to use it Identify valid and invalid input equivalence classes Identify output equivalence classes Apply boundary value analysis on valid equivalence classes Guess about possible errors Cause-effect graphing for linking inputs and outputs TT 2004, Classical Techniques 20

TT 2004, Classical Techniques 21 White-Box Testing Testing based on program code hence, programming language dependent Extent to which (source) code is executed, i.e. covered Different kind of coverage : path coverage statement coverage (multiple-) condition coverage decision / branch coverage ….. TT 2004, Classical Techniques 21

White-Box Testing: Path Testing Execute every possible path of a program, i.e., every possible sequence of statements Strongest white-box criterion Usually impossible: infinitely many paths ( in case of loops ) So: not a realistic option But note : enormous reduction w.r.t. all possible test cases ( each sequence of statements executed for only one value ) TT 2004, Classical Techniques 22

TT 2004, Classical Techniques 23 Example : Path Testing 1 PROGRAM som ( maxint, N : INT ) 2 INT result := 0 ; i := 0 ; 3 IF N < 0 4 THEN N := - N ; 5 WHILE ( i < N ) AND ( result <= maxint ) 6 DO i := i + 1 ; 7 result := result + i ; 8 OD; 9 IF result <= maxint 10 THEN OUTPUT ( result ) 11 ELSE OUTPUT ( “too large” ) 12 END. TT 2004, Classical Techniques 23

TT 2004, Classical Techniques 24 Example : Path Testing (i<N) and (result<=maxint) i:=i+1; result:=result+i; result<=maxint N < 0 N := -N; output(result); output(too large); exit start yes no Path: start i:=i+1; result:=result+i; …. output(result); exit TT 2004, Classical Techniques 24

White-Box Testing : Statement Coverage Execute every statement of a program Relatively weak criterion Weakest white-box criterion TT 2004, Classical Techniques 25

Example : Statement Coverage i:=i+1; result:=result+i; N := -N; (i<N) and (result<=maxint) result<=maxint N < 0 output(result); output(too large); exit start yes no Tests for complete statement coverage: maxint N 10 -1 0 -1 TT 2004, Classical Techniques 26

White-Box Testing : Branch Coverage Branch coverage == decision coverage Execute every branch of a program : each possible outcome of each decision occurs at least once Example: IF b THEN s1 ELSE s2 CASE x OF 1 : …. 2 : …. 3 : …. TT 2004, Classical Techniques 27

Example : Branch Testing (i<N) and (result<=maxint) result<=maxint N < 0 N := -N; output(result); output(too large); exit start yes no N < 0 Tests for complete statement coverage: maxint N 10 -1 0 -1 is not sufficient for branch coverage; i:=i+1; result:=result+i; Take: maxint N 10 3 0 -1 for complete branch coverage TT 2004, Classical Techniques 28

Example : Branch Testing i:=i+1; result:=result+i; N := -N; (i<N) and (result<=maxint) result<=maxint N < 0 output(result); output(too large); exit start yes no maxint N But: No green path ! 10 3 -1 -1 10 3 -1 -1 -1 -1 Needed : Combination of decisions 10 -3 TT 2004, Classical Techniques 29

Example : Branch Testing i:=i+1; result:=result+i; N:= -N; (i<N) and (result<=maxint) result<=maxint N < 0 output(result); output(“too large”); exit start yes no i:=i+1; result:=result+i; N := -N; (i<N) and (result<=maxint) result<=maxint N < 0 output(result); output(“too large”); exit start yes no Sometimes there are infeasible paths ( infeasible combinations of conditions ) TT 2004, Classical Techniques 30

White-Box Testing : Condition Coverage Design test cases such that each possible outcome of each condition in each decision occurs at least once Example: decision ( i < N ) AND (result <= maxint ) consists of two conditions : ( i < value ) and (result <= maxint ) test cases should be designed such that each gets value true and false at least once TT 2004, Classical Techniques 31

Example : Condition Testing i:=i+1; result:=result+i; N := -N; (i<N) and (result<=maxint) result<=maxint N < 0 output(result); output(“too large”); exit start yes no But ( i = result = 0 ) : maxint N i<value result<=maxint -1 1 true false 1 0 false true gives condition coverage for all conditions But it does not preserve decision (branch) coverage  always take care that condition coverage preserves decision coverage : decision / condition coverage TT 2004, Classical Techniques 32

White-Box testing : Multiple Condition Testing Design test cases for each combination of conditions Example: ( i < N ) (result <= maxint ) false false false true true false true true Implies decision-, condition-, decision/condition coverage But : exponential blow-up Again : some combinations may be infeasible TT 2004, Classical Techniques 33

White-Box Testing : Overview statement coverage decision (branch) coverage condition coverage decision/ condition coverage multiple- condition coverage path coverage TT 2004, Classical Techniques 34

White-Box testing : How to Apply ? Don’t start with designing white-box test cases ! Start with black-box test cases (equivalence partitioning, boundary value analysis, cause effect graphing, derivation with formal methods, …..) Check white-box coverage ( statement-, branch-, condition-, …… coverage ) Use a coverage tool Design additional white-box test cases for not covered code TT 2004, Classical Techniques 35

TT 2004, Classical Techniques 36 A Coverage Tool : tcov Many coverage tools : commercial and open source Standard Unix tool tcov Only statement coverage Compile your program under test with a special option Run a number of test cases A listing indicates how often each statement was executed and percentage of statements executed TT 2004, Classical Techniques 36