Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

Software Testing Lecturer Notes Unit2: Functional Testing

Acharya Institute of Technology


Bangalore-107

Lecture Notes

Name of the Faculty:Chayapathi A R

Title of the Subject / Subject Code: Software Testing/17IS63

Academic Year / Semester: 2019-20

Name of the Department: Information Science & Engineering

UNIT2

Functional Testing

There are two types of testing


1. Black box testing ( by giving inputs test the output according to the requirements)
2. White box testing (testing source code)

Example:- Requirement for   age   drop down (1-100)


      
If you select the values between 1 -100 it should accept,else it should display error message.
 But it is not possible to test all the values from 1 to 100(time consuming)

To overcome that, two types of black box testing methods are there to derive test cases

1. Boundary value analysis


2. Equivalence class testing

Prof.Chayapathi A R, Dept of ISE ACITPage 1


Software Testing Lecturer Notes Unit2: Functional Testing

BOUNDARY VALUE ANALYSIS


Boundary value analysis’s one of the black box testing method it is used to find the errors at
boundaries of input domain rather than finding those errors in the centre of input.

Boundary Value Analysis refers to analysis of functions with inputs from a range of values that have
boundaries.

a x b
If there are two input variables x1 and x2, then the boundaries might be:

a x1 b c x2 d
The intervals [a,b] and [c,d] are referred to as the ranges of x1 and x2.

Theinputspace(domain)ofourfunctionFisshowninFigure2.1

Figure2.1 InputDomainofaFunctionofTwoVariables

Generalized Boundary Value analysis


Thebasicboundaryvalueanalysistechniquecanbegeneralizedintwoways:
 B ythenumberofvariables,andbythekindsofranges.
 Bythekindsofranges

Generalizingthenumberofvariablesiseasy: I fwehavea
functionofnvariables,weholdallbutoneatthenominalvalues,andlettheremainingvariable
assumethemin,min+,nom,max-andmaxvalues,andrepeatthisforeachvariable.Thusfora functionof
nvariables, boundary value analysis yields 4n+1test cases.

Generalizing ranges depends on the nature (or more precisely, the type) of the variables themselves. In
the Next Date function, for example, we have variables for the month, the day, and the year.

Min+ Avg Max-


|------|----------------------|------------------------|------|
Min Max
Boundary value test cases of single input

Prof.Chayapathi A R, Dept of ISE ACITPage 2


Software Testing Lecturer Notes Unit2: Functional Testing

Here we are testing within the boundaries(only valid data according to the requirement)
We are not testing for invalid data (out of boundary).

Min ---------------------------------- Minimal


Min+ ---------------------------------- Just above Minimal
Nom ---------------------------------- Average
Max ---------------------------------- Just below Maximum
Max ---------------------------------- Maximum

Example:-

Requirement: Age: 1-100


Boundary Value Test Cases are  (min, min+1, avg, max-1, max)
    1 2 51 99 100 

Requirement: ATM PIN: 0000-9999


Boundary Value Test Cases are  (min min+1 avg max-1 max)
      0000 0001 5000 9998 9999 

Boundary Value Test Cases of two inputs (x1, x2)

{< x1 nom,x2min>,< x1 nom,x2min+>,< x1 nom,x2nom>,< x1 nom,x2max->,< x1


nom,x2max>,
<x1min+,x2nom>,<x1min,x2nom>, <x1max,x2nom>,<x1max-,x2nom> }
 
No. of test cases are 4n+1 (n is no of inputs)

Give each set of inputs and check whether the output is according to the requirement or not, instead
of testing all sets, you have to test the above set of inputs to make sure that it will work for all the
values within the range.

Prof.Chayapathi A R, Dept of ISE ACITPage 3


Software Testing Lecturer Notes Unit2: Functional Testing

Boundary Value analysis makes single fault assumption

Single fault assumption:Each failure because of single fault

  
Example of two inputs: -
To test whether multiplication is working correctly or not (we need 2 inputs)

Requirement:- c= a* b   (1<=a<=100, 1<=b<=100)           


  
Boundary value sets of a and b are a= {1,2,50,99 ,100}  b={1,2,50,99,100}
  
Based on the above sets, combinations of test cases (input sets by BVA)are
{< x1 nom,x2min>,< x1 nom,x2min+>,< x1 nom,x2nom>,< x1 nom,x2max->,< x1
nom,x2max>,
<x1min+,x2nom>,<x1min,x2nom>, <x1max,x2nom>,<x1max-,x2nom> }
 
{(50,1),(50,2),(50 ,50),(50,99),(50,100),(1,50),(2,50)(99,50)(100,50)} 

 Take first set of inputs and check whether it is according to the requirement or not
 Give first set input values are 50 and 1       c=50*1 
     It displays some result that is called actual result, if you know the multiplication(requirement)
you can expect the result that is called expected result(if both accepted result and actual result are
same you can say first test case is pass else fail)
  
     Like above you have to test all sets of inputs one by one, Second set is (50, 2) give inputs and
