SlideShare a Scribd company logo
1 of 52
Whitebox Testing 
CS 420 - Spring 2007
A Testing Life Cycle 
Requirement 
Specs 
Design 
Error 
Coding 
Testing 
Fix 
Fault 
Resolution 
Fault 
Isolation 
Fault 
Classification 
Error 
Fault 
Fault 
Fault 
Error 
incident
Terminology 
• Error 
– Represents mistakes made by people 
• Fault 
– Is result of error. May be categorized as 
• Fault of Commission – we enter something into 
representation that is incorrect 
• Fault of Omission – Designer can make error of 
omission, the resulting fault is that something is 
missing that should have been present in the 
representation
Cont… 
• Failure 
– Occurs when fault executes. 
• Incident 
– Behavior of fault. An incident is the 
symptom(s) associated with a failure that 
alerts user to the occurrence of a failure 
• Test case 
– Associated with program behavior. It carries 
set of input and list of expected output
Cont… 
• Verification 
– Process of determining whether output of one 
phase of development conforms to its 
previous phase. 
• Validation 
– Process of determining whether a fully 
developed system conforms to its SRS 
document
Verification versus Validation 
• Verification is concerned with phase 
containment of errors 
• Validation is concerned about the final 
product to be error free
Relationship – program 
behaviors 
Program Behaviors 
Specified 
(expected) 
Behavior 
Programmed 
(observed) 
Fault Behavior 
Of 
Omission 
Fault 
Of 
Commission 
Correct portion
Classification of Test 
• There are two levels of classification 
– One distinguishes at granularity level 
• Unit level 
• System level 
• Integration level 
– Other classification (mostly for unit level) is 
based on methodologies 
• Black box (Functional) Testing 
• White box (Structural) Testing
Relationship – Testing wrt 
Behavior 
Program Behaviors 
5 6 
Specified 
(expected) 
Behavior 
Programmed 
(observed) 
Behavior 
2 
1 
4 3 
Test Cases 
(Verified behavior) 
8 7
Test methodologies 
• Functional (Black box) inspects specified 
behavior 
• Structural (White box) inspects 
programmed behavior
Functional Test cases 
Specified Programmed 
Test 
Cases
Structural Test cases 
Specified Programmed 
Test 
Cases
When to use what 
• Few set of guidelines available 
• A logical approach could be 
– Prepare functional test cases as part of 
specification. However they could be used 
only after unit and/or system is available. 
– Preparation of Structural test cases could be 
part of implementation/code phase. 
– Unit, Integration and System testing are 
performed in order.
Unit testing – essence 
• Applicable to modular design 
– Unit testing inspects individual modules 
• Locate error in smaller region 
– In an integrated system, it may not be easier 
to determine which module has caused fault 
– Reduces debugging efforts
Test cases and Test suites 
• Test case is a triplet [I, S, O] where 
– I is input data 
– S is state of system at which data will be input 
– O is the expected output 
• Test suite is set of all test cases 
• Test cases are not randomly selected. 
Instead even they need to be designed.
Need for designing test cases 
• Almost every non-trivial system has an 
extremely large input data domain thereby 
making exhaustive testing impractical 
• If randomly selected then test case may 
loose significance since it may expose an 
already detected error by some other test 
case
Design of test cases 
• Number of test cases do not determine the 
effectiveness 
• To detect error in following code 
if(x>y) max = x; else max = x; 
• {(x=3, y=2); (x=2, y=3)} will suffice 
• {(x=3, y=2); (x=4, y=3); (x=5, y = 1)} 
• Each test case should detect different errors
White-Box Testing 
• Statement coverage 
• Branch coverage 
• Path coverage 
• Condition coverage 
• Data flow-based testing
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
Statement coverage criterion 
• 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; }
Euclid's GCD computation 
algorithm 
• 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 is given true and 
false values in turn. 
• Branch testing guarantees statement 
coverage: 
– a stronger testing compared to the statement 
coverage-based testing.
Example 
• Test cases for branch coverage can be: 
{(x=3,y=3), (x=4,y=3), (x=3,y=4)}
Condition Coverage 
• Test cases are designed such that: 
– each component of a composite conditional 
expression given both true and false values. 
• Example 
– Consider the conditional expression 
((c1.and.c2).or.c3): 
– Each of c1, c2, and c3 are exercised at least 
once i.e. given true and false values.
Branch testing 
• Branch testing is the simplest condition 
testing strategy 
• compound conditions appearing in 
different branch statements are given true 
and false values. (note: the entire 
condition is given true and false values, 
not ALL possible sub expressions)
Branch testing 
• Condition testing 
– stronger testing than branch testing: 
• Branch testing 
– stronger than statement coverage testing.
Condition coverage 
• Consider a Boolean expression having n 
components: 
– for condition coverage we require 2n test 
cases. 
• practical only if n (the number of 
component conditions) is small.
Path Coverage 
• Design test cases such that: 
– all linearly independent paths in the program 
are executed at least once. 
• Defined in terms of 
– control flow graph (CFG) of a program.
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.
How 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){ 
1. while (x != y){ 
2. if (x>y) then 
3. x=x-y; 
4. else y=y-x; 
5. } 
6. return x; }
Example Control Flow Graph 
1 
2 
3 4 
5 
6
Path 
• A path through a program: 
– A node and edge sequence from the starting 
node to a terminal node of the control flow 
graph. 
– There may be several terminal nodes for 
program.
Independent path 
• Any path through the program: 
– introducing at least one new node or one new 
edge that is not included in any other 
independent paths. 
• It may be straight forward to identify 
linearly independent paths of simple 
programs. However For complicated 
programs it is not so easy to determine the 
number of independent paths.
McCabe's cyclomatic metric 
• An upper bound: 
– for the number of linearly independent paths 
of a program 
• Provides a practical way of determining: 
– the maximum number of linearly independent 
paths in a program.
McCabe's cyclomatic metric 
• Given a control flow graph G, 
cyclomatic complexity V(G): 
– V(G)= E-N+2 
• N is the number of nodes in G 
• E is the number of edges in G
Example 
• Cyclomatic complexity = 
7 – 6 + 2 = 3.
Cyclomatic complexity 
• The cyclomatic complexity of a program 
provides: 
– a lower bound on the number of test cases to 
be designed to get coverage of all linearly 
independent paths. 
– only gives an indication of the minimum 
number of test cases required.
Path Testing - Test Cases 
• Draw control flow graph. (Loops can 
cause an explosion in the number of 
independent paths, so use looping values 
of 0 and 1 to test loops). 
• Determine V(G). 
• Determine the set of linearly independent 
paths. 
• Prepare test cases: 
– to force execution along each path
Example Control Flow Graph 
1 
2 
3 4 
5 
6
Derivation of Test Cases 
• Number of independent paths: 4 
– 1, 6 test case (x=1, y=1) 
– 1, 2, 3, 5, 1, 6 test case(x=1, y=2) 
– 1, 2, 4, 5, 1, 6 test case(x=2, y=1)
An interesting application of 
cyclomatic complexity 
• Relationship exists between: 
– McCabe's metric 
– the number of errors existing in the code, 
– the time required to find and correct the 
errors.
Cyclomatic complexity 
• Cyclomatic complexity of a program: 
– also indicates the psychological complexity of 
a program. 
– difficulty level of understanding the program.
Cyclomatic complexity 
• From maintenance perspective, 
– limit cyclomatic complexity 
• of modules to some reasonable value. 
– Some software development organizations: 
• restrict cyclomatic complexity of functions to some 
max number.
Data-flow-based Testing 
• Basic idea: test the connections between 
variable definitions (“write”) and variable uses 
(“read”) 
• Starting point: variation of the control flow graph 
– Each node represents a single statement, not a chain 
of statements 
• Set DEF(n) contains variables that are defined at 
node n (i.e., they are written) 
• Set USE(n): variables that are read
Example 
Assume y is already initialized 
1 s:= 0; 
2 x:= 0; 
3 while (x<y) { 
4 x:=x+3; 
5 y:=y+2; 
6 if (x+y<10) 
7 s:=s+x+y; 
else 
8 s:=s+x-y; 
1 2 3 
DEF(1) := {s}, USE(1) := 
DEF(2) := {x}, USE(2) := 
DEF(3) := , USE(3) := {x,y} 
DEF(4) := {x}, USE(4) := {x} 
DEF(5) := {y}, USE(5) := {y} 
DEF(6) := , USE(6) := {x,y} 
DEF(7) := {s}, USE(7) := {s,x,y} 
DEF(8) := {s}, USE(8) := {s,x,y} 
DEF(9) := , USE(9) := 
DEF(10) := , USE(10) := 
4 
5 
6 
7 8 
9 
10
Reaching Definitions 
A definition of variable x at node n1 
reaches node n2 if and only if there is 
a path between n1 and n2 that does 
not contain a definition of x 
1 2 3 
DEF(1) := {s}, USE(1) := 
DEF(2) := {x}, USE(2) := 
DEF(3) := , USE(3) := {x,y} 
DEF(4) := {x}, USE(4) := {x} 
DEF(5) := {y}, USE(5) := {y} 
DEF(6) := , USE(6) := {x,y} 
DEF(7) := {s}, USE(7) := {s,x,y} 
DEF(8) := {s}, USE(8) := {s,x,y} 
4 
5 
6 
7 8 
9 
10 
Reaches 
nodes 
2,3,4,5,6,7,8, 
but not 9 and 
10.
Def-use Pairs 
• A def-use pair (DU) for variable x is a pair of 
nodes (n1,n2) such that 
– x is in DEF(n1) 
– The definition of x at n1 reaches n2 
– x is in USE(n2) 
• In other words, the value that is assigned to x at 
n1 is used at n2 
– Since the definition reaches n2, the value is not killed 
along some path n1...n2.
Examples of Def-Use Pairs 
1 2 3 
DEF(1) := {s}, USE(1) := 
DEF(2) := {x}, USE(2) := 
DEF(3) := , USE(3) := {x,y} 
DEF(4) := {x}, USE(4) := {x} 
DEF(5) := {y}, USE(5) := {y} 
DEF(6) := , USE(6) := {x,y} 
DEF(7) := {s}, USE(7) := {s,x,y} 
DEF(8) := {s}, USE(8) := {s,x,y} 
4 
5 
6 
7 8 
9 
10 
Reaches nodes 2, 3, 4, 5, 6, 
7, 8, but not 9,10 
For this 
definition, two 
DU pairs: 
1-7, 1-8
Data-flow-based Testing 
• Identify all DU pairs and construct test cases 
that cover these pairs 
– Several variations with different “relative strength” 
• All-DU-paths: For each DU pair (n1,n2) for x, 
exercise all possible paths n1, n2 that are clear 
of a definition of x 
• All-uses: for each DU pair (n1,n2) for x, 
exercise at least one path n1 n2 that is clear of 
definitions of x
Data-flow-based Testing 
• All-definitions: for each definition, cover at 
least one DU pair for that definition 
– i.e., if x is defined at n1, execute at least one path 
n1..n2 such that x is in USE(n2) and the path is clear 
of definitions of x 
• Clearly, all-definitions is subsumed by all-uses 
which is subsumed by all-DU-paths 
• Motivation: see the effects of using the values 
produced by computations 
– Focuses on the data, while control-flow-based 
testing focuses on the control

More Related Content

What's hot

03 fmea表格使用說明
03 fmea表格使用說明03 fmea表格使用說明
03 fmea表格使用說明營松 林
 
Testing documents
Testing documentsTesting documents
Testing documentssuhasreddy1
 
Oracle Unit Testing with utPLSQL
Oracle Unit Testing with utPLSQLOracle Unit Testing with utPLSQL
Oracle Unit Testing with utPLSQLBrendan Furey
 
Lucene Introduction
Lucene IntroductionLucene Introduction
Lucene Introductionotisg
 
Ukoug webinar - testing PLSQL APIs with utPLSQL v3
Ukoug webinar - testing PLSQL APIs with utPLSQL v3Ukoug webinar - testing PLSQL APIs with utPLSQL v3
Ukoug webinar - testing PLSQL APIs with utPLSQL v3Jacek Gebal
 
Introduction to Unified Functional Testing 12 (UFT)
Introduction to Unified Functional Testing 12 (UFT)Introduction to Unified Functional Testing 12 (UFT)
Introduction to Unified Functional Testing 12 (UFT)Archana Krushnan
 
Sumo Logic Search Job API
Sumo Logic Search Job APISumo Logic Search Job API
Sumo Logic Search Job APISumo Logic
 
整合型計劃的管理思維與工具應用
整合型計劃的管理思維與工具應用整合型計劃的管理思維與工具應用
整合型計劃的管理思維與工具應用tarm-tw
 
What is Regression Testing? | Edureka
What is Regression Testing? | EdurekaWhat is Regression Testing? | Edureka
What is Regression Testing? | EdurekaEdureka!
 
Dowhy: An end-to-end library for causal inference
Dowhy: An end-to-end library for causal inferenceDowhy: An end-to-end library for causal inference
Dowhy: An end-to-end library for causal inferenceAmit Sharma
 
UFT Automation Framework Introduction
UFT Automation Framework IntroductionUFT Automation Framework Introduction
UFT Automation Framework IntroductionHimal Bandara
 
Hybrid automation framework
Hybrid automation frameworkHybrid automation framework
Hybrid automation frameworkdoai tran
 

What's hot (20)

03 fmea表格使用說明
03 fmea表格使用說明03 fmea表格使用說明
03 fmea表格使用說明
 
Testing documents
Testing documentsTesting documents
Testing documents
 
Appium vs Espresso and XCUI Test
Appium vs Espresso and XCUI TestAppium vs Espresso and XCUI Test
Appium vs Espresso and XCUI Test
 
Oracle Unit Testing with utPLSQL
Oracle Unit Testing with utPLSQLOracle Unit Testing with utPLSQL
Oracle Unit Testing with utPLSQL
 
Automation testing
Automation testingAutomation testing
Automation testing
 
TestNG
TestNGTestNG
TestNG
 
Lucene Introduction
Lucene IntroductionLucene Introduction
Lucene Introduction
 
Testing & Quality Assurance
Testing & Quality AssuranceTesting & Quality Assurance
Testing & Quality Assurance
 
Ukoug webinar - testing PLSQL APIs with utPLSQL v3
Ukoug webinar - testing PLSQL APIs with utPLSQL v3Ukoug webinar - testing PLSQL APIs with utPLSQL v3
Ukoug webinar - testing PLSQL APIs with utPLSQL v3
 
精實6S Lean 6S
精實6S Lean 6S精實6S Lean 6S
精實6S Lean 6S
 
Introduction to Unified Functional Testing 12 (UFT)
Introduction to Unified Functional Testing 12 (UFT)Introduction to Unified Functional Testing 12 (UFT)
Introduction to Unified Functional Testing 12 (UFT)
 
Sumo Logic Search Job API
Sumo Logic Search Job APISumo Logic Search Job API
Sumo Logic Search Job API
 
Sentiment Analysis
Sentiment AnalysisSentiment Analysis
Sentiment Analysis
 
VDA 6.3 過程稽核說明
VDA 6.3 過程稽核說明VDA 6.3 過程稽核說明
VDA 6.3 過程稽核說明
 
Test automation proposal
Test automation proposalTest automation proposal
Test automation proposal
 
整合型計劃的管理思維與工具應用
整合型計劃的管理思維與工具應用整合型計劃的管理思維與工具應用
整合型計劃的管理思維與工具應用
 
What is Regression Testing? | Edureka
What is Regression Testing? | EdurekaWhat is Regression Testing? | Edureka
What is Regression Testing? | Edureka
 
Dowhy: An end-to-end library for causal inference
Dowhy: An end-to-end library for causal inferenceDowhy: An end-to-end library for causal inference
Dowhy: An end-to-end library for causal inference
 
UFT Automation Framework Introduction
UFT Automation Framework IntroductionUFT Automation Framework Introduction
UFT Automation Framework Introduction
 
Hybrid automation framework
Hybrid automation frameworkHybrid automation framework
Hybrid automation framework
 

Viewers also liked

Extended Essay Poster part 1
Extended Essay Poster part 1Extended Essay Poster part 1
Extended Essay Poster part 1Assia Chelaghma
 
Ed300 helen's part
Ed300 helen's partEd300 helen's part
Ed300 helen's parthelenjoyjose
 
The au-co-presentation
The au-co-presentationThe au-co-presentation
The au-co-presentationBhaya Cruises
 
Field lab assignment
Field lab assignmentField lab assignment
Field lab assignmentsantillan9
 
Bhaya cruises Presentation update Dec.2013
Bhaya cruises Presentation  update Dec.2013Bhaya cruises Presentation  update Dec.2013
Bhaya cruises Presentation update Dec.2013Bhaya Cruises
 
Evaluation
EvaluationEvaluation
Evaluationharps123
 
15 peranan guru dan cabaran
15 peranan guru dan cabaran15 peranan guru dan cabaran
15 peranan guru dan cabaranDidie Patient
 
Public speaking tips ageng tp 031108040
Public speaking tips ageng tp 031108040Public speaking tips ageng tp 031108040
Public speaking tips ageng tp 031108040DimensiAgeng
 
Global South Development Magazine July 2010
Global South Development Magazine July 2010Global South Development Magazine July 2010
Global South Development Magazine July 2010globalsouth
 
YESdigital European Project - PBL e guide
YESdigital European Project - PBL e guideYESdigital European Project - PBL e guide
YESdigital European Project - PBL e guideNicoleta Olcott
 
Desmania Autostudio Brochure
Desmania Autostudio BrochureDesmania Autostudio Brochure
Desmania Autostudio BrochureDesmania_Design
 
пэр для см
пэр для смпэр для см
пэр для смDemanessa
 
組み込みーモバイルークラウドをオープンな形でつなぐ
組み込みーモバイルークラウドをオープンな形でつなぐ組み込みーモバイルークラウドをオープンな形でつなぐ
組み込みーモバイルークラウドをオープンな形でつなぐKenichi Yoshida
 
Martyanovy shakleiny voinovy
Martyanovy shakleiny voinovyMartyanovy shakleiny voinovy
Martyanovy shakleiny voinovyDemanessa
 
Впровадження електронних технології в місті львові
Впровадження електронних технології в місті львовіВпровадження електронних технології в місті львові
Впровадження електронних технології в місті львовіOlena Ursu
 
Delocalizzazione cementificio moccia scelta condivisa
Delocalizzazione cementificio moccia scelta condivisaDelocalizzazione cementificio moccia scelta condivisa
Delocalizzazione cementificio moccia scelta condivisaGiuseppe Messina
 
ロボットサミットについてin愛媛on2012年3月
ロボットサミットについてin愛媛on2012年3月ロボットサミットについてin愛媛on2012年3月
ロボットサミットについてin愛媛on2012年3月Kenichi Yoshida
 

Viewers also liked (20)

Extended Essay Poster part 1
Extended Essay Poster part 1Extended Essay Poster part 1
Extended Essay Poster part 1
 
Ppt
PptPpt
Ppt
 
Electronic cash
Electronic cashElectronic cash
Electronic cash
 
Ed300 helen's part
Ed300 helen's partEd300 helen's part
Ed300 helen's part
 
The au-co-presentation
The au-co-presentationThe au-co-presentation
The au-co-presentation
 
Field lab assignment
Field lab assignmentField lab assignment
Field lab assignment
 
Bhaya cruises Presentation update Dec.2013
Bhaya cruises Presentation  update Dec.2013Bhaya cruises Presentation  update Dec.2013
Bhaya cruises Presentation update Dec.2013
 
Evaluation
EvaluationEvaluation
Evaluation
 
15 peranan guru dan cabaran
15 peranan guru dan cabaran15 peranan guru dan cabaran
15 peranan guru dan cabaran
 
Public speaking tips ageng tp 031108040
Public speaking tips ageng tp 031108040Public speaking tips ageng tp 031108040
Public speaking tips ageng tp 031108040
 
Global South Development Magazine July 2010
Global South Development Magazine July 2010Global South Development Magazine July 2010
Global South Development Magazine July 2010
 
YESdigital European Project - PBL e guide
YESdigital European Project - PBL e guideYESdigital European Project - PBL e guide
YESdigital European Project - PBL e guide
 
Desmania Autostudio Brochure
Desmania Autostudio BrochureDesmania Autostudio Brochure
Desmania Autostudio Brochure
 
пэр для см
пэр для смпэр для см
пэр для см
 
組み込みーモバイルークラウドをオープンな形でつなぐ
組み込みーモバイルークラウドをオープンな形でつなぐ組み込みーモバイルークラウドをオープンな形でつなぐ
組み込みーモバイルークラウドをオープンな形でつなぐ
 
Prezentacja1
Prezentacja1Prezentacja1
Prezentacja1
 
Martyanovy shakleiny voinovy
Martyanovy shakleiny voinovyMartyanovy shakleiny voinovy
Martyanovy shakleiny voinovy
 
Впровадження електронних технології в місті львові
Впровадження електронних технології в місті львовіВпровадження електронних технології в місті львові
Впровадження електронних технології в місті львові
 
Delocalizzazione cementificio moccia scelta condivisa
Delocalizzazione cementificio moccia scelta condivisaDelocalizzazione cementificio moccia scelta condivisa
Delocalizzazione cementificio moccia scelta condivisa
 
ロボットサミットについてin愛媛on2012年3月
ロボットサミットについてin愛媛on2012年3月ロボットサミットについてin愛媛on2012年3月
ロボットサミットについてin愛媛on2012年3月
 

Similar to 11 whiteboxtesting

Seii unit6 software-testing-techniques
Seii unit6 software-testing-techniquesSeii unit6 software-testing-techniques
Seii unit6 software-testing-techniquesAhmad sohail Kakar
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniquesFincy V.J
 
Newsoftware testing-techniques-141114004511-conversion-gate01
Newsoftware testing-techniques-141114004511-conversion-gate01Newsoftware testing-techniques-141114004511-conversion-gate01
Newsoftware testing-techniques-141114004511-conversion-gate01Mr. Jhon
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)ShudipPal
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)ShudipPal
 
Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testingAjit Nayak
 
