Data Flow Testing Data flow testing(DFT) is NOT directly related to the design diagrams of data-flow-diagrams(DFD). It is a form of structural testing.

Slides:



Advertisements
Similar presentations
Programming In C++ Spring Semester 2013 Lecture 3 Programming In C++, Lecture 3 By Umer Rana.
Advertisements

DATAFLOW TESTING DONE BY A.PRIYA, 08CSEE17, II- M.s.c [C.S].
Overview Structural Testing Introduction – General Concepts
A Survey of Program Slicing Techniques A Survey of Program Slicing Techniques Sections 3.1,3.6 Swathy Shankar
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
Program Slice Program slice was a concept first discussed by Mark Weiser in the early 1980’s –He especially noticed that when people debug, they trace.
ECE453/SE465 Prof. Alencar University of Waterloo 1 Data Flow Testing Slice-Based Testing Winter 2007 Based on the tutorials by Prof. Kontogiannis, Winter.
Csci 565 Spring  Originally proposed by [Weiser 88]and [Gallagher 91] in software maintenance  Useful for  Software Debugging  Software Maintenance.
Data Flow Testing (DFT) Data flow testing is NOT the same as constructing Design Diagrams in the form of data-flow-diagrams (DFD) or E-R diagrams. It is.
Unit Testing CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 27, 2007.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 16, 1999.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts and Debugging.
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.
Software Testing and Quality Assurance White Box Testing.
16/27/ :53 PM6/27/ :53 PM6/27/ :53 PMLogic Control Structures Arithmetic Expressions Used to do arithmetic. Operations consist of +,
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 5 Data Flow Testing
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
Path testing Path testing is a “design structural testing” in that it is based on detailed design & the source code of the program to be tested. The methodology.
Topics in Software Dynamic White-box Testing: Data-flow Testing
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Topics in Software Dynamic White-box Testing Part 2: Data-flow Testing
Path selection criteria Tor Stålhane & ‘Wande Daramola.
Software testing techniques Testing criteria based on data flow
Presented By Dr. Shazzad Hosain Asst. Prof., EECS, NSU
Software Testing (Part 2)
Data Flow Testing Chapter Data Flow Testing Testing All-Nodes and All-Edges in a control flow graph may miss significant test cases Testing All-Paths.
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Course Outline Traditional Static Program Analysis –Theory –Classic analysis and applications Points-to analysis, CHA, RTA –The Soot analysis framework.
White-Box Testing Techniques II Originals prepared by Stephen M. Thebaut, Ph.D. University of Florida Dataflow Testing.
Final Review  Different tests  Boundary Value Testing  Equivalence Class Testing  Decision Table Based Testing  Path Testing  Data Flow & P-Slice.
Reference Paulo Alencar, University of Waterloo Frank Tsui, Southern Polytechnic State University.
Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Coverage Estimating the quality of a test suite. 2 Code Coverage A code coverage model calls out the parts of an implementation that must be exercised.
Summarizing “Structural” Testing Now that we have learned to create test cases through both: – a) Functional (blackbox)and – b) Structural (whitebox) testing.
Overview Structural Testing Introduction – General Concepts
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
September 7, 2004ICP: Chapter 3: Control Structures1 Introduction to Computer Programming Chapter 3: Control Structures Michael Scherger Department of.
1 Graph Coverage (3). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section 2.2 ◦ Section
1 Software Testing & Quality Assurance Lecture 13 Created by: Paulo Alencar Modified by: Frank Xu.
Path selection criteria Tor Stålhane & Wande Daramola.
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.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
Software Dynamic White-box Testing Part 2: Data-flow Testing Lecture 7 Prof. Mostafa Abdel Aziem Mostafa.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
ECE 453, Prof. Kontogiannis University of Waterloo 1 Data Flow Testing Slice-Based Testing Winter 2006 Presented by Nikos Giannopoulos
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Software TestIng White box testing.
CSCE 747 Software Testing and Quality Assurance
Data Flow Testing.
Structural testing, Path Testing
White-Box Testing Techniques II
CHAPTER 4 Test Design Techniques
Unit# 9: Computer Program Development
White-Box Testing Techniques II
Chapter 10 Data Flow Testing Slice Testing
“White box” or “glass box” tests
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
Examining Variables on Flow Paths
White-Box Testing Techniques II
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Unit III – Chapter 3 Path Testing.
Presentation transcript:

Data Flow Testing Data flow testing(DFT) is NOT directly related to the design diagrams of data-flow-diagrams(DFD). It is a form of structural testing and a White Box testing technique that focuses on program variables and the paths: –From the point where a variable, v, is defined or assigned a value –To the point where that variable, v, is used Remember, to generate the path for testing we need to set up the data to drive the path.

