SlideShare a Scribd company logo
Code Coverage
Venkatesh-Prasad Ranganath
Kansas State University
A Program & its CFG
s0: z = input()
s1: x = input()
s2: if x > 5:
s3: y = x * 5
else:
s4: y = z / 5
s5: print(y)
s6: return
CFG is short for Control Flow Graph
s0
s1
s2
s4s3
s5
s6
Each node is a
statement
Each solid edge is
control flow edge
between two
statements
Node and Edge Coverage*
• Node (Statement) Coverage
• Fraction of graph nodes covered by tests
• Testing Goal: Every node should be executed at
least once
• (Control Flow) Edge Coverage
• Fraction of graph edges covered by tests
• Testing Goal: Every edge should be executed at
least once
• Path is a sequence of nodes in a graph
such that consecutive nodes in the path
are connected by a edge in the graph
• (Control Flow) Path Coverage
• Fraction of graph paths covered by tests
• How can we deal with programs with
loops, i.e. graphs with infinite number of
paths?
t0
t1
t2
t3
(Control Flow) Path Coverage*
• (Control Flow) Path Coverage — Testing Goal
• Every path between every pair of nodes should be
executed (may lead to redundancy)
• Every path between source and sinks should be
executed.
• Ideal for programs without loops
• Sufficient number of paths between source and sink
nodes are executed such that all edges are executed
• Every finite path between source and sinks should
executed such that each loop is executed at least
once (when all paths are considered)
• Good enough for programs with loops
(Control Flow) Path Coverage*
• (Control Flow) Path Coverage
• What about programs without sinks?
• Every finite path between source and
every node is executed with each
loop executed at least once (when all
paths are considered)
• What about infeasible paths?
(Control Flow) Path Coverage*
t0
t1
t2
t3
A Program & its DFG
s0: z = input()
s1: x = input()
s2: if x > 5:
s3: y = x * 5
else:
s4: y = z / 5
s5: print(y)
s6: return
DFG is short for Data Flow Graph
Each node is a
statement
Each solid edge is
the control flow
between two
statements
Each dashed edge is
the data flow between
two statements (from
definition of a variable
to its use)
s0
s1
s2
s4s3
s5
s6
z
x
x
y
y
Data Flow Coverage*
• Fraction of def-use edges covered by tests
• Testing Goal: Every def-use edge should be
executed at least once
• How well will this work in case of programs with
pointers and references?
• Can we detect all def-use edges?
• What about infeasible def-use edges?
• What about in case of programs written in OO
languages?
Which is better?
With 2 (red) paths, we get 100% node
and edge coverage but miss exercising
s2-s6 data flow edge
s1
s3s2
s4
s6s5
s7
Which is better?
With 2 (red) paths, we get 100%
node and edge coverage but miss
exercising s3-s6 data flow edge
s1
s3s2
s4
s6s5
s7
Which is better?
With 2 (red) paths, we get 100% data
flow coverage (s2-s6 and s3-s6) but
miss exercising s5 node
s1
s3s2
s4
s6s5
s7
Which is better?
s1
s3s2
s4
s6s5
s7
With 4 (red) paths, we get 100%
node, edge, and data flow coverage
but with some redundancy
Which is better?
s1
s3s2
s4
s6s5
s7
With 3 (red) paths, we get 100%
node, edge, and data flow coverage
but with lesser redundancy
Branch Coverage*
• Fraction of branches (edges) covered by tests
• Testing Goal: Every branch should be executed at
least once
• How does this relate to node and edge coverage?
Boolean Expressions
x > 0
x > 0 y < 0
and z > 10
or
x > 0 x > 0 and y < 0 or z > 10
Simple boolean
expressions contain no
logical connectives
Compound boolean
expressions contain
logical connectives
Condition Coverage*
• Fraction of boolean expression valuations covered
by tests
• Testing Goal:
• Every simple boolean expression should be
evaluated to both true and false
• Every compound boolean expression should be
evaluated to both true and false
Condition Coverage
• What about coupling between sub-expressions of a
compound expression?
• (x>0	and	y)	or	(x<=0	and	z)
• What about masking between sub-expressions of a
compound expression?
• (x>100	and	y) where x ranges from 0 to 100