Class9_SW_Testing_Strategies.pdf
Class9_SW_Testing_Strategies.pdfClass9_SW_Testing_Strategies.pdf
Class9_SW_Testing_Strategies.pdfFarjanaParvin5
 
Chapter 14 software testing techniques
Chapter 14 software testing techniquesChapter 14 software testing techniques
Chapter 14 software testing techniquesSHREEHARI WADAWADAGI
 
Software Testing Techniques
Software Testing TechniquesSoftware Testing Techniques
Software Testing TechniquesKiran Kumar
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhPankaj Thakur
 
CS8494 SOFTWARE ENGINEERING Unit-4
CS8494 SOFTWARE ENGINEERING Unit-4CS8494 SOFTWARE ENGINEERING Unit-4
CS8494 SOFTWARE ENGINEERING Unit-4SIMONTHOMAS S
 
Lecture (Software Testing).pptx
Lecture (Software Testing).pptxLecture (Software Testing).pptx
Lecture (Software Testing).pptxskknowledge
 
SE UNIT 5 part 2 (1).pptx
SE UNIT 5 part 2 (1).pptxSE UNIT 5 part 2 (1).pptx
SE UNIT 5 part 2 (1).pptxPraneethBhai1
 
Qat09 presentations dxw07u
Qat09 presentations dxw07uQat09 presentations dxw07u
Qat09 presentations dxw07uShubham Sharma
 

