White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box 44330 Lafayette, LA 70504, USA

Slides:



Advertisements
Similar presentations
Chapter 14 Software Testing Techniques - Testing fundamentals - White-box testing - Black-box testing - Object-oriented testing methods (Source: Pressman,
Advertisements

Chapter 14 Testing Tactics
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.
Creator: ACSession No: 13 Slide No: 1Reviewer: SS CSE300Advanced Software EngineeringFebruary 2006 Testing - Techniques CSE300 Advanced Software Engineering.
Chapter 17 Software Testing Techniques
TESTING LOOPS ● Simple Loops ● Nested Loops ● Concatenated Loops ● Unstructured Loops.
1 “White box” or “glass box” tests “White Box” (or “Glass Box”) Tests.
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
BASIS PATH TESTING ● By Tom McCabe ● McCabe, T., "A Software Complexity Measure," IEEE Trans. Software Engineering, vol. SE-2, December 1976, pp
Testing an individual module
Chapter 18 Testing Conventional Applications
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Software Engineering Lecture 12 Software Testing Techniques 1.
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
Software Systems Verification and Validation Laboratory Assignment 3
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Software Testing Techniques
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
CMSC 345 Fall 2000 Unit Testing. The testing process.
©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.
Software Testing The process of operating a system or component under specified conditions, observing and recording the results, and making an evaluation.
Agenda Introduction Overview of White-box testing Basis path testing
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.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 14a: Software Testing Techniques Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Software Testing and Reliability Southern Methodist University CSE 7314.
These slides are designed to accompany Software Engineering: A Practitioner’s Approach, 6/e (McGraw-Hill 2005). Slides copyright 2005 by Roger Pressman.1.
Presented by: Ritesh Jain Date: 16-Jun-05 Software Quality Testing.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Software Construction Lecture 19 Software Testing-2.
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.
Dynamic Testing.
White Box Testing by : Andika Bayu H.
These slides are designed to accompany Software Engineering: A Practitioner’s Approach, 7/e (McGraw-Hill 2009). Slides copyright 2009 by Roger Pressman.1.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
White-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 7.
1 Lecture 14: Chapter 18 Testing Conventional Applications Slide Set to accompany Software Engineering: A Practitioner’s Approach, 7/e by Roger S. Pressman.
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.
Software Testing. SE, Testing, Hans van Vliet, © Nasty question  Suppose you are being asked to lead the team to test the software that controls.
Chapter 17 Software Testing Techniques
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.
Software Engineering (CSI 321)
Loop Testing.
Chapter 18 Testing Conventional Applications
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
White Box Testing.
White-Box Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
Chapter 18 Testing Conventional Applications
Chapter 18 Testing Conventional Applications
Chapter 14 Software Testing Techniques
“White box” or “glass box” tests
White-Box Testing.
Chapter 18 Testing Conventional Applications
White-Box Testing Techniques I
Control Structure Testing
Chapter 18 Testing Conventional Applications.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Unit III – Chapter 3 Path Testing.
Presentation transcript:

White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA

References: 1) Jalote, section 7.3 2) Roger Pressman, Software Engineering: A Practitioner’s Approach.

Testing Scenario 1 n If we know the function that the product has been designed to perform, tests can show that each function is fully operational. n This approach called Black-Box Testing.

Testing Scenario 2 n If we know the internal workings of a product, tests can show that internal operations perform according to specification, and all components have been exercised. n This approach is called White-Box (Structural) Testing.

Question n Why do we need both? n White box testing wants to force some desired coverage of different structures -- coverage based testing.

Coverage Types 1) Statement Coverage 2) Branch Coverage 3) Path Testing

Statement Coverage n The goal is to execute every statement at least once. n Is this a good or bad idea? int abs( int x ) { if ( x >= 0 ) x = 0 - x; return x; } n If we execute this with {x=0} the criteria will be satisfied - every statement will be executed. But the error will not be detected. Why?

Branch Coverage n Each branch is executed once. Each decision is evaluated to T and F at least once. n This will usually imply statement coverage. n Does this criteria “find” the fault in the abs() function?

Branch Coverage (cont’d) n Branch coverage has problems with multiple (compound) conditions within a decision (&&, ||) n Consider the following: /* x is valid if 0<=x<=100 */ int check( int x ) { if( x>=0 && x<=200 ) return TRUE; else return FALSE; } n If we test this module with x  {-5,5}, then the error will not be revealed.

Path Testing n A path is a sequence of branches executed when a program is executed from start to finish. n Also called a logical path. n The problem with path testing is that even small programs can have very large numbers of paths, especially if they contain loops.

Path Testing (cont’d) n Consider the following flowchart:

Path Testing (cont’d) n There are 100 trillion possible paths to traverse! This would take over 3,000 years. n Obviously, we need to limit the number of paths to execute...

Basis Path Testing n Involves the construction of a flow graph and using the graph to determine a basis set of execution paths for the program. n McCabe’s Cyclomatic Complexity n C.C. = # paths in the basis set.

Constructing a Flow Graph n “primitiv es” sequen ce if-else FT while- do

Flow Graphs (cont’d) more “primitives” do- until case (switch)

Flow Graphs (advanced) if( a || b ) x( ); else y( ); x a yx b if( a && b ) x( ); else y( ); x a yx b T T F F

Example: n Procedure Sort 1) while records remain do read record 2) if record.field1 = 0 3) process record; store record; increment counter; 4) else if record.field2 = 0; 5) reset counter; 6) else process record; 7) endif endif 8) enddo 9) end

Procedure Sort Flow Graph

Cyclomatic Complexity n Once we’ve found the flow graph (G), we can compute the cyclomatic complexity, V(G). n It is simply the number of enclosed regions in the graph plus 1: V(G) = # Regions + 1 V(G) = = 4 n This means that we need 4 independent paths through the graph.

Independent Paths n By independent paths, we mean that no path is a combination of the others in the set. n When constructing them, each “new” path should include some node not previously used. n A good guidelne is to start with a simple path, and change each condition.

Example n Path 1: 1-9 n Path 2: n Path 3: n Path 4: n Note: is not independent because it simply combines paths 2 and 4. n If we choose data to force execution of these 4 basis paths, then we will be executed and every condition will be evaluated on TRUE and FALSE sides.

Loop Testing n Path testing may only force the execution of loops with one TRUE and one FALSE value. n Since loops are the cornerstone of many algorithms, we should derive specific tests to test loop constructs.

Loop Classes n Simple n Nested n Concatenated n Unstructured (FORTRAN, COBOL)

Testing Simple Loops n Assume N is the maximum number of allowable passes through the loop: 1. Skip the loop entirely 2. One pass through the loop 3. Two passes through the loop 4. m passes through the loop where m < N 5. N - 1, N + 1, N passes.

Testing Nested Loops 1. Start at innermost loop. 2. Perform simple loop test for innermost loop. 3. Work outward, conducting tests for the next loop, keeping outer loops at minimum values and other nested loops to “typical” values. 4. Continue until all loops have been tested.

Testing Concatenated Loops n Independend vs. dependent n See text pg. 399

Testing Unstructured Loops n rewrite them

Test Case Generation n Manual generation is tedious. n Some automated methods: u Random generation until desired coverage is reached -- inefficient. u Tools to tell the tester what paths have been covered. Then tester can derive additional test cases to increase coverage.

Instrumentation n Programs are instrumented with probes. n Probes keep track of which branches have been executed. n A preprocessor inserts the probes at strategic locations. n The program is executed on the test data. n A postprocessor analyzes the results. n btool, bmake, bsummary, breport