compare actual and expected and decide whether the test case is pass or fail. Same way third set (50,
50), fourth (50, 99)...

Table format of multiplication test cases (BVA)

Inputs
Expected Actual Status
A B Result Result Pass/fail
50 1 50 50 Pass
50 2 100 100 Pass
50 50 2500 2500 Pass
…………. ……………. ………….. ………. ………….

Boundary value Test cases of three inputs are:-

{< x1 nom,x2min>,< x1 nom,x2min+>,< x1 nom,x2nom>,< x1 nom,x2max->,< x1 nom,x2max>,


<x1min+,x2nom>,<x1min,x2nom>, <x1max,x2nom>,<x1max-,x2nom> }
Example:-
*
{x3min, x3 min+1, x3 nom, x3max-1, x3max} (Cartesian product)
Requirement:-

Prof.Chayapathi A R, Dept of ISE ACITPage 4


Software Testing Lecturer Notes Unit2: Functional Testing

Example triangle problem: -


1 ≤ x1 ≤ 100,
1 ≤ x2≤ 100,
1 ≤ x3≤ 100 are three sides of triangle.

{(50,1),(50,2),(50 ,50),(50,99),(50,100),(1,50),(2,50)(99,50)(100,50)}  *{1, 2, 50, 99,100}

{(50,50,1)(50,50,2)(50,50,50),(50,50,99)(50,50,100)(50,1,50)(50,2,50),(50,99,50),(50,100,50),(1,50,50),
(2,50,50)(99,50,50)(100,50,50)}  
Give each set of inputs and compare actual and expected results

Table format of triangle test cases using BVA


Inputs
Expected Actual Status
x1 x2 x3 Result Result Pass/fail

50 50 1 Isosceles Isosceles Pass

50 50 50 Equilateral Equilateral Pass


50 50 1 Isosceles Isosceles Pass
…… …… …….. ………. ……….. ………

ROBUSTNESS TESTING

Robustness testing is an extension of boundary value analysis, to derive test cases and to make sure
it will work for all the values (valid and invalid) with in andout of the boundaries.

In addition to 5 boundary value analysis values of a variable, we see what happens when the extreme
are exceeded with a value slightly greater than the maximum (max+) and a value slightly less
than the minimum (min-).

1. Robustnesstesting of single input

Min- Min+ Nom Max- Max+


|------|------|----------------------|------------------------|------|------|
  Min Max

Robustness Test Cases of single input

{ x1 min-,x1min,x1min+,x1nom,x1max-,x1max,x1max+ }

Prof.Chayapathi A R, Dept of ISE ACITPage 5


Software Testing Lecturer Notes Unit2: Functional Testing

Example: -
Requirement of ATM withdraw min amount is 100 max is 10,000
Robustness Test Cases are (Min-1, min, min+1, nom, max-1, max max+1) 
0 1 2 51 99 100 101

2. Robustness Test Cases of two inputs a<= x1<=b,c<=x2<=d

{< x1 nom,x2min->,< x1 nom,x2min>,< x1 nom,x2min+>,< x1 nom,x2nom>,< x1 nom,x2max-


>,<x1nom,x2max>,<x1nom,x2max+>,
<x1min-,x2nom>,<x1min,x2nom>,<x1min+,x2nom><x1max+,x2nom>,
 <x1max,x2nom>,<x1max-,x2nom> }

No. of test cases are 6n+1 (n is no of inputs)


Give each set of inputs and check whether the output is according to the requirement or not,
instead of testing all the values you have to test the above set of inputs to make sure it will work for
all the values with in and out of the boundaries(valid and invalid).
  
Example for writing Robustness Test Case of two inputs

To test whether addition is working correctly or not (2 inputs)

             c= a+ b   (1<=a<=100, 1<=b<=100)           

    a= {0,1,2,50,99,100,101}  b={0,1,2,50,99,100,101}
  
Based on the above sets, combinations of test cases (inputs) are 

{(50,0)(50,1),(50,2),(50,50),(50,99),(50,101),(50,100),(1,50),(2,50)(99,50)(100,50)(101,50)(0,50)}
 
 Take first set of inputs and check whether it is according to the requirement or not
 
Give first set input values are 50 and 0       c=50+0

Prof.Chayapathi A R, Dept of ISE ACITPage 6


Software Testing Lecturer Notes Unit2: Functional Testing

It displays some result that is called actual result, if you know the addition you can expect
the result that is called expected result (if both accepted result and actual result are same you can
say first test case is pass else fail)
  
Like this you have to test all sets of inputs one by one, second set is (50, 1) give inputs and
compare actual and expected and decide whether that is pass or fail. Same way third set (50, 2),
fourth (50, 50)...

Table format of addition test cases (Robustness Testing)


Inputs
Expected Actual Status
A B Result result Pass/fail
50 0 50 50 Pass
50 1 51 51 Pass
50 2 52 52 Pass
50 50 100 100 Pass
…………. ……………. ………….. ………. ………….