More Related Content

What's hot

Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Waqas Afzal
 
Block diagrams
Block diagramsBlock diagrams
Block diagrams
Kali Appan
 
Csl8 2 f15
Csl8 2 f15Csl8 2 f15
Csl8 2 f15
kodam2512
 
Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...
Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...
Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...
AboutYouGmbH
 
Signal flow graph
Signal flow graphSignal flow graph
Signal flow graph
Chandresh Suthar
 
Control system concepts by using matlab
Control system concepts by using matlabControl system concepts by using matlab
Control system concepts by using matlab
CharltonInao1
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problem
Ifra Ilyas
 
Assignment of pseudo code
Assignment of pseudo codeAssignment of pseudo code
Assignment of pseudo code
Burhan Chaudhry
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysis
Anindita Kundu
 
Biconnected components (13024116056)
Biconnected components (13024116056)Biconnected components (13024116056)
Biconnected components (13024116056)
Akshay soni
 
Signal Flow Graph Introduction
Signal Flow Graph IntroductionSignal Flow Graph Introduction
Signal Flow Graph Introduction
priyankabirlaa
 
Nikit
NikitNikit
Some other Importent Question (Mix)
Some other Importent Question (Mix)Some other Importent Question (Mix)
Some other Importent Question (Mix)
prabhatjon
 
signal flow graph
signal flow graphsignal flow graph
signal flow graph
Rajput Manthan
 
SFG and Mason's Gain Formula
SFG and Mason's Gain FormulaSFG and Mason's Gain Formula
SFG and Mason's Gain Formula
priyankabirlaa
 
Control chap3
Control chap3Control chap3
Control chap3
Mohd Ashraf Shabarshah
 
R time series analysis
R   time series analysisR   time series analysis
R time series analysis
Learnbay Datascience
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
Subrata Kumer Paul
 
Some question for Section C (Embeded )
Some question for Section C (Embeded )Some question for Section C (Embeded )
Some question for Section C (Embeded )
prabhatjon
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
meisamstar
 

What's hot (20)

Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
 
Block diagrams
Block diagramsBlock diagrams
Block diagrams
 
Csl8 2 f15
Csl8 2 f15Csl8 2 f15
Csl8 2 f15
 
Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...
Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...
Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...
 
Signal flow graph
Signal flow graphSignal flow graph
Signal flow graph
 
Control system concepts by using matlab
Control system concepts by using matlabControl system concepts by using matlab
Control system concepts by using matlab
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problem
 
Assignment of pseudo code
Assignment of pseudo codeAssignment of pseudo code
Assignment of pseudo code
 
asymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysisasymptotic analysis and insertion sort analysis
asymptotic analysis and insertion sort analysis
 
Biconnected components (13024116056)
Biconnected components (13024116056)Biconnected components (13024116056)
Biconnected components (13024116056)
 
Signal Flow Graph Introduction
Signal Flow Graph IntroductionSignal Flow Graph Introduction
Signal Flow Graph Introduction
 
Nikit
NikitNikit
Nikit
 
Some other Importent Question (Mix)
Some other Importent Question (Mix)Some other Importent Question (Mix)
Some other Importent Question (Mix)
 
signal flow graph
signal flow graphsignal flow graph
signal flow graph
 
SFG and Mason's Gain Formula
SFG and Mason's Gain FormulaSFG and Mason's Gain Formula
SFG and Mason's Gain Formula
 
Control chap3
Control chap3Control chap3
Control chap3
 
R time series analysis
R   time series analysisR   time series analysis
R time series analysis
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
 
Some question for Section C (Embeded )
Some question for Section C (Embeded )Some question for Section C (Embeded )
Some question for Section C (Embeded )
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
 

Similar to Code Coverage [9] - Software Testing Techniques (CIS640)

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
Pankaj Thakur
 
