Docsity

CSE 565 Course Notes: Random and Partition Testing in Software Engineering - Prof. Wei-Tek, Study notes of Computer Science

Toggle sidebar
bg1
CSE 565 Course Notes 9/10/03
9/10/03 – Random and Partition Testing
Path Testing Review [1,2] – A method of testing all or selected paths of a computer
program. A path is a unique sequence of branches from program entry to exit (in other
words a trace through an execution of the program). Basis path testing is testing of
unique paths with no loops. Loops introduce complexity in path testing as they have an
unbounded amount of paths. A possible means to handle loops are boundary-interior
path testing which considers zero and more than zero iteration possibilities.
Data Flow Testing Review [1,2] – Stemming from Data flow analysis, data flow
testing tests the use of variables along different paths of a program execution. Unlike path
flow testing which is primarily based on the control flow, data flow testing is based on
the content flow. It is a variation on path testing that considers only the sub-paths from
variable assignments to when they are referenced. Two common types of data flow
errors picked up by data flow testing are Define-Define (DD) or Use-Define (UD). They
occur because of initialization before declaration, or usage before declaration. Today
compilers do a lot of data flow analysis, but there is still a need for it as new technologies
have new types of data flow bugs. For instance in Object Oriented programming, aspects
such as dynamic binding and circular message calls (figure 1) present new data flow
challenges. However, most of these problems can still be solved via initialization and
parameter checking.
Circular Data Flow Anomaly:
This is in case of OO programming. In this, A receives data from B and passes it to B and
B receives data from A and passes it to A. In this anomaly, you only use the data but you
don’t do any useful work as you are just circulating the data.
A B
Figure 1 - OO Programming:
A New Type of Data Flow Anomaly
Circular Message Call
Without Using the Data
Data Flow Testing in Practice – The main purpose of testing is to discover bugs and
prevent bugs. The former is very expensive hence normally later is preferred. Data flow
bugs can be prevented by initializing variables, checking the validity of input parameters
and checking of output before return result. Generally, data flow testing is rarely used
however, due to its extreme costs and low bug-finding abilities.
[REF: Journal Of Object-Oriented Programming 1994]
http://www.adtmag.com/joop/index.asp
- 1 -
pf3
pf4
pf5

Partial preview of the text

Download CSE 565 Course Notes: Random and Partition Testing in Software Engineering - Prof. Wei-Tek and more Study notes Computer Science in PDF only on Docsity!

9/10/03 – Random and Partition Testing

Path Testing Review [1,2] – A method of testing all or selected paths of a computer

program. A path is a unique sequence of branches from program entry to exit (in other words a trace through an execution of the program). Basis path testing is testing of unique paths with no loops. Loops introduce complexity in path testing as they have an unbounded amount of paths. A possible means to handle loops are boundary-interior path testing which considers zero and more than zero iteration possibilities.

Data Flow Testing Review [1,2] – Stemming from Data flow analysis, data flow

testing tests the use of variables along different paths of a program execution. Unlike path flow testing which is primarily based on the control flow, data flow testing is based on the content flow. It is a variation on path testing that considers only the sub-paths from variable assignments to when they are referenced. Two common types of data flow errors picked up by data flow testing are Define-Define (DD) or Use-Define (UD). They occur because of initialization before declaration, or usage before declaration. Today compilers do a lot of data flow analysis, but there is still a need for it as new technologies have new types of data flow bugs. For instance in Object Oriented programming, aspects such as dynamic binding and circular message calls (figure 1) present new data flow challenges. However, most of these problems can still be solved via initialization and parameter checking. Circular Data Flow Anomaly: This is in case of OO programming. In this, A receives data from B and passes it to B and B receives data from A and passes it to A. In this anomaly, you only use the data but you don’t do any useful work as you are just circulating the data.

A B

Figure 1 - OO Programming: A New Type of Data Flow Anomaly Circular Message Call Without Using the Data Data Flow Testing in Practice – The main purpose of testing is to discover bugs and prevent bugs. The former is very expensive hence normally later is preferred. Data flow bugs can be prevented by initializing variables, checking the validity of input parameters and checking of output before return result. Generally, data flow testing is rarely used however, due to its extreme costs and low bug-finding abilities. [REF: Journal Of Object-Oriented Programming 1994] http://www.adtmag.com/joop/index.asp

Partition Testing [1,3] –

There are three types of partitions  Input partition  Output partition  Failure partition. Partition testing is also known as Domain Testing, the basic idea is to break the input space into several finite non-overlapping regions and selecting the test inputs from each sub-partition and at the boundaries. How do we partition?

  • Proportional partition testing Allocate test cases according to the probability of occurrence each sub domain.
  • Equivalence partition testing Problem partition + path partition For instance: if we have input space below, we break it into the given pieces based on some sort of partitioning heuristic. Note that inputs can be anything (a program, as in case of compilers and interpreters, numbers, etc.). Note that a failure partition is a subset of the input domain that causes failure (the red regions below). Typically, we cannot make any assumptions regarding the failure partitions. Failure partitions do not depend on input or output partition. For the regions created by the partitions, create a set of test cases. Develop test cases covering as many partitions as possible. For each partition that turns out to be invalid, develop additional test cases.

Random Testing [1,3] – Randomly picks points from the input domains. This can be

either input or output domain, but most of the time, input domain. An advantage to random testing is that random input is easy to generate. (Can be automated for some cases). In 1984 a paper was published [J. W. Duran and S.C. Ntafos, "An evaluation of random testing," IEEE Trans. on Software Engineering, SE-10(7):438 444, July 1984] that conducted theoretical experiments and concluded that if you double the test cases than that of partition testing, random testing is about as good as partition testing. There are some arguments against this, first is that it may be easy to generate test input for random testing, but it may not be so easy to create expected output. This is a caveat to watch for. Another more important reason has to do with the mathematics of it: The Probability of finding one failure with double number of test cases with random testing is equal to the probability of finding one failure with partition testing. For example: If a program is very buggy then most any random test cases can find the bugs. Suppose, however, that there are fewer bugs and that they are more intricate. In this instance random testing will probably not find the bugs. When is a program buggy?  At the beginning of inception  After being modified

We should use Random Testing then if  The program is buggy  It is easy to generate expected output for. Otherwise use Partition Testing. Side Note 1 – Elements of Style By William Strunk Jr & EB White. is a good book for increasing ones writing abilities. You can find it online at: http://www.bartleby.com/141/ Side Note 2 – An example of buggy code that is a good candidate for random testing is the sine function defined in The Elements of Programming Style by Brian W. Kernighan, P. J. Plauger. In this book, a negative was left out of the code resulting in a sine wave that did not cross the x-axis (blue and red below). Random Testing (blue dots) would have immediately uncovered this problem. Partition Example: Bank / Checking Account Example Do partition testing. Partition based on domain:  account size  account type  history  occupation (students, faculty, etc)  group of people (golf club)  Input data > 500  Input value <  Account open within one month

References: [1] Tsai, Wei-Tek, Testing Fundamentals. Lecture Notes. Arizona State University Department of Computer Science and Engineering. [2] Cornett, Steve, Code Coverage Analysis. Oct 02 http://www.bullseye.com/webCoverage.html [3] Wu, Ye, Category Partition Testing. Sept. 03 http://www.isse.gmu.edu/~wuye/classes/637/lecture/CategoryPartitionTesting.pdf [4] Gutjahr. Walter J. Partition Testing vs. Random Testing: The Influence of Uncertainty. IEEE Transactions on Software Engineering. September/October 1999 (Vol. 25, No. 5), pg 661-674.