Robustness Test Cases In case of three inputs (example triangle problem):-

{<x1nom,x2min-
>,<x1nom,x2min>,<x1nom,x2min+>,<x1nom,x2nom>,<x1nom,x2max,<x1nom,x2max+>,<x1min-
,x2nom>,<x1min,x2nom>,<x1min+,x2nom><x1max+,x2nom>,
 <x1max,x2nom>,<x1max-,x2nom> } * {x3 min-,x3 min, x3 min+1, x3 nom, x3 max-1, x3 max,x3
max+}

Requirement:-
1 ≤ x1 ≤ 100, 1 ≤ x2≤ 100, 1 ≤ x3≤ 100 are three sides of triangle.
Test cases are:-

{(50,0),(50,1),(50,2),(50,50),(50,99),(50,100),(50,101)(0,50),(1,50),(2,50)(99,50)(100,50),(101,50)}
 *
{0, 1, 2, 50, 99,100,101}
{(50,50,0)(50,50,1)(50,50,2)(50,50,50),(50,50,99)(50,50,100)(50,50,101)(50,0,50),(50,1,50),(50,2,50),
(50,99,50),(50,100,50),(50,101,50)(0,50,50),(1,50,50),(2,50,50) (99,50,50)(100,50,50),(101,50,50)}
Give each set of inputs and compare actual and expected result

Table format of triangle test case (robustness testing)

Prof.Chayapathi A R, Dept of ISE ACITPage 7


Software Testing Lecturer Notes Unit2: Functional Testing

Inputs
Expected Actual Status
X1 X2 X3 Result result Pass/fail
50 50 0 Not a triangle Not a triangle Pass
50 50 1 Isosceles Isosceles Pass
50 50 50 Equilateral Equilateral Pass
…………. ……………. ……….. ………….. ………. ………….

Worst-case Testing (Boundary value analysis)


If you are not satisfied with Boundary value Test cases that mean you can’t make sure that, the
related functionality is working according to the requirements after testing with the above Boundary
value limited sets, and then we can go for Worst Case Testing.

Boundary value analysis makes the Single fault assumption. It Rejects the single fault assumption
and tests all combinations of values Instead of 5n test cases, we have 5n.

For each variable, we start with the five-element set that contains min, min+, nom, max-, max
values. We can take the Cartesian product.

In case of two inputs, consider all sets produced by the below Cartesian product

{x1 min, x1 min+1, x1 nom, x1max-1, x1max} * {x2 min, x2 min+1, x2 nom, x2max-1, x2max}

These test cases although more comprehensive in their coverage, constitute much more endeavour. To
compare we can see that Boundary Value Analysis results in 4n + 1 test case where Worst-Case testing
results in 5n test cases. As each variable has to assume each of its variables for each permutation (the
Cartesian product) we have 5 to the n test cases.

Worst–Case Robustness Test Cases of two inputs

Prof.Chayapathi A R, Dept of ISE ACITPage 8


Software Testing Lecturer Notes Unit2: Functional Testing

{ x1 mn-,x1min,x1min+,x1avg,x1max-,x1max,x1max+} *
{ x2 mn-,x2min,x2min+,x2avg,x2max-,x2max,x2max+ }

These test cases although more comprehensive in their coverage, constitute much more endeavour. To
compare we can see that Robustness Testing results in 6n + 1 test case where Worst-Case testing results
in 7n test cases. As each variable has to assume each of its variables for each permutation (the Cartesian
product) we have 7 to the n test cases.Totalno.of Test Cases is 7n

Worst-case Robustness Test cases of (three inputs) triangle problem(x1, x2, x3 are the
sides):-