Static Analysis of Data Static analysis allows us to check (test or find faults) without running the actual code, and we can apply it to analyzing variables as follows: 1.A variable that is defined but never used 2.A variable that is used but never defined 3.A variable that is defined a multiple times prior to usage. While these are dangerous signs, they may or may not lead to defects. 1.A defined, but never used variable may just be extra stuff 2.Some compilers will assign an initial value of zero or blank to all undefined variable based on the data type. 3.Multiple definitions prior to usage may just be bad and wasteful logic We are more interested in “executing” the code than just static analysis, though.

Variable Define-Use Testing In define-use testing, we are interested in testing (executing) certain paths that a variable is defined – to - its usage. These paths will provide further information that will allow us to decide on choice of test cases beyond just the earlier discussed paths analysis (all statements testing or dd- testing (branch) or linearly independent paths).

Data Dependencies and Data Flow Testing(DFT) In Data Flow Testing (DFT) we are interested in the “dependencies” among data or “relationships” among data Consider a data item, X: –Data Definitions (value assignment) of X: via 1) initialization, 2) input, or 3) some assignment. Integer X; (compiler initializes X to 0 or it will be “trash”) X = 3; Input X; –Data Usage (accessing the value) of X: for 1) computation and assignment (C-Use) or 2) for decision making in a predicate (P-Use) Z = X + 25; (C-Use) If ( X > 0 ) then (P-Use)

Some Definitions Defining node, DEF(v,n), is a node, n, in the program graph where the specific variable, v, is defined or given its value (value assignment). Usage node, USE(v,n), is a node, n, in the program graph where the specific variable, v, is used. A P-use node is a usage node where the variable, v, is used as a predicate (or for a branch-decision-making). A C-use node is any usage node that is not P-used. A Definition-Use path, du-path, for a specific variable, v, is a path where DEF(v,x) and USE(v,y) are the initial and the end nodes (x and y nodes) of that path. A Definition-Clear path for a specific variable, v, is a Definition- Use path with DEF(v,x) and USE(v,y) such that there is no other node in the path that is a defining node of variable, v. (e.g. v does not get reassigned in the path. )

Simple Example 1.Pseudo-code Sample 2. int a, b 3. input (a, b) 4. if (a > b) 5. then Output (a, “ a bigger than b”) 6. else Output (b, “ b is equal or greater than a”) 7.end The following are examples of the definitions: DEF(a, 3) – node 3 is a defining node of variable “a” --- a value is assigned to “a” USE(a, 4) – node 4 is a usage node of variable “a” USE(a, 5) – node 5 is a usage node of variable “a” USE (a,4) is a P-use node while USE(a,5) is C-use node Path that begins with DEF(a,3) and ends with USE(a,4) is a definition-use path of a Path that begins with DEF(a,3) and ends with USE(a,5) is a definition-use path of a Path that begins with DEF(a,3) and ends with USE(a,5) is a definition-clear path of a Path that begins with DEF(b,3) and ends with USE(b.6) is a definition-use path of b Note that: if we choose the definition-use paths [last two examples above] of both variables a and b, then it is the same as executing the decision-decision (dd) path or branch testing. This is type defining not value

“Commission Program” Partial Example from Text : on variable “locks” other assignments 13. Input (locks) 14. While NOT (locks equals -1) 15. Input( stocks, barrels) 16. Totallocks= Totallocks + locks 17. Totalstocks =Totalstocks + stocks 18. Totalbarrels = Totalbarrels + barrels 19. Input (locks) 20. EndWhile false true 21. Output (“Locks sold “, Totallocks) continuing other statements we have DEF(locks,13) and DEF(locks,19) we have USE(locks,14) and USE(locks,16) We can employ the define/use methodology and get the following paths: - path1 = DEF(locks,13) to USE(locks,14) - path2 = DEF(locks,13) to USE(locks,16) - path3 = DEF(locks,19) to USE(locks14) - path4 = DEF(locks,19) to USE(locks,16) But we have not even tested all the branches! Modify Path1 to include nodes and call it Path1’ Also modify Path3 to include nodes and call it Path3’ With Path1’, Path2, Path3’ and Path4, we have covered all 4 cases: 1) Path1’ = by-pass loop, 2) Path2 = drop Into loop, 3) Path3’ = exit loop, and 4) Path4 = repeat the loop (using statement number instead of “node”)