Similar to 11 whiteboxtesting (20)

Seii unit6 software-testing-techniques
Seii unit6 software-testing-techniquesSeii unit6 software-testing-techniques
Seii unit6 software-testing-techniques
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniques
 
Newsoftware testing-techniques-141114004511-conversion-gate01
Newsoftware testing-techniques-141114004511-conversion-gate01Newsoftware testing-techniques-141114004511-conversion-gate01
Newsoftware testing-techniques-141114004511-conversion-gate01
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)
 
Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testing
 
Class9_SW_Testing_Strategies.pdf
Class9_SW_Testing_Strategies.pdfClass9_SW_Testing_Strategies.pdf
Class9_SW_Testing_Strategies.pdf
 
Chapter 14 software testing techniques
Chapter 14 software testing techniquesChapter 14 software testing techniques
Chapter 14 software testing techniques
 
AutoTest.ppt
AutoTest.pptAutoTest.ppt
AutoTest.ppt
 
AutoTest.ppt
AutoTest.pptAutoTest.ppt
AutoTest.ppt
 
AutoTest.ppt
AutoTest.pptAutoTest.ppt
AutoTest.ppt
 
Test Techniques
Test TechniquesTest Techniques
Test Techniques
 
Software Testing Techniques
Software Testing TechniquesSoftware Testing Techniques
Software Testing Techniques
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR Chandigarh
 