7-White Box Testing.ppt
7-White Box Testing.ppt7-White Box Testing.ppt
7-White Box Testing.ppt
HirenderPal
 
Slicing of Object-Oriented Programs
Slicing of Object-Oriented ProgramsSlicing of Object-Oriented Programs
Slicing of Object-Oriented Programs
Praveen Penumathsa
 
Bp150513(compiler)
Bp150513(compiler)Bp150513(compiler)
Bp150513(compiler)
indhu mathi
 
Rseminarp
RseminarpRseminarp
Slicing of Object-Oriented Programs
Slicing of Object-Oriented ProgramsSlicing of Object-Oriented Programs
Slicing of Object-Oriented Programs
Praveen Penumathsa
 
Queuing theory and traffic analysis in depth
Queuing theory and traffic analysis in depthQueuing theory and traffic analysis in depth
Queuing theory and traffic analysis in depth
IdcIdk1
 
White box testing
White box testingWhite box testing
White box testing
Purvi Sankhe
 
7 convolutional codes
7 convolutional codes7 convolutional codes
7 convolutional codes
Varun Raj
 
Data structures assignmentweek4b.pdfCI583 Data Structure
Data structures assignmentweek4b.pdfCI583 Data StructureData structures assignmentweek4b.pdfCI583 Data Structure
Data structures assignmentweek4b.pdfCI583 Data Structure
OllieShoresna
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniques
Fincy V.J
 
Generalized Linear Models in Spark MLlib and SparkR by Xiangrui Meng
Generalized Linear Models in Spark MLlib and SparkR by Xiangrui MengGeneralized Linear Models in Spark MLlib and SparkR by Xiangrui Meng
Generalized Linear Models in Spark MLlib and SparkR by Xiangrui Meng
Spark Summit
 
Generalized Linear Models in Spark MLlib and SparkR
Generalized Linear Models in Spark MLlib and SparkRGeneralized Linear Models in Spark MLlib and SparkR
Generalized Linear Models in Spark MLlib and SparkR
Databricks
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
Eelco Visser
 
Modeling and Querying Metadata in the Semantic Sensor Web: stRDF and stSPARQL
Modeling and Querying Metadata in the Semantic Sensor Web: stRDF and stSPARQLModeling and Querying Metadata in the Semantic Sensor Web: stRDF and stSPARQL
Modeling and Querying Metadata in the Semantic Sensor Web: stRDF and stSPARQL
Kostis Kyzirakos
 
Path testing, data flow testing
Path testing, data flow testingPath testing, data flow testing
Path testing, data flow testing
priyasoundar
 
Types of routing Protocols in Computer Networks
Types of routing Protocols in Computer NetworksTypes of routing Protocols in Computer Networks
Types of routing Protocols in Computer Networks
samarahmadf21
 
OFDM
OFDMOFDM
Path based Algorithms(Term Paper)
Path based Algorithms(Term Paper)Path based Algorithms(Term Paper)
Path based Algorithms(Term Paper)
pankaj kumar
 
11 whiteboxtesting
11 whiteboxtesting11 whiteboxtesting
11 whiteboxtesting
asifusman1998
 

Similar to Code Coverage [9] - Software Testing Techniques (CIS640) (20)

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
 
7-White Box Testing.ppt
7-White Box Testing.ppt7-White Box Testing.ppt
7-White Box Testing.ppt
 
Slicing of Object-Oriented Programs
Slicing of Object-Oriented ProgramsSlicing of Object-Oriented Programs
Slicing of Object-Oriented Programs
 
Bp150513(compiler)
Bp150513(compiler)Bp150513(compiler)
Bp150513(compiler)
 
Rseminarp
RseminarpRseminarp
Rseminarp
 
Slicing of Object-Oriented Programs
Slicing of Object-Oriented ProgramsSlicing of Object-Oriented Programs
Slicing of Object-Oriented Programs
 
Queuing theory and traffic analysis in depth
Queuing theory and traffic analysis in depthQueuing theory and traffic analysis in depth
Queuing theory and traffic analysis in depth
 
