Home Basic SDP Test Case Web Testing FAQ Others
You are here: Home>>Test Plan & Test Case>> Test Case Design - Page 2

Sample Test Plan

you are hereQA Test Case Design


We need your help! To keep the site alive, please make the donation by clicking the button below.
Thank you very much!

How to Make a Donation Using PayPal Without an Account?
Pages: Prev 1 2 3 4 5 6 7 8 9 10 11 12 Next

Software Test Case Design

Software Testing - Software Test Case Design - Page 2

Logic Coverage testing

White-box testing is concerned with the degree to which test cases exercise or cover the logic (source code) of the program. The ultimate white-box test is the execution of every path in the program, but complete path testing is not a realistic goal for a program with loops.

If you back completely away from path testing, it may seem that a worthy goal would be to execute every statement in the program at least once. Unfortunately, this is a weak criterion for a reasonable white-box test. This concept is illustrated in Figure 1. Assume that Figure 4.1 represents a small program to be tested. The equivalent Java code snippet follows:

  public void foo(int a, int b, int x) {
  if (a>1 && b==0) {x=x/a;}
  if (a==2 || x>1) {x=x+1;}}

You could execute every statement by writing a single test case that traverses path ace. That is, by setting A=2, B=0, and X=3 at point a, every statement would be executed once (actually, X could be assigned any value).

Unfortunately, this criterion is a rather poor one. For instance, perhaps the first decision should be an or rather than an and. If so, this error would go undetected. Perhaps the second decision should have stated X>0; this error would not be detected. Also, there is a path through the program in which X goes unchanged (the path abd). If this were an error, it would go undetected. In other words, the statementcoverage criterion is so weak that it generally is useless.

A stronger logic-coverage criterion is known as decision coverage or branch coverage. This criterion states that you must write enough test cases that each decision has a true and a false outcome at least once. In other words, each branch direction must be traversed at least once. Examples of branch or decision statements are switch, do-while, and if-else statements. Multiway GOTO statements qualify in some programming languages such as FORTRAN.

Decision coverage usually can satisfy statement coverage. Since every statement is on some subpath emanating either from a branch statement or from the entry point of the program, every statement must be executed if every branch direction is executed. However, there are at least three exceptions:

  • Programs with no decisions.
  • Programs or subroutines/methods with multiple entry points. A given statement might be executed only if the program is entered at a particular entry point.
  • Statements within ON-units. Traversing every branch direction will not necessarily cause all ON-units to be executed.

 

Page 2


Pages: Prev 1 2 3 4 5 6 7 8 9 10 11 12 Next