White-box Testing.

Slides:



Advertisements
Similar presentations
Software Testing Techniques
Advertisements

Chapter 14 Software Testing Techniques - Testing fundamentals - White-box testing - Black-box testing - Object-oriented testing methods (Source: Pressman,
Software Testing Technique. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves.
Chapter 14 Testing Tactics
Chapter 6 Path Testing 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.
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.
White Box Testing Techniques Dynamic Testing. White box testing(1) Source code is known and used for test design While executing the test cases, the internal.
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.
Unit Testing CS 414 – Software Engineering I Don Bagert Rose-Hulman Institute of Technology January 16, 2003.
Software Engineering Lecture 12 Software Testing Techniques 1.
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
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.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
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.
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.
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.
BASIS PATH TESTING.
White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA
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.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
White-Box Testing Statement coverage Branch coverage Path coverage
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.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Chapter 17 Software Testing Techniques
Based on slides created by Ian Sommerville & Gary Kimura
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
Software TestIng White box testing.
BASIS PATH TESTING.
Software Testing.
Software Testing.
Software Engineering (CSI 321)
Loop Testing.
Structural testing, Path Testing
White-Box Testing Techniques
Types of Testing Visit to more Learning Resources.
White Box Testing.
Software Testing (Lecture 11-a)
Chapter 14 Software Testing Techniques
“White box” or “glass box” tests
White-Box Testing Techniques I
Chapter 14 Software Testing Techniques
By: Lecturer Raoof Talal
Unit III – Chapter 3 Path Testing.
Presentation transcript:

White-box Testing

Contents Advantages Of White Box Testing Control flow graph (CFG) Flow Graph Notation Data Flow Testing Mutation Testing Advantages Of White Box Testing  Disadvantages of white box testing

White-Box Testing Uses the control structure part of component-level design to derive the test cases These test cases Guarantee that all independent paths within a module have been exercised at least once Exercise all logical decisions on their true and false sides Execute all loops at their boundaries and within their operational bounds Exercise internal data structures to ensure their validity “Bugs lurk in corners and congregate at boundaries” BACK

White-Box Testing There exist several popular white-box testing methodologies: control flow graph: Statement coverage Branch coverage Path coverage Data flow based testing: Loop testing Nested Loops Concatenated Loops Unstructured Loops mutation testing: BACK

Control flow graph (CFG) A control flow graph (CFG) describes: the sequence in which different instructions of a program get executed. the way control flows through the program.

Steps to draw Control flow graph Number all the statements of a program. Numbered statements: represent nodes of the control flow graph. An edge from one node to another node exists: if execution of the statement representing the first node can result in transfer of control to the other node.

Example int f1(int x,int y){ while (x != y){ if (x>y) then x=x-y; else y=y-x; } return x; }

1 2 3 4 5 6 Control Flow Graph

Statement Coverage Statement coverage methodology: design test cases so that every statement in a program is executed at least once. The principal idea: unless a statement is executed, we have no way of knowing if an error exists in that statement

Based on the observation: an error in a program can not be discovered unless the part of the program containing the error is executed. Observing that a statement behaves properly for one input value: no guarantee that it will behave correctly for all input values

Example int f1(int x, int y){ 1 while (x != y){ 2 if (x>y) then 3 x=x-y; 4 else y=y-x; 5 } 6 return x; } NOTE:- By choosing the test set {(x=3,y=3),(x=4,y=3), (x=3,y=4)} all statements are executed at least once.

Branch coverage Test cases are designed such that: different branch conditions given true and false values in turn. Similar to code coverage, but stronger Test every branch in all possible directions If statements test both positive and negative directions Switch statements test every branch If no default case, test a value that doesn't match any case Loop statements test for both 0 and > 0 iterations

Basis Path Testing White-box testing technique proposed by Tom McCabe Enables the test case designer to derive a logical complexity measure of a procedural design Uses this measure as a guide for defining a basis set of execution paths Test cases derived to exercise the basis set are guaranteed to execute every statement in the program at least one time during testing

Flow Graph Notation A circle in a graph represents a node, which stands for a sequence of one or more procedural statements A node containing a simple conditional expression is referred to as a predicate node Each compound condition in a conditional expression containing one or more Boolean operators (e.g., and, or) is represented by a separate predicate node A predicate node has two edges leading out from it (True and False) An edge, or a link, is a an arrow representing flow of control in a specific direction An edge must start and terminate at a node An edge does not intersect or cross over another edge Areas bounded by a set of edges and nodes are called regions

Flow Graph Example R4 1 1 FLOW GRAPH 2 2 R3 3 3 6 4 6 4 R2 7 8 5 7 R1 R4 1 1 FLOW GRAPH 2 2 R3 3 3 6 4 6 4 R2 7 8 5 7 R1 8 5 9 9 11 10 11 10

Independent Program Paths Defined as a path through the program from the start node until the end node that introduces at least one new set of processing statements Must move along at least one edge that has not been traversed before by a previous path Basis set for flow graph on previous slide Path 1: 0-1-11 Path 2: 0-1-2-3-4-5-10-1-11 Path 3: 0-1-2-3-6-8-9-10-1-11 Path 4: 0-1-2-3-6-7-9-10-1-11 The number of paths in the basis set is determined by the cyclomatic complexity

Cyclomatic Complexity Provides a quantitative measure of the logical complexity of a program Defines the number of independent paths in the basis set and the number of tests that must be conducted to ensure all statements have been executed at least once Can be computed three ways The number of regions V(G) = E–N+2, where E is the number of edges and N is the number of nodes in graph G V(G) = P+1,where P is the number of predicate nodes Results in the following equations for the example flow graph Number of regions = 4 V(G) = 14 edges – 12 nodes + 2 = 4 V(G) = 3 predicate nodes + 1 = 4

Deriving the Basis Set and Test Cases Using the design or code as a foundation, draw a corresponding flow graph Determine the cyclomatic complexity of the resultant flow graph Determine a basis set of linearly independent paths Prepare test cases that will force execution of each path in the basis set

A Second Flow Graph Example 3 4 1 int functionY(void) 2 { 3 int x = 0; 4 int y = 19; 5 A: x++; 6 if (x > 999) 7 goto D; 8 if (x % 11 == 0) 9 goto B; 10 else goto A; 11 B: if (x % y == 0) 12 goto C; 13 else goto A; 14 C: printf("%d\n", x); 15 goto A; 16 D: printf("End of list\n"); 17 return 0; 18 } 5 6 8 7 10 9 16 11 17 13 12 14 BACK 15

Data Flow Testing The techniques discussed so far have all been based on "control flow" we can also design test cases based on "data flow“(how data flows through the code) Some statements "define" a variable’s value (“variable definition”) Variable declarations with initial values Assignments Incoming parameter values Some statements "use" variable’s value (“variable use”) Expressions on right side of assignment Boolean condition expressions

Loop Testing A white-box testing technique that focuses exclusively on the validity of loop constructs Four different classes of loops exist Simple loops Nested loops Concatenated loops Unstructured loops Testing occurs by varying the loop boundary values Examples: for (i = 0; i < MAX_INDEX; i++) while (currentTemp >= MINIMUM_TEMPERATURE)

Testing of Simple Loops Skip the loop entirely Only one pass through the loop Two passes through the loop m passes through the loop, where m < n n –1, n, n + 1 passes through the loop ‘n’ is the maximum number of allowable passes through the loop

Testing of Nested Loops Start at the innermost loop; set all other loops to minimum values Conduct simple loop tests for the innermost loop while holding the outer loops at their minimum iteration parameter values; add other tests for out-of-range or excluded values Work outward, conducting tests for the next loop, but keeping all other outer loops at minimum values and other nested loops to “typical” values Continue until all loops have been tested

Testing of Concatenated Loops For independent loops, Concatenated Loops means combination of more than one loop In concatenated loops , testing depends upon interdependence among loops If loops are not interdependence, then they should be tested in the someway as nested loops

Testing of Unstructured Loops Redesign the code to reflect the use of structured programming practices Depending on the resultant design, apply testing for simple loops, nested loops, or concatenated loops BACK

Mutation Testing The software is first tested: using an initial testing method based on white-box strategies. After the initial testing is complete, mutation testing is taken up. The idea behind mutation testing: make a few arbitrary small changes to a program at a time.

Mutation Testing Each time the program is changed, it is called a mutated program the change is called a mutant. A mutated program: tested against the full test suite of the program. If there exists at least one test case in the test suite for which: a mutant gives an incorrect result, then the mutant is said to be dead.

If a mutant remains alive: even after all test cases have been exhausted, the test suite is enhanced to kill the mutant. The process of generation and killing of mutants: can be automated by predefining a set of primitive changes that can be applied to the program. The primitive changes can be: altering an arithmetic operator, changing the value of a constant, changing a data type, etc. BACK

Advantages Of White Box Testing Testing can be commenced at an earlier stage. One need not wait for the GUI to be available. Testing is more thorough, with the possibility of covering most paths. BACK

Disadvantages of white box testing Developers often test with the intent to prove that the code works rather than proving that it doesn't work Developers tend to skip the more sophisticated types of white box tests (e.g., condition testing, data flow testing, loop testing, etc.), relying mostly on code coverage And developers also tend to overestimate the level of code coverage White box testing focuses on testing the code that's there. If something is missing, white box testing might not help you. There are many kinds of errors that white box testing won't find Timing and concurrency bugs Volume and load limitations Efficiency problems Usability problems BACK

THANKS BACK TO INDEX