CS8494 SOFTWARE ENGINEERING Unit-4
CS8494 SOFTWARE ENGINEERING Unit-4CS8494 SOFTWARE ENGINEERING Unit-4
CS8494 SOFTWARE ENGINEERING Unit-4
 
Se unit 4
Se unit 4Se unit 4
Se unit 4
 
Lecture (Software Testing).pptx
Lecture (Software Testing).pptxLecture (Software Testing).pptx
Lecture (Software Testing).pptx
 
SE UNIT 5 part 2 (1).pptx
SE UNIT 5 part 2 (1).pptxSE UNIT 5 part 2 (1).pptx
SE UNIT 5 part 2 (1).pptx
 
Qat09 presentations dxw07u
Qat09 presentations dxw07uQat09 presentations dxw07u
Qat09 presentations dxw07u
 
Testing part 2 bb
Testing part 2 bbTesting part 2 bb
Testing part 2 bb
 

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 

11 whiteboxtesting

  • 1. Whitebox Testing CS 420 - Spring 2007
  • 2. A Testing Life Cycle Requirement Specs Design Error Coding Testing Fix Fault Resolution Fault Isolation Fault Classification Error Fault Fault Fault Error incident
  • 3. Terminology • Error – Represents mistakes made by people • Fault – Is result of error. May be categorized as • Fault of Commission – we enter something into representation that is incorrect • Fault of Omission – Designer can make error of omission, the resulting fault is that something is missing that should have been present in the representation
  • 4. Cont… • Failure – Occurs when fault executes. • Incident – Behavior of fault. An incident is the symptom(s) associated with a failure that alerts user to the occurrence of a failure • Test case – Associated with program behavior. It carries set of input and list of expected output
  • 5. Cont… • Verification – Process of determining whether output of one phase of development conforms to its previous phase. • Validation – Process of determining whether a fully developed system conforms to its SRS document
  • 6. Verification versus Validation • Verification is concerned with phase containment of errors • Validation is concerned about the final product to be error free
  • 7. Relationship – program behaviors Program Behaviors Specified (expected) Behavior Programmed (observed) Fault Behavior Of Omission Fault Of Commission Correct portion
  • 8. Classification of Test • There are two levels of classification – One distinguishes at granularity level • Unit level • System level • Integration level – Other classification (mostly for unit level) is based on methodologies • Black box (Functional) Testing • White box (Structural) Testing
  • 9. Relationship – Testing wrt Behavior Program Behaviors 5 6 Specified (expected) Behavior Programmed (observed) Behavior 2 1 4 3 Test Cases (Verified behavior) 8 7
  • 10. Test methodologies • Functional (Black box) inspects specified behavior • Structural (White box) inspects programmed behavior
  • 11. Functional Test cases Specified Programmed Test Cases
  • 12. Structural Test cases Specified Programmed Test Cases
  • 13. When to use what • Few set of guidelines available • A logical approach could be – Prepare functional test cases as part of specification. However they could be used only after unit and/or system is available. – Preparation of Structural test cases could be part of implementation/code phase. – Unit, Integration and System testing are performed in order.
  • 14. Unit testing – essence • Applicable to modular design – Unit testing inspects individual modules • Locate error in smaller region – In an integrated system, it may not be easier to determine which module has caused fault – Reduces debugging efforts
  • 15. Test cases and Test suites • Test case is a triplet [I, S, O] where – I is input data – S is state of system at which data will be input – O is the expected output • Test suite is set of all test cases • Test cases are not randomly selected. Instead even they need to be designed.
  • 16. Need for designing test cases • Almost every non-trivial system has an extremely large input data domain thereby making exhaustive testing impractical • If randomly selected then test case may loose significance since it may expose an already detected error by some other test case
  • 17. Design of test cases • Number of test cases do not determine the effectiveness • To detect error in following code if(x>y) max = x; else max = x; • {(x=3, y=2); (x=2, y=3)} will suffice • {(x=3, y=2); (x=4, y=3); (x=5, y = 1)} • Each test case should detect different errors
  • 18. White-Box Testing • Statement coverage • Branch coverage • Path coverage • Condition coverage • Data flow-based testing
  • 19. 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
  • 20. Statement coverage criterion • Observing that a statement behaves properly for one input value: – no guarantee that it will behave correctly for all input values.
  • 21. 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; }
  • 22. Euclid's GCD computation algorithm • By choosing the test set {(x=3,y=3),(x=4,y=3), (x=3,y=4)} – all statements are executed at least once.
  • 23. Branch Coverage • Test cases are designed such that: – different branch conditions is given true and false values in turn. • Branch testing guarantees statement coverage: – a stronger testing compared to the statement coverage-based testing.
  • 24. Example • Test cases for branch coverage can be: {(x=3,y=3), (x=4,y=3), (x=3,y=4)}
  • 25. Condition Coverage • Test cases are designed such that: – each component of a composite conditional expression given both true and false values. • Example – Consider the conditional expression ((c1.and.c2).or.c3): – Each of c1, c2, and c3 are exercised at least once i.e. given true and false values.
  • 26. Branch testing • Branch testing is the simplest condition testing strategy • compound conditions appearing in different branch statements are given true and false values. (note: the entire condition is given true and false values, not ALL possible sub expressions)
  • 27. Branch testing • Condition testing – stronger testing than branch testing: • Branch testing – stronger than statement coverage testing.
  • 28. Condition coverage • Consider a Boolean expression having n components: – for condition coverage we require 2n test cases. • practical only if n (the number of component conditions) is small.
  • 29. Path Coverage • Design test cases such that: – all linearly independent paths in the program are executed at least once. • Defined in terms of – control flow graph (CFG) of a program.
  • 30. 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.
  • 31. How 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.
  • 32. 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; }
  • 33. Example Control Flow Graph 1 2 3 4 5 6
  • 34. Path • A path through a program: – A node and edge sequence from the starting node to a terminal node of the control flow graph. – There may be several terminal nodes for program.
  • 35. Independent path • Any path through the program: – introducing at least one new node or one new edge that is not included in any other independent paths. • It may be straight forward to identify linearly independent paths of simple programs. However For complicated programs it is not so easy to determine the number of independent paths.
  • 36. McCabe's cyclomatic metric • An upper bound: – for the number of linearly independent paths of a program • Provides a practical way of determining: – the maximum number of linearly independent paths in a program.
  • 37. McCabe's cyclomatic metric • Given a control flow graph G, cyclomatic complexity V(G): – V(G)= E-N+2 • N is the number of nodes in G • E is the number of edges in G
  • 38. Example • Cyclomatic complexity = 7 – 6 + 2 = 3.
  • 39. Cyclomatic complexity • The cyclomatic complexity of a program provides: – a lower bound on the number of test cases to be designed to get coverage of all linearly independent paths. – only gives an indication of the minimum number of test cases required.
  • 40. Path Testing - Test Cases • Draw control flow graph. (Loops can cause an explosion in the number of independent paths, so use looping values of 0 and 1 to test loops). • Determine V(G). • Determine the set of linearly independent paths. • Prepare test cases: – to force execution along each path
  • 41. Example Control Flow Graph 1 2 3 4 5 6
  • 42. Derivation of Test Cases • Number of independent paths: 4 – 1, 6 test case (x=1, y=1) – 1, 2, 3, 5, 1, 6 test case(x=1, y=2) – 1, 2, 4, 5, 1, 6 test case(x=2, y=1)
  • 43. An interesting application of cyclomatic complexity • Relationship exists between: – McCabe's metric – the number of errors existing in the code, – the time required to find and correct the errors.
  • 44. Cyclomatic complexity • Cyclomatic complexity of a program: – also indicates the psychological complexity of a program. – difficulty level of understanding the program.
  • 45. Cyclomatic complexity • From maintenance perspective, – limit cyclomatic complexity • of modules to some reasonable value. – Some software development organizations: • restrict cyclomatic complexity of functions to some max number.
  • 46. Data-flow-based Testing • Basic idea: test the connections between variable definitions (“write”) and variable uses (“read”) • Starting point: variation of the control flow graph – Each node represents a single statement, not a chain of statements • Set DEF(n) contains variables that are defined at node n (i.e., they are written) • Set USE(n): variables that are read
  • 47. Example Assume y is already initialized 1 s:= 0; 2 x:= 0; 3 while (x<y) { 4 x:=x+3; 5 y:=y+2; 6 if (x+y<10) 7 s:=s+x+y; else 8 s:=s+x-y; 1 2 3 DEF(1) := {s}, USE(1) := DEF(2) := {x}, USE(2) := DEF(3) := , USE(3) := {x,y} DEF(4) := {x}, USE(4) := {x} DEF(5) := {y}, USE(5) := {y} DEF(6) := , USE(6) := {x,y} DEF(7) := {s}, USE(7) := {s,x,y} DEF(8) := {s}, USE(8) := {s,x,y} DEF(9) := , USE(9) := DEF(10) := , USE(10) := 4 5 6 7 8 9 10
  • 48. Reaching Definitions A definition of variable x at node n1 reaches node n2 if and only if there is a path between n1 and n2 that does not contain a definition of x 1 2 3 DEF(1) := {s}, USE(1) := DEF(2) := {x}, USE(2) := DEF(3) := , USE(3) := {x,y} DEF(4) := {x}, USE(4) := {x} DEF(5) := {y}, USE(5) := {y} DEF(6) := , USE(6) := {x,y} DEF(7) := {s}, USE(7) := {s,x,y} DEF(8) := {s}, USE(8) := {s,x,y} 4 5 6 7 8 9 10 Reaches nodes 2,3,4,5,6,7,8, but not 9 and 10.
  • 49. Def-use Pairs • A def-use pair (DU) for variable x is a pair of nodes (n1,n2) such that – x is in DEF(n1) – The definition of x at n1 reaches n2 – x is in USE(n2) • In other words, the value that is assigned to x at n1 is used at n2 – Since the definition reaches n2, the value is not killed along some path n1...n2.
  • 50. Examples of Def-Use Pairs 1 2 3 DEF(1) := {s}, USE(1) := DEF(2) := {x}, USE(2) := DEF(3) := , USE(3) := {x,y} DEF(4) := {x}, USE(4) := {x} DEF(5) := {y}, USE(5) := {y} DEF(6) := , USE(6) := {x,y} DEF(7) := {s}, USE(7) := {s,x,y} DEF(8) := {s}, USE(8) := {s,x,y} 4 5 6 7 8 9 10 Reaches nodes 2, 3, 4, 5, 6, 7, 8, but not 9,10 For this definition, two DU pairs: 1-7, 1-8
  • 51. Data-flow-based Testing • Identify all DU pairs and construct test cases that cover these pairs – Several variations with different “relative strength” • All-DU-paths: For each DU pair (n1,n2) for x, exercise all possible paths n1, n2 that are clear of a definition of x • All-uses: for each DU pair (n1,n2) for x, exercise at least one path n1 n2 that is clear of definitions of x
  • 52. Data-flow-based Testing • All-definitions: for each definition, cover at least one DU pair for that definition – i.e., if x is defined at n1, execute at least one path n1..n2 such that x is in USE(n2) and the path is clear of definitions of x • Clearly, all-definitions is subsumed by all-uses which is subsumed by all-DU-paths • Motivation: see the effects of using the values produced by computations – Focuses on the data, while control-flow-based testing focuses on the control