White box testing
White box testingWhite box testing
White box testing
 
7 convolutional codes
7 convolutional codes7 convolutional codes
7 convolutional codes
 
Data structures assignmentweek4b.pdfCI583 Data Structure
Data structures assignmentweek4b.pdfCI583 Data StructureData structures assignmentweek4b.pdfCI583 Data Structure
Data structures assignmentweek4b.pdfCI583 Data Structure
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniques
 
Generalized Linear Models in Spark MLlib and SparkR by Xiangrui Meng
Generalized Linear Models in Spark MLlib and SparkR by Xiangrui MengGeneralized Linear Models in Spark MLlib and SparkR by Xiangrui Meng
Generalized Linear Models in Spark MLlib and SparkR by Xiangrui Meng
 
Generalized Linear Models in Spark MLlib and SparkR
Generalized Linear Models in Spark MLlib and SparkRGeneralized Linear Models in Spark MLlib and SparkR
Generalized Linear Models in Spark MLlib and SparkR
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
 
Modeling and Querying Metadata in the Semantic Sensor Web: stRDF and stSPARQL
Modeling and Querying Metadata in the Semantic Sensor Web: stRDF and stSPARQLModeling and Querying Metadata in the Semantic Sensor Web: stRDF and stSPARQL
Modeling and Querying Metadata in the Semantic Sensor Web: stRDF and stSPARQL
 
Path testing, data flow testing
Path testing, data flow testingPath testing, data flow testing
Path testing, data flow testing
 
Types of routing Protocols in Computer Networks
Types of routing Protocols in Computer NetworksTypes of routing Protocols in Computer Networks
Types of routing Protocols in Computer Networks
 
OFDM
OFDMOFDM
OFDM
 
Path based Algorithms(Term Paper)
Path based Algorithms(Term Paper)Path based Algorithms(Term Paper)
Path based Algorithms(Term Paper)
 
11 whiteboxtesting
11 whiteboxtesting11 whiteboxtesting
11 whiteboxtesting
 

More from Venkatesh Prasad Ranganath

SeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android AppsSeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android Apps
Venkatesh Prasad Ranganath
 
Are free Android app security analysis tools effective in detecting known vul...
Are free Android app security analysis tools effective in detecting known vul...Are free Android app security analysis tools effective in detecting known vul...
Are free Android app security analysis tools effective in detecting known vul...
Venkatesh Prasad Ranganath
 
Benchpress: Analyzing Android App Vulnerability Benchmark Suites
Benchpress:  Analyzing Android App Vulnerability Benchmark SuitesBenchpress:  Analyzing Android App Vulnerability Benchmark Suites
Benchpress: Analyzing Android App Vulnerability Benchmark Suites
Venkatesh Prasad Ranganath
 
Why do Users kill HPC Jobs?
Why do Users kill HPC Jobs?Why do Users kill HPC Jobs?
Why do Users kill HPC Jobs?
Venkatesh Prasad Ranganath
 
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Venkatesh Prasad Ranganath
 
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Venkatesh Prasad Ranganath
 
Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Boundary Value Testing [7] - Software Testing Techniques (CIS640)Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Venkatesh Prasad Ranganath
 
Property Based Testing [5] - Software Testing Techniques (CIS640)
Property Based Testing [5] - Software Testing Techniques (CIS640)Property Based Testing [5] - Software Testing Techniques (CIS640)
Property Based Testing [5] - Software Testing Techniques (CIS640)
Venkatesh Prasad Ranganath
 
Intro to Python3 [2] - Software Testing Techniques (CIS640)
Intro to Python3 [2] - Software Testing Techniques (CIS640)Intro to Python3 [2] - Software Testing Techniques (CIS640)
Intro to Python3 [2] - Software Testing Techniques (CIS640)
Venkatesh Prasad Ranganath
 
Unit testing [4] - Software Testing Techniques (CIS640)
Unit testing [4] - Software Testing Techniques (CIS640)Unit testing [4] - Software Testing Techniques (CIS640)
Unit testing [4] - Software Testing Techniques (CIS640)
Venkatesh Prasad Ranganath
 
Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)
Venkatesh Prasad Ranganath
 