Definitions/Concepts of Definition-Use (DU) Testing All-Defs : contains set of test paths, P, where for every variable v in the program, P includes definition-clear paths from every DEF(v,n) to only one of its use node. All-Uses: contains set of test paths, P, where for every variable v in the program, P includes definition-clear paths from every DEF(v,n) to every use of v and to the successor node of that use node. All-P-Use/Some C-Use: contains set of test paths, P, where for every variable v in the program, P contains definition-clear paths from DEF(v,n) to every predicate –use node of v; and if there is no predicate-use, then the definition-clear path leads to at least one C-use node of v. All-C-Use/Some P-Use: contains set of test paths, P, where for every variable v in the program, P contains definition-clear paths from DEF(v,n) to every computation-use node of v; and if there is no computation-use, then the definition-clear path leads to at least one predicate-use node of v. All-DU-paths: contains the set of paths, P, where for every variable v in the program, P includes definition-clear paths from every DEF(v,n) to every USE(v,n) and to the successor node of each of the USE(v,n), and that these paths are either single loop traversals or they are cycle free.

Summarizing hierarchy All possible paths All-DU-paths All-Uses All-C-Use/some-P-Use All-P-Use/some-C-Use All-Defs Text page 160 has another chain Under All-P-Use/some-C-Use; take a look at that page.

Program Slices A concept related to dataflow analysis (def-use path) is to look at a slice of program that is related to some “variable of interest” and trace the program statements that are in the program slice. (Program slice was first discussed by Mark Weiser in the 1980’s) –Tracing program statements that contribute or affect the value of the variable of interest at some point of the program; { e.g. (v,node) } going “backward” to include all those statements that have affected the variable’s value is considered a slicing of the program with respect to that variable. –The designated program slice then becomes a path that one would consider for testing. This is also a popular, perhaps subconscious, debugging technique used by most of us.

A simple example of Program Slice Pseudo code example 1. int limit = 10; 2. int y = 0; 3. int x = 0; 4. for (int i = 0; i < limit ; i++) 5. { x = x + i; 6. y = y + i 2 ; } 7. print (“ x = “, x, “y =“, y); - Consider that our variable of interest is y at statement 7. (and pick up statements 6 & 2) - But, on second look, we would pick up statements: (because the loop influences statement 6) 2 1 (because limit influences statement 4) -Statements form a program slice related to variable, y - We would include this slice as a test case Note that: in executing just this slice for the value of y at statement 7 is the same as executing the whole example good for tracing bug but ---- for testing?

Definition of Program Slice Given a program P and a set of variables, V, in P, a slice on the variable set V at some statement n, denoted at S(V,n), is a set of all statements in P, “prior to” and at n, that contribute to the values of those variables in V at that statement-fragment n. (note that V can be one or more variables --- empty set V is not considered ) –“Contribute” is a key word that should be expanded to consider various types of contribution ( usage and definition) : 1.P- use (in predicate) 2.C- use (in computation) 3.O- use (in outputs) 4.L-use (used as pointers to locations) 5.I-use (used as part of some iteration counter) 1.I- def (defined through input) 2.A-def (defined via assignment) logical prior, may be physically after

More on Program Slicing Note that we can’t just blindly apply the usage rules. Pseudo code example 1. int limit = 10; 2. int y = 0; 3. int x = 0; 4. for (int i = 0; i < limit ; i++) 5. {x = x + i + y; 6. y = y + i 2 ; } 7. print (“ x = “, x, “y =“, y); Modified to include y Note that we have modified statement 5 of the previous example to include y. Now should S(y,7) include statement 5? Even though this is C-use of y, statement 5 does not “contribute” to the value of y in statement 7. So we do not include 5 in the slice, S(y,7). Also, p-use of other variable not in the set V (in this case V = y) may need to be included because it influences the value of y. In this case, the variable, “limit,” in the “for” statement. So, statement 4 is included in S(y.7) as before. And limit is placed into the set V, Variable of interest.

Program Slices with Previous Partial Example other assignments 13. Input (locks) 14. While NOT (locks = -1) 15. Input( stocks, barrels) 16. totallocks= totallocks + locks 17. totalstocks =totalstocks + stocks 18. Totalbarrels = totalbarrels + barrels 19. Input (locks) 20. EndWhile false true 21. Output (“Locks sold “, totallocks) continuing other statements - For variable, locks, we can see that - nodes 13 and 19 are input-definition nodes - node 14 is a predicate – use node - node 16 is a c-use node Now let’s look at some examples - S (locks, 13) = - S (locks, 14) = (may split this) - S (locks, 16) = (may split this) - S (locks, 19) = Note that statement 16 is not included in these slices even though it is C-use of locks. For variable, stocks: - node 15 is the input-def node - node 14 influences node 15 - node 13 influences node 14 - node 19 influences node 14 So, Slice(stocks,15) =

Program slices Although program slice technique is based on the define-use dataflow approach, we do not need to include all the d-u paths that has no real influencing or contribution value to testing ( or debugging) a particular variable. Program slice requires more analysis, but it allows us to focus on only those parts that are of interest. Remember “testability” from Whitaker’s paper? ---- Perhaps, we can study testability with program slices?