Structural testing, Path Testing

Slides:



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

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
การทดสอบโปรแกรม กระบวนการในการทดสอบ
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
-- Finishing Design Unit -- Intro to Glass Box Testing ECEN5543 / CSCI 5548 SW Eng of Standalone Programs University of Colorado, Boulder.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 16, 1999.
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.
Testing an individual module
Chapter 18 Testing Conventional Applications
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Systems Verification and Validation Laboratory Assignment 3
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.
White-Box Testing Eshcar Hillel Michael Beder. White Box Testing 2 Tutorial Outline What is White Box Testing? Flow Graph and Coverage Types Symbolic.
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.
CSC 480 Software Engineering Lecture 14 Oct 16, 2002.
Path Testing + Coverage Chapter 9 Assigned reading from Binder.
Agenda Introduction Overview of White-box testing Basis path testing
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.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
White-box Testing.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA
CS451 Lecture 10: Software Testing Yugi Lee STB #555 (816)
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.
White Box Testing by : Andika Bayu H.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
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.
ANOOP GANGWAR 5 TH SEM SOFTWARE TESTING MASTER OF COMPUTER APPLICATION-V Sem.
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.
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
Software TestIng White box testing.
BASIS PATH TESTING.
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.
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Software Engineering (CSI 321)
Software Testing and Maintenance 1
CompSci 230 Software Construction
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Data Coverage and Code Coverage
White-Box Testing Techniques
Types of Testing Visit to more Learning Resources.
White Box Testing.
White-Box Testing Techniques II
CHAPTER 4 Test Design Techniques
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
White-Box Testing Techniques II
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.
White-Box Testing Techniques I
White-Box Testing Techniques II
Whitebox Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
By: Lecturer Raoof Talal
Unit III – Chapter 3 Path Testing.
Presentation transcript:

Structural testing, Path Testing

Structural Testing (White Box Testing) Black-box testing is concerned with functionality rather than implementation of the program. White-box testing, on the other hand is concerned with testing the implementation of the program. The idea is not to exercise all the different I/O conditions but to exercise the different programming structures and data structures used in the program. Structural testing aims to achieve test cases that will force the desired coverage of different structures. The criteria for structural testing are generally quite precise as they are based on program structures. White-box testing, sometimes called glass-box testing.

Structural Testing (White Box Testing) Using white-box testing methods we can derive test cases that 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. There are three different approaches to structural testing: control flow-based testing Data flow-based testing Mutation testing

Types of control flow-based testing Statement coverage - Test cases which will execute every statement at least once. Tools exist for help No guarantee that all branches are properly tested. Loop exit? Branch coverage All branches are tested once Path coverage - Restriction of type of paths: Linear code sequences Definition/Use checking (all definition/use paths) Can locate dead code

Control Flow-Based Criteria Here the control flow graph of a program is considered and coverage of various aspects of the graph are specified as criteria. Let the control flow graph or flow graph of a program P be G. Node in this graph represents a block of statements that is always executed together. An 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 of the block represented by node j . Start Node is that whose first statement is the start statement of P, Similarly there is exit node with the last statement of P. A path is a finite sequence of nodes (n1,n2, ...,nk),k > 1, such that there is an edge (ni,ni+1 )for all nodes ni in the sequence (except the last node nk). A complete path is a path whose first node is the start node and the last node is an exit node.

Control Flow-Based Criteria Simplest coverage criteria is statement coverage, Here each statement of the program be executed at least once during testing. i.e. It requires that the paths executed during testing include all the nodes in the graph. This is also called the all-nodes criterion. This method is not very strong as it leave errors e.g. if there is an if statement in the program without having an else clause, the statement coverage criterion for this statement will be satisfied by a test case that evaluates the condition to true. No test case is needed that ensures that the condition in the if statement evaluates to false. Criterion is branch coverage, which requires that each edge in the control flow graph be traversed at least once during testing. i.e. each decision in the program be evaluated to true and false values at least once during testing, often called branch testing.

Control Flow-Based Criteria The problem in branch testing is, if a decision has many conditions in it (consisting of a Boolean expression with Boolean operators and &or). In such situations, a decision can evaluate to true and false without actually exercising all the conditions. Studies have indicated that there are many errors whose presence is not detected by branch testing because some errors are related to some combinations of branches and their presence is revealed by an execution that follows the path that includes those branches. Another Criteria requires all possible paths in the control flow graph be executed during testing. This is called the path coverage criterion or the all-paths criterion, and the testing based on this criterion is often called path testing.