Introduction [1] - Software Testing Techniques (CIS640)
Introduction [1] - Software Testing Techniques (CIS640)Introduction [1] - Software Testing Techniques (CIS640)
Introduction [1] - Software Testing Techniques (CIS640)
Venkatesh Prasad Ranganath
 
Compatibility Testing using Patterns-based Trace Comparison
Compatibility Testing using Patterns-based Trace ComparisonCompatibility Testing using Patterns-based Trace Comparison
Compatibility Testing using Patterns-based Trace Comparison
Venkatesh Prasad Ranganath
 
My flings with data analysis
My flings with data analysisMy flings with data analysis
My flings with data analysis
Venkatesh Prasad Ranganath
 
Data analytics, a (short) tour
Data analytics, a (short) tourData analytics, a (short) tour
Data analytics, a (short) tour
Venkatesh Prasad Ranganath
 
R language, an introduction
R language, an introductionR language, an introduction
R language, an introduction
Venkatesh Prasad Ranganath
 
Pattern-based Features
Pattern-based FeaturesPattern-based Features
Pattern-based Features
Venkatesh Prasad Ranganath
 

More from Venkatesh Prasad Ranganath (17)

SeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android AppsSeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android Apps
 
Are free Android app security analysis tools effective in detecting known vul...
Are free Android app security analysis tools effective in detecting known vul...Are free Android app security analysis tools effective in detecting known vul...
Are free Android app security analysis tools effective in detecting known vul...
 
Benchpress: Analyzing Android App Vulnerability Benchmark Suites
Benchpress:  Analyzing Android App Vulnerability Benchmark SuitesBenchpress:  Analyzing Android App Vulnerability Benchmark Suites
Benchpress: Analyzing Android App Vulnerability Benchmark Suites
 
Why do Users kill HPC Jobs?
Why do Users kill HPC Jobs?Why do Users kill HPC Jobs?
Why do Users kill HPC Jobs?
 
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
 
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
 
Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Boundary Value Testing [7] - Software Testing Techniques (CIS640)Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Boundary Value Testing [7] - Software Testing Techniques (CIS640)
 
Property Based Testing [5] - Software Testing Techniques (CIS640)
Property Based Testing [5] - Software Testing Techniques (CIS640)Property Based Testing [5] - Software Testing Techniques (CIS640)
Property Based Testing [5] - Software Testing Techniques (CIS640)
 
Intro to Python3 [2] - Software Testing Techniques (CIS640)
Intro to Python3 [2] - Software Testing Techniques (CIS640)Intro to Python3 [2] - Software Testing Techniques (CIS640)
Intro to Python3 [2] - Software Testing Techniques (CIS640)
 
Unit testing [4] - Software Testing Techniques (CIS640)
Unit testing [4] - Software Testing Techniques (CIS640)Unit testing [4] - Software Testing Techniques (CIS640)
Unit testing [4] - Software Testing Techniques (CIS640)
 
Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)
 
Introduction [1] - Software Testing Techniques (CIS640)
Introduction [1] - Software Testing Techniques (CIS640)Introduction [1] - Software Testing Techniques (CIS640)
Introduction [1] - Software Testing Techniques (CIS640)
 
Compatibility Testing using Patterns-based Trace Comparison
Compatibility Testing using Patterns-based Trace ComparisonCompatibility Testing using Patterns-based Trace Comparison
Compatibility Testing using Patterns-based Trace Comparison
 
My flings with data analysis
My flings with data analysisMy flings with data analysis
My flings with data analysis
 
Data analytics, a (short) tour
Data analytics, a (short) tourData analytics, a (short) tour
Data analytics, a (short) tour
 
R language, an introduction
R language, an introductionR language, an introduction
R language, an introduction
 
Pattern-based Features
Pattern-based FeaturesPattern-based Features
Pattern-based Features
 

Recently uploaded

World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 

