Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 8 Data-Flow Testing.

Similar presentations


Presentation on theme: "Lab 8 Data-Flow Testing."— Presentation transcript:

1 Lab 8 Data-Flow Testing

2 Data-Flow Testing Data-flow testing uses the control flowgraph to explore the unreasonable things that can happen to data (i.e. anomalies). Consideration of data-flow anomalies leads to test path selection strategies that fill the gaps between complete path testing and branch or statement testing. Data-flow testing is the name given to a family of test strategies based on selecting paths through the program’s control flow in order to explore sequences of events related to the status of data objects. E.g., Pick enough paths to assure that: – Every data object has been initialized prior to its use. – All defined objects have been used at least once.

3 Data Object Categories
(d) Defined, Created, Initialized (k) Killed, Undefined, Released (u) Used: – (c) Used in a calculation – (p) Used in a predicate

4 (d) Defined Objects An object (e.g., variable) is defined when it:
– appears in a data declaration – is assigned a new value – is a file that has been opened – is dynamically allocated

5 (u) Used Objects An object is used when it is part of a computation or a predicate. A variable is used for a computation (c) when it appears on the RHS (sometimes even the LHS in case of array indices) of an assignment statement. A variable is used in a predicate (p) when it appears directly in that predicate.

6 Example: Definition and Uses
What are the definitions and uses for the program below? 1. read (x, y); 2. z = x + 2; 3. if (z < y) w = x + 1; else y = y + 1; 6. print (x, y, w, z);

7 Example: Definition and Uses

8

9

10

11

12

13 du Path Segments A du Path is a path segment such that if the last link has a use of X, then the path is simple and definition clear.

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30 Example Staff Discount Program The following program is used in a hypothetical retail situation. The owner of a shop has decided that her staff can have a 10 percent discount on all their purchases. If they spend more than £15, then the total discount is in-creased by 50 pence. The price of each item being purchased is input into the program. When -1 is entered, the total price is displayed, as well as the calculated discount and the final price to pay. For example, the values £5.50, £2.00 and £2.50 are input, equalling £ The total discount would equal £1.00 (10% of £10.00), with the total price to pay equalling £9.00. A second example would have purchases of £10.50 and £5.00, equaling £ In this case, as the total value is over £15, the discount would be £2.05 (10% of £15.50 is £1.55, plus 50p as the original total is over £15), meaning that the total price to pay would be £ The source code, written in pseudocode, for a program which has been written to perform the task described above, is shown below:

31 Example (conti)

32

33 Define/use Testing

34 With these nodes, some useful paths can be generated.
Definition-use (du) paths: A path in the set of all paths in P(G) is a du-path for some variable v (in the set V of all variables in the program) if and only if there exist DEF(v, m) and USE(v, n) nodes such that m is the first node of the path, and n is the last node.

35

36 Definition-clear (dc) paths:
A path in the set of all paths in P(G) is a dc-path for some variable v (in the set V of all variables in the program) if and only if it is a du-path and the initial node of the path is the only defining node of v in the path.

37


Download ppt "Lab 8 Data-Flow Testing."

Similar presentations


Ads by Google