Control Flow-Based Criteria

Control Flow-Based Criteria The problem here is that programs that contain loops can have an infinite number of possible paths. Furthermore, not all paths in a graph may be "feasible" in the sense that there may not be any inputs for which the path can be executed. Here main aim is to select a set of paths that ensure branch coverage criterion and try some other paths that may help reveal errors. One method to decrease the no. of paths is consider two paths same if they are in same loop. Another approach is based on cyclometic complexity . cyclomatic complexity V of a module is the number of independent paths in the flow graph of a module.

Control Flow-Based Criteria The test criterion is that if the cyclomatic complexity of a module is V, then at least V distinct paths must be executed during testing. As these paths are independent others are dependant , and these basic paths are finite.

Basis Path Testing – Estimation of Complexity Measure V(G) This value of V(G), defines the maximum number of test cases to be designed by identifying basis set of execution paths to ensure that all statements are executed at least once. To draw a Flow Graph, find its Cyclomatic Complexity, V(G) and the independent paths for the following piece of code. void foo (float y, float a *, int n) { float x = sin (y) ; if (x > 0.01) z = tan (x) ; else z = cos (x) ; for (int i = 0 ; i < x ; + + i) { a[i] = a[i] * z ; Cout < < a [i] ; } Cout < < a [i] ; }

Basis Path Testing – Estimation of Complexity Measure V(G) Piece of code being covered under Node –1 void foo (float y, float a *, int n) {float x = sin (y) ; if (x > 0.01) Piece of code being covered under Node –2 z = tan (x) ; else Piece of code being covered under Node –3 z = cos (x) ; Piece of code being covered under Node –4 for (int i = 0 ; i < x ; + + i) Piece of code being covered under Node –5 { Piece of code being covered under Node –6 a[i] = a[i] * z ; Cout < < a [i] ; } Piece of code being covered under Node –7 Cout < < a [i] ; } Calculation of V(G) by three methods : V(G) = e – n + 2 ( Where “e” are  edges & “n” are nodes) V(G) = 8 – 7 + 2=3

Path testing (Revision) The objective of path testing is to ensure that the set of test cases is such that each path through the program is executed at least once The starting point for path testing is a program flow graph that shows nodes representing program decisions and arcs representing the flow of control Statements with conditions are therefore nodes in the flow graph

Program flow graphs Describes the program control flow. Each branch is shown as a separate path and loops are shown by arrows looping back to the loop condition node Used as a basis for computing the cyclomatic complexity Cyclomatic complexity = Number of edges - Number of nodes +2

Cyclomatic complexity The number of tests to test all control statements equals the cyclomatic complexity Cyclomatic complexity equals number of conditions in a program Useful if used with care. Does not imply adequacy of testing. Although all paths are executed, all combinations of paths are not executed

Binary search flow graph

Independent paths 1, 2, 3, 8, 9 1, 2, 3, 4, 6, 7, 2 1, 2, 3, 4, 5, 7, 2 1, 2, 3, 4, 6, 7, 2, 8, 9 Test cases should be derived so that all of these paths are executed A dynamic program analyser may be used to check that paths have been executed None of these criteria is sufficient to detect all kind of errors in programs. For example, if a program is missing some control flow paths that are needed to check for a special value (like pointer equals nil and divisor equals zero), then even executing all the paths will not necessarily detect the error. Hence, even the path coverage criterion, which is the strongest of the criteria we have discussed, is not strong enough to guarantee detection of all the errors.

Data Flow Testing The data flow testing method selects test paths of a program according to the locations of definitions and uses of variables in the program. E.g. suppose that each statement in a program is assigned a unique statement number and that each function does not modify its parameters or global variables. For a statement with S as its statement number, DEF(S) = {X | statement S contains a definition of X} USE(S) = {X | statement S contains a use of X} If statement S is an if or loop statement, its DEF set is empty and its USE set is based on the condition of statement S. The definition of variable X at statement S is said to be live at statement S' if there exists a path from statement S to statement S' that contains no other definition of X.

Data Flow Testing A definition-use (DU) chain of variable X is of the form [X, S, S'], where S and S' are statement numbers, X is in DEF(S) and USE(S'), and the definition of X in statement S is live at statement S'. One simple data flow testing strategy is to require that every DU chain be covered at least once, called a DU testing strategy.