Code Coverage [9] - Software Testing Techniques (CIS640)

  • 2. A Program & its CFG s0: z = input() s1: x = input() s2: if x > 5: s3: y = x * 5 else: s4: y = z / 5 s5: print(y) s6: return CFG is short for Control Flow Graph s0 s1 s2 s4s3 s5 s6 Each node is a statement Each solid edge is control flow edge between two statements
  • 3. Node and Edge Coverage* • Node (Statement) Coverage • Fraction of graph nodes covered by tests • Testing Goal: Every node should be executed at least once • (Control Flow) Edge Coverage • Fraction of graph edges covered by tests • Testing Goal: Every edge should be executed at least once
  • 4. • Path is a sequence of nodes in a graph such that consecutive nodes in the path are connected by a edge in the graph • (Control Flow) Path Coverage • Fraction of graph paths covered by tests • How can we deal with programs with loops, i.e. graphs with infinite number of paths? t0 t1 t2 t3 (Control Flow) Path Coverage*
  • 5. • (Control Flow) Path Coverage — Testing Goal • Every path between every pair of nodes should be executed (may lead to redundancy) • Every path between source and sinks should be executed. • Ideal for programs without loops • Sufficient number of paths between source and sink nodes are executed such that all edges are executed • Every finite path between source and sinks should executed such that each loop is executed at least once (when all paths are considered) • Good enough for programs with loops (Control Flow) Path Coverage*
  • 6. • (Control Flow) Path Coverage • What about programs without sinks? • Every finite path between source and every node is executed with each loop executed at least once (when all paths are considered) • What about infeasible paths? (Control Flow) Path Coverage* t0 t1 t2 t3
  • 7. A Program & its DFG s0: z = input() s1: x = input() s2: if x > 5: s3: y = x * 5 else: s4: y = z / 5 s5: print(y) s6: return DFG is short for Data Flow Graph Each node is a statement Each solid edge is the control flow between two statements Each dashed edge is the data flow between two statements (from definition of a variable to its use) s0 s1 s2 s4s3 s5 s6 z x x y y
  • 8. Data Flow Coverage* • Fraction of def-use edges covered by tests • Testing Goal: Every def-use edge should be executed at least once • How well will this work in case of programs with pointers and references? • Can we detect all def-use edges? • What about infeasible def-use edges? • What about in case of programs written in OO languages?
  • 9. Which is better? With 2 (red) paths, we get 100% node and edge coverage but miss exercising s2-s6 data flow edge s1 s3s2 s4 s6s5 s7
  • 10. Which is better? With 2 (red) paths, we get 100% node and edge coverage but miss exercising s3-s6 data flow edge s1 s3s2 s4 s6s5 s7
  • 11. Which is better? With 2 (red) paths, we get 100% data flow coverage (s2-s6 and s3-s6) but miss exercising s5 node s1 s3s2 s4 s6s5 s7
  • 12. Which is better? s1 s3s2 s4 s6s5 s7 With 4 (red) paths, we get 100% node, edge, and data flow coverage but with some redundancy
  • 13. Which is better? s1 s3s2 s4 s6s5 s7 With 3 (red) paths, we get 100% node, edge, and data flow coverage but with lesser redundancy
  • 14. Branch Coverage* • Fraction of branches (edges) covered by tests • Testing Goal: Every branch should be executed at least once • How does this relate to node and edge coverage?
  • 15. Boolean Expressions x > 0 x > 0 y < 0 and z > 10 or x > 0 x > 0 and y < 0 or z > 10 Simple boolean expressions contain no logical connectives Compound boolean expressions contain logical connectives
  • 16. Condition Coverage* • Fraction of boolean expression valuations covered by tests • Testing Goal: • Every simple boolean expression should be evaluated to both true and false • Every compound boolean expression should be evaluated to both true and false
  • 17. Condition Coverage • What about coupling between sub-expressions of a compound expression? • (x>0 and y) or (x<=0 and z) • What about masking between sub-expressions of a compound expression? • (x>100 and y) where x ranges from 0 to 100