ST Mod3 Chapter10 DataflowTesting Part1
ST Mod3 Chapter10 DataflowTesting Part1
2
Introduction
• Dataflow testing refers to forms of structural testing.
3
• Many times, their analyses were based on
concordances(alphabetical list of the words present in a text )
that list statement numbers in which variable names occur.
• Definitions:
• Node n G (P ) is a defining node of the variable v V , written as
DEF(v, n), iff the value of the variable v is defined at the
statement fragment corresponding to node n.
– E.g. Input statements, assignment statements, loop control
statements, and procedure calls
– When the code corresponding to such statements executes,
the contents of memory location associated with the
variables are changed.
5
• Node n G (P ) is a usage node of the variable v V , written as
USE(v, n), iff the value of the variable v is used at the statement
fragment corresponding to node n.
– E.g. Output statements, assignment statements, conditional
statements, loop control statements, and procedure calls
– When the code corresponding to such statements executes,
the contents of memory location associated with the
variables remain unchanged.
6
• A definition-use path with respect to a variable v (denoted
as du-path) is a path in PATHS(P), such that, for somev V ,
there are define and usage nodes DEF(v, m) and USE(v, n)
such that m, and n are the initial and final nodes in the path
respectively.
7
• An outline of data-flow testing is as follows:
– Draw a data flow graph for the program
– Select data-flow testing criteria
– Identify paths in the data-flow graph to satisfy the
selection criteria (i.e. all-defs, all-uses, all-P-uses/some-C-
uses etc.)
– Produce test cases for the selected paths
8
1.Program Commission (INPUT,OUTPUT)
`
2.Dim locks,stocks,barrels As Integer
3.Dim lockPrice,stockPrice,barrelPrice As Real
4.Dim totalLocks,totalStocks,totalBarrels As Integer
5.Dim lockSales,stockSales,barrelSales As Real
6.Dim sales,commission:REAL
`
7.lockPrice=45.0
8.stockPrice=30.0
9.barrelPrice=25.0
10.totalLocks=0
11.totalStocks=0
12.totalBarrels=0
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 9
21.Output(“Locks sold”,totalLocks)
22.Output(“Stocks sold”,totalStocks)
23.Output(“Barrels sold”,totalBarrels)
`
24.lockSales=lockPrice*totalLocks
25.stockSales=stockPrice*totalStocks
26.barrelSales=barrelPrice*totalBarrels
27.sales=lockSales+stockSales+barrelSales
28.Output(“Total sales”,sales)
`
29.If (sales > 1800.0)
30.Then
31.Commission=0.10*1000.0
32.Commission=commission+0.15*800.0
33.Commission=commission+0.20*(sales-1800.0)
34.Else If(sales > 1000.0)
35.Then
36.Commission=0.10*1000.0
37.Commission=commission+0.15*(sales-1000.0)
38.Else
39.commission=0.10*sales
40.EndIf
41.EndIf
42.Output (“Commission is $”,commission)
`
43.End Commission 10
11
12