Professional Documents
Culture Documents
Functional Testing - MOD2
Functional Testing - MOD2
Lecture Notes
UNIT2
Functional Testing
To overcome that, two types of black box testing methods are there to derive test cases
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
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.
Here we are testing within the boundaries(only valid data according to the requirement)
We are not testing for invalid data (out of boundary).
Example:-
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.
Example of two inputs: -
To test whether multiplication is working correctly or not (we need 2 inputs)
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)...
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
…………. ……………. ………….. ………. ………….
{(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
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-).
{ x1 min-,x1min,x1min+,x1nom,x1max-,x1max,x1max+ }
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
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
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)...
{<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
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
…………. ……………. ……….. ………….. ………. ………….
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.
{ 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+}
Beloware the few worst-case Robust ness Test Cases of triangle problem (1<=x1, x2,
x3<=200)
SpecialValueTesting
Specialvaluetestingisprobablythemostwidelypracticedformoffunctionaltesting.Italsoisthemostintuitive
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
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
Table2WorstCaseTestCasesCase
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
16 1 199 1 NotaTriangle
17 1 199 2 NotaTriangle
21 1 200 1 NotaTriangle
22 1 200 2 NotaTriangle
TestCasesfortheNextDateProblem
Table3WorstCaseTestCasesCase
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
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
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
1 1 1 1 100 10 outputminimum
3 1 2 1 130 13 outputminimum+
5 5 5 5 500 50 midpoint
7 10 9 10 970 97 borderpoint-
Random Testing
X=Int((b-a+1)*Rnd+a)
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
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.
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
• 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 :
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)
• 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
EquivalenceClassTestCasesfortheNextDateFunction
Itisgoodexampleonwhichtocomparetraditional,weak,andstrongformsofequivalenceclasstesting.Next
Dateisafunctionofthreevariables,month,day,andyear,andthese haverangesdefinedasfollows:
TraditionalTestCases
Thevalidequivalenceclassesare
Theinvalidequivalenceclassesare
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:
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
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.
EquivalenceClassTestCasesfortheCommissionProblem
TheInputdomainoftheCommissionProblemis“naturally”partitionedbythelimitsonlocks,
stocks,andbarrels.Theseequivalenceclassesareexactlythosethatwouldalsobeidentifiedbytraditionalequival
enceclasstesting.Thefirstclassisthevalidinput,theothertwoareinvalid.Theinputdomainequivalenceclassesl
eadtoveryunsatisfactorysetsoftestcases.We’lldoalittlebetterwithequivalenceclassesdefinedontheoutputra
ngeofthecommissionfunction.
The valid classes of the input variables are :
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
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
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
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
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).
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.
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.
A B C Expected Output