{ {x1 mn-,x1min,x1min+,x1avg,x1max-,x1max,x1max+} *
{ x2 mn-,x2min,x2min+,x2avg,x2max-,x2max,x2max+ }
* {x1 mn-,x1min,x1min+,x1avg,x1max-,x1max,x1max+}

* {x3 min-,x3 min, x3 min+1, x3 nom, x3 max-1, x3 max,x3


max+}

Prof.Chayapathi A R, Dept of ISE ACITPage 9


Software Testing Lecturer Notes Unit2: Functional Testing

Beloware the few worst-case Robust ness Test Cases of triangle problem (1<=x1, x2,
x3<=200)

Limitation of Boundary value analysis

 Does not work well for Boolean variables


 Boundary value analysis works well when the program to be tested is a function
of several independent variables that represent bounded physical quantities.
E.g. Next Date test cases are inadequate (little stress on February, dependencies
among month, day, and year)
E.g. variables refer to physical quantities, such as temperature, air speed, load
etc.
 Not that much useful for strongly-typed languages

SpecialValueTesting

Specialvaluetestingisprobablythemostwidelypracticedformoffunctionaltesting.Italsoisthemostintuitive

Prof.Chayapathi A R, Dept of ISE ACITPage 10


Software Testing Lecturer Notes Unit2: Functional Testing

andtheleastuniform.Specialvaluetestingoccurswhenatesteruseshis/herdomain knowledge,
experiencewithsimilarprograms,andinformationabout“softspots”todevisetest cases.
Wemightalsocallthis“adhoctesting”.Thereareno
guidelines,otherthantouse“bestengineeringjudgment.”Asaresult,specialvaluetestingisverydep
endentontheabilitiesofthetester.
Even though it is highly subjective, it often results in a set of test cases which is more effective
in revealing faults than the test sets generated by the other methods .

Table:5 contains some typical value test case for the commission problem

Table5OutputSpecialValueTestCasesCase

locks stocks barrels sales comm Comment

1 10 11 9 1005 100.75 borderpoint+

2 18 17 19 1795 219.25 borderpoint-


3 18 19 17 1805 221 borderpoint+

TestCasesfortheTriangleProblem
Table1BoundaryValueAnalysisTestCasesCase
A b c ExpectedOutput
1 100 100 1 Isosceles
2 100 100 2 Isosceles
3 100 100 100 Equilateral
4 100 100 199 Isosceles
5 100 100 200 NotaTriangle
6 100 1 100 Isosceles
7 100 2 100 Isosceles
8 100 100 100 Equilateral
9 100 199 100 Isosceles
10 100 200 100 Not a Triangle
11 1 100 100 Isosceles
12 2 100 100 Isosceles
13 100 100 100 Equilateral
14 199 100 100 Isosceles
15 200 100 100 Not a riangle

Worst case TestCasesfortheTriangleProblem

Table2WorstCaseTestCasesCase

Prof.Chayapathi A R, Dept of ISE ACITPage 11


Software Testing Lecturer Notes Unit2: Functional Testing

A b c ExpectedOutput

1 1 1 1 Equilateral

2 1 1 2 NotaTriangle

3 1 1 100 NotaTriangle

4 1 1 199 NotaTriangle

5 1 1 200 NotaTriangle

6 1 2 1 NotaTriangle

7 1 2 2 Isosceles

8 1 2 100 NotaTriangle

9 1 2 199 NotaTriangle

10 1 2 200 NotaTriangle

11 1 100 1 NotaTriangle

12 1 100 2 NotaTriangle

13 1 100 100 Isosceles

14 1 100 199 NotaTriangle

15 1 100 200 NotaTriangle

16 1 199 1 NotaTriangle

17 1 199 2 NotaTriangle

18 1 199 100 NotaTriangle

19 1 199 199 Isosceles

20 1 199 200 NotaTriangle

21 1 200 1 NotaTriangle

22 1 200 2 NotaTriangle

23 1 200 100 NotaTriangle

Prof.Chayapathi A R, Dept of ISE ACITPage 12


Software Testing Lecturer Notes Unit2: Functional Testing

24 1 200 199 NotaTriangle

25 1 200 200 Isosceles

TestCasesfortheNextDateProblem

Table3WorstCaseTestCasesCase

Month day year expectedoutput

1 1 1 1812 January2,1812

2 1 1 1813 January2,1813

3 1 1 1912 January2,1912

4 1 1 2011 January2,2011

5 1 1 2012 January2,2012

6 1 2 1812 January3,1812

7 1 2 1813 January3,1813

8 1 2 1912 January3,1912

9 1 2 2011 January3,2011

10 1 2 2012 January3,2012

11 1 15 1812 January16,1812

12 1 15 1813 January16,1813

13 1 15 1912 January16,1912

14 1 15 2011 January16,2011

15 1 15 2012 January16,2012

16 1 30 1812 January31,1812

17 1 30 1813 January31,1813

18 1 30 1912 January31,1912

19 1 30 2011 January31,2011

Prof.Chayapathi A R, Dept of ISE ACITPage 13


Software Testing Lecturer Notes Unit2: Functional Testing

20 1 30 2012 January31,2012

21 1 31 1812 February1,1812

22 1 31 1813 February1,1813

23 1 31 1912 February1,1912

24 1 31 2011 February1,2011

25 1 31 2012 February1,2012

Test Cases for the commission problem

Rather than go through 125 boring test cases again, we’ll look at some more
interesting test cases for the commission problem. This time we’ll look at boundary
values for the output range, especially near the threshold points of $1000 and $1800.

Table4OutputBoundaryValueAnalysisTestCasesCase

Locks stocks barrels sales comm Comment

1 1 1 1 100 10 outputminimum

2 1 1 2 125 12.5 outputminimum+

3 1 2 1 130 13 outputminimum+

4 2 1 1 145 14.5 outputminimum+

5 5 5 5 500 50 midpoint

6 10 10 9 975 97.5 borderpoint-

7 10 9 10 970 97 borderpoint-

8 9 10 10 955 95.5 borderpoint-

9 10 10 10 1000 100 borderpoint

10 10 10 11 1025 103.75 borderpoint+

11 10 11 10 1030 104.5 borderpoint+

12 11 10 10 1045 106.75 borderpoint+

13 14 14 14 1400 160 midpoint

Prof.Chayapathi A R, Dept of ISE ACITPage 14


Software Testing Lecturer Notes Unit2: Functional Testing

14 18 18 17 1775 216.25 borderpoint-

15 18 17 18 1770 215.5 borderpoint-

16 17 18 18 1755 213.25 borderpoint-

17 18 18 18 1800 220 borderpoint

18 18 18 19 1825 225 borderpoint+

19 18 19 18 1830 226 borderpoint+

20 19 18 18 1845 229 borderpoint+

21 48 48 48 4800 820 midpoint

22 70 80 89 7775 1415 outputmaximum-

23 70 79 90 7770 1414 outputmaximum-

24 69 80 90 7755 1411 outputmaximum-

25 70 80 90 7800 1420 outputmaximum

Random Testing

 Use a random number generator to generate test cases.


 Statistically the most valid method.
 The basic idea is that, rather than always choose the min, min+, nom,
max- and maxvalues of a bounded variable, use a random number
generator to pick test case values.

X=Int((b-a+1)*Rnd+a)

Where function Int returns the integer part of a floating point


number, and function Rnd generates random numbers in the interval
[0,1].
The program keeps generating random test cases until at least one of
each output occurs.

 This avoids a form of bias in testing

Prof.Chayapathi A R, Dept of ISE ACITPage 15


Software Testing Lecturer Notes Unit2: Functional Testing

 The program keeps generating random test cases until at least one of
each output occurs.

In each table, the program went through seven cycles that ended with
hard to generate test case.

In table 5.6 and 5.7 shows the result of randomly generated test cases, the
last line shows what percentage of the random test cases was generated for
each column. In the table 5.8 for Next date, the percentage is very close to
the probability given in the last line

Prof.Chayapathi A R, Dept of ISE ACITPage 16


Software Testing Lecturer Notes Unit2: Functional Testing

Guidelines for Boundary Value Testing

 Test methods based on input domain of the function are


rudimentary.
 Share the common assumption that input variables are independent.
 Two other distinctions:
◦ Normal vs. Robust
◦ Single vs. Multiple Fault Assumption

Prof.Chayapathi A R, Dept of ISE ACITPage 17


Software Testing Lecturer Notes Unit2: Functional Testing

Equivalence Class Testing


 Equivalence class testing develops test cases via the partitioning of the
input/output/predicate variable’s value set into classes (subsets) using some equivalence
relation.
 Use the mathematical concept of partitioning into equivalence classes to generate test cases
for Functional (Black-box) testing
 The key goals (motivation ) for equivalence class testing are similar to partitioning:
o completeness of test coverage
o lesser duplication of test coverage(avoid redundancy)
Partitioning : -

 Recall a partitioning of a set, A, is to divide the set A into ( a1, a2, - - - -, an ) subsets such
that:
o a1 U a2 U - - - - U an = A (completeness)
o for any i and j, ai ∩ aj = Ø (no duplication)

Equivalence Classes:-

 Equivalence class testing is the partitioning of the (often times, but not always) input variable’s
value set into classes (subsets) using some equivalence relation.

There are four types of Equivalence Class Testing types


1. Weak Normal Equivalence Class Testing
2. Strong Normal Equivalence Class Testing
3. Weak Robust Equivalence Class Testing
4. Strong Robust Equivalence Class Testing

Equivalence Class Test Cases of single input: -


In Boundary Value and Robustness Testing we are selecting the inputs at the boundary points and
one nom value.
For example age- 0-100 in we are considering only -1,0,1, 50, 99,100 and 101 , but it may not accept
when you enter the age not at the boundary like 30 , 40, 60, 70 etc., we are not testing these values in
BVA or RT to overcome that we can go for Equivalence Class Testing.

 Consider a numerical input variable, i, whose values may range from -200 through +200.
Then a possible partitioning of testing input variable by 4 people may be:
o -200 to -100| -101 to 0|1 to 100|101 to 200

Inputs are -150, -50,90, and 150

Prof.Chayapathi A R, Dept of ISE ACITPage 18


Software Testing Lecturer Notes Unit2: Functional Testing

1.Weak Normal Equivalence testing of two inputs:-


 Assumes the ‘single fault’ or “independence of input variables.”
 E.g. If there are 2 input variables, these input variables are independent of
each other.
 Partition the test cases of each input variable separately into different equivalent classes.
 Choose the test case from each of the equivalence classes for each input variable
independently of the other input variable

2.Strong Normal Equivalence testing of two inputs:-

• This is the same as the weak normal equivalence testing except for
“Multiple fault assumption”
or
“Dependence among the inputs”
• All the combinations of equivalence classes of the variables must be included.
• The Cartesian product guarantees that we have a notion of completeness in two sense :

We cover all the equivalence classes, and


We have one of each possible combination of inputs.

Prof.Chayapathi A R, Dept of ISE ACITPage 19


Software Testing Lecturer Notes Unit2: Functional Testing

3 Weak Robust Equivalence testing of two inputs:-

• Up to now we have only considered partitioning the valid input space.


• “Weak robust” is similar to “weak normal” equivalence test except that the invalid input
variables are now considered.
• The robust part comes from consideration of invalid values, and weak part refers to
the single fault assumption

1. For valid inputs,use one value from each valid class (as in what we have called
weakequivalence class testing.(Note that each input in these testcases will be valid.)
2. Forinvalidinputs,atestcasewillhaveoneinvalidvalueandtheremaining valueswillallbe
valid.(Thusa“singlefailure”shouldcausethetestcasetofail)

Prof.Chayapathi A R, Dept of ISE ACITPage 20


Software Testing Lecturer Notes Unit2: Functional Testing

4 Strong Robust Equivalence testing of two inputs:-

• Does not assume “single fault” - - - assumes dependency of input variables


• “Strong robust” is similar to “strong normal” equivalence test except that the invalid input
variables are now considered.

Equivalence Class Test Cases for the Triangle Problem


Prof.Chayapathi A R, Dept of ISE ACITPage 21
Software Testing Lecturer Notes Unit2: Functional Testing

• We may define the input test data by defining the equivalence class through “viewing”
the 4 output groups:
R1-input sides <a, b, c> do not form a triangle
R2-input sides <a, b ,c> form an isosceles triangle
R3-input sides <a, b, c> form a scalene triangle
R4-input sides <a, b, c> form an equilateral triangle

Weak Normal Test Cases of Triangle problem

Test A b C Expected Output


Case
Weak WN1 5 5 5 Equilateral or Robust Test Cases of
WN2 2 2 3 Isosceles or Triangle problem
WN3 3 4 5 Scalene or
WN4 4 1 2 Not a Triangle
Test A b C Expected Output
Case
WR1 -1 5 5 Value a is not in range
WR2 5 -1 5 Value b is not in range
WR3 5 5 -1 Value c is not in range
or
WR4 201 5 5 Value a is not in range
WR5 5 201 5 Value b is not in range
WR6 5 5 201 Value c is not in range

Strong Robust Test Cases of Triangle problem

Test Case A b C Expected Output


SR1 -1 5 5 Value a is not in range
SR2 5 -1 5 Value b is not in range
SR3 5 5 -1 Value c is not in range
SR4 -1 -1 5 Value a,b is not in range
SR5 5 -1 -1 Value b,c is not in range
SR6 -1 5 -1 Value c,a is not in range
SR7 -1 -1 -1 Value c,a,b is not in range

EquivalenceClassTestCasesfortheNextDateFunction

Itisgoodexampleonwhichtocomparetraditional,weak,andstrongformsofequivalenceclasstesting.Next
Dateisafunctionofthreevariables,month,day,andyear,andthese haverangesdefinedasfollows:

Prof.Chayapathi A R, Dept of ISE ACITPage 22


Software Testing Lecturer Notes Unit2: Functional Testing

TraditionalTestCases

Thevalidequivalenceclassesare

Theinvalidequivalenceclassesare

Because the number of valid classes equals the number of independent


variables, only one weak normal equivalence class test case occurs , and it is
identical to the strong normal equivalence class test case

Here is the full set of weak robust test cases

Prof.Chayapathi A R, Dept of ISE ACITPage 23


Software Testing Lecturer Notes Unit2: Functional Testing

Test case for strong Robust Equivalence class

Sr1 -1 15 1912 Value of month not in the range 1----12

What must be done to an input date? If it is not the last day of a month, the NextDate function
will simply increment the day value.At the end of a month,the next day is 1 and the month is
incremented. At the end of a year,both the day and the month are reset to 1, and the year is
incremented. Intresting With all this in mind, we might postulate the following equivalence
classes:

WeakEquivalenceClassTestCases for Next date Function

Prof.Chayapathi A R, Dept of ISE ACITPage 24


Software Testing Lecturer Notes Unit2: Functional Testing

These classes yield the following weak equivalence class test cases. As before, the inputs are
mechanically selected from the approximate middle of the corresponding class:
CaseID Month Day Year Expected
Output

WE1 6 14 1900 6/15/1900

WE2 7 29 1912 7/30/1912

WE3 2 30 1913 invalidinput

WE4 6 31 1900 invalidinput

StrongEquivalenceClassTestCasesfor Next date Function

Usingthesameequivalenceclasses,wefindthestrongequivalenceclasstestcasesshowninthetablebelow.Thesamevalu
eselectioncriterionisused.Westilldon’thavea“perfect”setoftest
cases,butIthinkanytesterwouldbealothappierwiththe36strongequivalenceclasstestcases.Toillustratethesensiti
vitytothechoiceofclasses,noticethat,amongthese36testcases,wenevergetaFeb.28.Ifwehadchosenfivedayclasse
s,whereD1’wouldbedays1-27,D1”wouldbe28,
andtheotherthreewouldstaythesame.Wewouldhaveasetof45testcases,andamongthese, therewouldbebetter
coverageofFeb.28considerations.

CaseID Month Day Year Expected


Output

SE1 6 14 1900 6/15/1900

SE2 6 14 1912 6/15/1912

SE3 6 14 1913 6/15/1913

SE4 6 29 1900 6/30/1900

SE5 6 29 1912 6/30/1912

SE6 6 29 1913 6/30/1913

SE7 6 30 1900 7/1/1900

SE8 6 30 1912 7/1/1912

SE9 6 30 1913 7/1/1913

Prof.Chayapathi A R, Dept of ISE ACITPage 25


Software Testing Lecturer Notes Unit2: Functional Testing

SE10 6 31 1900 ERROR

SE11 6 31 1912 ERROR

SE12 6 31 1913 ERROR

SE13 7 14 1900 7/15/1900

SE14 7 14 1912 7/15/1912

SE15 7 14 1913 7/15/1913

SE16 7 29 1900 7/30/1900

SE17 7 29 1912 7/30/1912

SE18 7 29 1913 7/30/1913

SE19 7 30 1900 7/31/1900

SE20 7 30 1912 7/31/1912

SE21 7 30 1913 /31/1913

SE22 7 31 1900 8/1/1900

SE23 7 31 1912 8/1/1912

SE24 7 31 1913 8/1/1913

SE25 2 14 1900 2/15/1900

SE26 2 14 1912 2/15/1912

SE27 2 14 1913 2/15/1913

SE28 2 29 900 ERROR

SE29 2 29 1912 3/1/1912

SE30 2 29 1913 ERROR

SE31 2 30 1900 ERROR

SE32 2 30 1912 ERROR


SE33 2 30 1913 ERROR

Prof.Chayapathi A R, Dept of ISE ACITPage 26


Software Testing Lecturer Notes Unit2: BVA, ECT, DT-Based Testing

SE34 2 31 1900 ERROR

SE35 2 31 1912 ERROR

SE36 2 31 1913 ERROR

EquivalenceClassTestCasesfortheCommissionProblem

TheInputdomainoftheCommissionProblemis“naturally”partitionedbythelimitsonlocks,
stocks,andbarrels.Theseequivalenceclassesareexactlythosethatwouldalsobeidentifiedbytraditionalequival
enceclasstesting.Thefirstclassisthevalidinput,theothertwoareinvalid.Theinputdomainequivalenceclassesl
eadtoveryunsatisfactorysetsoftestcases.We’lldoalittlebetterwithequivalenceclassesdefinedontheoutputra
ngeofthecommissionfunction.
The valid classes of the input variables are :

The corresponding invalid classes of the input variables are:

Weak Robust test cases for Weak Robust

TC Id Test Case Input Data Sales Expected Output(Commission)


Description

Locks Stocks Barrels

1 WR1 10 10 10 $100 10
2 WR2 -1 40 45 Program Program terminates
terminates
3 WR3 -2 40 45 Values of locks Values of locks not in the range 1...70
not in the range
1...70
4 WR4 71 40 45 Values of locks Values of locks not in the range 1...70
not in the range
1...70
5 WR5 35 -1 45 Values of Values of stocks not in the range 1...80
stocks not in
the range 1...80
6 WR6 35 81 45 Values of Values of stocks not in the range 1...80
stocks not in
the range 1...80

7 WR7 10 9 10 970 97

8 WR8 9 10 10 955 95.5


Software Testing Lecturer Notes Unit2: BVA, ECT, DT-Based Testing

Strong Robust test cases for commission problem

T Test Case Input Data Sales Expected


C Descriptio Lock Stock Barrels Output(Commission
Id n s s )
1 SR1 -2 40 45 Values of locks Values of locks not in
not in the range the range 1...70
1...70
2 SR2 35 -1 45 Values of stocks Values of stocks not in
not in the range the range 1...80
1...80
3 SR3 35 40 -2 Values of barrels Values of barrels not in
not in the range the range 1...90
1...90
4 SR4 -2 -1 45 Values of locks Values of locks not in
not in the range the range 1...70
1...70 Values of stocks not in
Values of stocks the range 1...80
not in the range
1...80
5 SR5 -2 40 -1 Values of locks Values of locks not in
not in the range the range 1...70
1...70 Values of barrels not in
Values of barrels the range 1...90
not in the range
1...90
6 SR6 35 -1 -1 Values of stocks Values of stocks not in
not in the range the range 1...80
1...80 Values of barrels not in
Values of barrels the range 1...90
not in the range
1...90
7 SR7 -2 -1 -1 Values of locks Values of locks not in
not in the range the range 1...70
1...70 Values of stocks not in
Values of stocks the range 1...80
not in the range Values of barrels not in
1...80 the range 1...90
Values of barrels
not in the range
1...90
GuidelinesandObservations
Software Testing Lecturer Notes Unit2: BVA, ECT, DT-Based Testing

 The weak forms of equivalence class testing are not as comprehensive as the
corresponding strong forms.
 If error conditions are a high priority, the robust forms are appropriate.
 Equivalence Class Testing is appropriate when input data is defined in terms of intervals
and sets of discrete values.
 Equivalence Class Testing is strengthened when combined with Boundary Value Testing
 Strong equivalence takes the presumption that variables are independent. If that is not
the case, redundant test cases may be generated
 Complex functions, such as the NextDate program, are well-suited for Equivalence Class
Testing
 Several tries may be required before the “right” equivalence relation is discovered

Decision Table Testing


Decision Table-Based Testing has been around since the early 1960’s; it is used toanalyze complex
logical relationships between input data.

Definition:-
A Decision Table is the method used to build a complete set of test cases withoutusing the internal
structure of the program. In order to create test cases weuse a table that contain the input and output
values of a program. Such a table is split upinto four sections as shown below in fig 2.1.

 In fig 2.1 there are two lines which divide the table into four components. The solid
vertical line separates the Stub and Entry portions of the table, and the solid horizontal
line is the boundary between the Conditions and Actions.
 These lines separate the table into four portions, Condition Stub, Action Stub, Condition
Entries and Action Entries.
 A column in the entry portion of the table is known as a rule.
 Values which are in the condition entry columns are known as inputs and values inside the
action entry portions are known as outputs.
 Outputs are calculated depending on the inputs and specification of the program

SAMPLE DECISION TABLE

RULES CONDITION ENTRIES


Software Testing Lecturer Notes Unit2: BVA, ECT, DT-Based Testing

CONDITIONS

ACTIONS ACTION
ENTRIES
2.2 Typical Structure of Decission Table

 The above table is an example of a typical Decision Table. The inputs in this given table
derive the outputs depending on what conditions these inputs meet.

 Notice the use of “-“in the table below, these are known as don’t care entries. Don’t care
entries are normally viewed as being false values which don’t require the value to define
the output.
 Figure 2.2 shows its values from the inputs as true(T) or false(F) values which arebinary
conditions, tables which use binary conditions are known as limited entrydecision tables.
Tables which use multiple conditions are known as extended entrydecision tables

Redundancy Decision Table:-

When using “don’t care” entries a level of care must be taken, using these entries can cause
redundancy and inconsistency within a decision table.
An example of a decision table with a redundant rule can be seen in figure 3.3. From the table
you can see that there is some conflict between rules 1-4 and rule 9, rules 1-4 use “don’t care”
entries as an alternative to false, but rule 9 replaces those “don’t care” entries with “false”
entries. So when condition 1 is met rules 1-4 or 9 may be applied, luckily in this particular
instance these rules have identical actions so there is only a simple correction to be made to
complete the following table(we can remove any one rule1-4 or 9).

Figure 3.3 an example of a Redundant Rule

Inconsistency Decision Table :-


If on the other hand the actions of the redundant rule differ from that of rules 1-4 then we
have a problem. A table showing this can be seen in figure 3.4.
Software Testing Lecturer Notes Unit2: BVA, ECT, DT-Based Testing

Figure 3.4 an example of Inconsistent Rules


From the above decision table, if condition 1 was to be true and conditions 2 and 3 were false
then rules 1-4 and 9 could be applied. This would result in a problem because the actions of
these rules are inconsistent so therefore the result is nondeterministic and would cause the
decision table to fail.

Decision Table for Triangle Problem


As explained above, there are two types of decision table, limited and extended entrytables.
Below, in fig 3.1 is an example of a limited entry decision table where theinputs are binary
conditions.

Fig 3.1 Decision Table for the Triangle Problem

Rule Counts :-
Rule counts are used along with don’t care entries as a method to test for decisiontable
completeness; we can count the no. oftest cases in a decision table usingrule counts and compare
it with a calculated value. Below is a table which illustratesrule counts in a decision table.

Fig 3.2 an example of Rule Counts in a Decision Table

The table above has a total rule count of 64; this can be calculated using the limitedentry formula
as it’s a limited entry table.Number of Rules = 2n (n is no. of conditions)
So therefore, Number of Rules =26= 64When calculating rule counts the don’t care values play a
major role to find the rule count ofthat rule.

Test cases for the triangle problem based on 3.2 diagram


Software Testing Lecturer Notes Unit2: BVA, ECT, DT-Based Testing

A B C Expected Output

DT1 4 1 2 Not a Triangle


DT2 1 4 2 Not a Triangle
DT3 1 2 4 Not a Triangle
DT4 5 5 5 Equilateral
DT5 - - - Impossible
DT6 - - - Impossible
DT7 2 2 3 Isosceles
DT8 - - - Impossible
DT9 2 3 2 Isosceles
DT10 3 2 2 Isosceles
DT11 3 4 5 Scalene

You might also like