Você está na página 1de 13

5/6/2016

SoftwareTestingMethodologiesCoursePage
R07RegulationDept.ofCSE&IT
HOME

SCHEDULE

UNITI
Purposeof
Testing
Dichotomies
Modelfor
Testing
Consequences
ofBugs
Taxonomyof
Bugs
Summary
UNITII
BasicsofPath
Testing
Predicates,Path
Predicatesand
Achievable
Paths
PathSensitizing
Path
Instrumentation
Applicationof
PathTesting
Summary
UNITIII
Transaction
Flows
Transaction
FlowTesting
Techniques
Implementation
BasicsofData
FlowTesting
Strategiesin
DataFlow
Testing
Applicationof
DataFlow
Testing
Summary
UNITIV
Domainsand
Paths
NiceandUgly

GLOSSARY

ASSIGNMENTS

UNITVILOGICBASEDTESTING

BRIEF
OVERVIEW

RESOURCES

LOGICBASEDTESTING:

Thisunitgivesanindepthoverviewoflogicbasedtestinganditsimplementation.
Attheendofthisunit,thestudentwillbeableto:
UnderstandtheconceptofLogicbasedtesting.
Understandtheuseofdecisiontablesintestcasedesignandknowtheirlimitations.
UnderstandandinterpretKVChartsandknowtheirlimitations.
LearnhowtotransformspecificationsintosentencesandmapthemintoKVcharts.
Understandtheimportanceofdontcareconditions.

OVERVIEWOFLOGICBASEDTESTING:

TOP
INTRODUCTION:
The functional requirements of many programs can be specified by decision tables,
whichprovideausefulbasisforprogramandtestdesign.
Consistency and completeness can be analyzed by using boolean algebra, which can
also be used as a basis for test design. Boolean algebra is trivialized by using
KarnaughVeitchcharts.
"Logic" is one of the most often used words in programmers' vocabularies but one of
theirleastusedtechniques.
Boolean algebra is to logic as arithmetic is to mathematics. Without it, the tester or
programmeriscutofffrommanytestanddesigntechniquesandtoolsthatincorporate
thosetechniques.
Many test methods developed for hardware logic can be adapted to software logic
testing. Because hardware testing automation is 10 to 15 years ahead of software
testing automation, hardware testing methods and its associated theory is a fertile
groundforsoftwaretestingmethods.
As programming and test techniques have improved, the bugs have shifted closer to
theprocessfrontend,torequirementsandtheirspecifications.These bugs range from
8%to30%ofthetotalandbecausethey'refirstinandlastout,they'rethecostliestof
all.
Thetroublewithspecificationsisthatthey'rehardtoexpress.
Boolean algebra (also known as the sentential calculus) is the most basic of all logic
systems.
Higherorderlogicsystemsareneededandusedforformalspecifications.
Much of logical analysis can be and is embedded in tools. But these tools incorporate
methods to simplify, transform, and check specifications, and the methods are to a
largeextentbasedonbooleanalgebra.
KNOWLEDGEBASEDSYSTEM:
Theknowledgebasedsystem(alsoexpertsystem,or"artificialintelligence"
system) has become the programming construct of choice for many
applicationsthatwereonceconsideredverydifficult.
Knowledgebased systems incorporate knowledge from a knowledge domain
such as medicine, law, or civil engineering into a database. The data can
then be queried and interacted with to provide solutions to problems in that

http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

1/13

5/6/2016

domains
DomainTesting
Domainand
Interface
Testing
Domainsand
Testability
Summary
UNITV
Pathproducts
andPath
expression
Reduction
Procedure
Applications
Regular
Expressionsand
FlowAnomaly
Detection
Summary
UNITVI
LogicBased
Testing
DecisionTables
Path
Expressions
KVCharts
Specications
Summary

domain.
One implementation of knowledgebased systems is to incorporate the
expert's knowledge into a set of rules. The user can then provide data and
The user's data is processed through the rule base to yield conclusions
(tentativeordefinite)andrequestsformoredata.Theprocessingisdoneby
aprogramcalledtheinferenceengine.
Understanding knowledgebased systems and their validation problems
requiresanunderstandingofformallogic.
Decision tables are extensively used in business data processing Decisiontable
preprocessors as extensions to COBOL are in common use boolean algebra is
embeddedintheimplementationoftheseprocessors.
Although programmed tools are nice to have, most of the benefits of boolean algebra
can be reaped by wholly manual means if you have the right conceptual tool: the
KarnaughVeitchdiagramisthatconceptualtool.
TOP
DECISIONTABLES:

TOP
Figure6.1isalimitedentrydecisiontable.Itconsistsoffourareascalledtheconditionstub,the
conditionentry,theactionstub,andtheactionentry.
Eachcolumnofthetableisarulethatspecifiestheconditionsunderwhichtheactionsnamedin
theactionstubwilltakeplace.
Theconditionstubisalistofnamesofconditions.

Figure6.1:ExamplesofDecisionTable.
Amoregeneraldecisiontablecanbeasbelow:

http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

2/13

5/6/2016

Figure6.2:AnotherExamplesofDecisionTable.
Arulespecifieswhetheraconditionshouldorshouldnotbemetfortheruletobesatisfied."YES"
means that the condition must be met, "NO" means that the condition must not be met, and "I"
meansthattheconditionplaysnopartintherule,oritisimmaterialtothatrule.
The action stub names the actions the routine will take or initiate if the rule is satisfied. If the
actionentryis"YES",theactionwilltakeplaceif"NO",theactionwillnottakeplace.
ThetableinFigure6.1canbetranslatedasfollows:
Action1willtakeplaceifconditions1and2aremetandifconditions3and4arenotmet(rule1)
orifconditions1,3,and4aremet(rule2).
"Condition"isanotherwordforpredicate.
Decisiontable uses "condition" and "satisfied" or "met". Let us use "predicate" and TRUE /
FALSE.
Nowtheabovetranslationsbecome:
1.Action1willbetakenifpredicates1and2aretrueandifpredicates3and4arefalse
(rule1),orifpredicates1,3,and4aretrue(rule2).
2.Action2willbetakenifthepredicatesareallfalse,(rule3).
3.Action3willtakeplaceifpredicate1isfalseandpredicate4istrue(rule4).
takenwhenallotherrulesfail.ThedefaultrulesforTableinFigure6.1isshowninFigure6.3

Figure6.3:ThedefaultrulesofTableinFigure6.1
DECISIONTABLEPROCESSORS:
Decision tables can be automatically translated into code and, as such, are a higher
orderlanguage
Iftheruleissatisfied,thecorrespondingactiontakesplace
Otherwise, rule 2 is tried.This process continues until either a satisfied rule results in
anactionornoruleissatisfiedandthedefaultactionistaken
Decision tables have become a useful tool in the programmers kit, in business data
processing.
DECISIONTABLESASBASISFORTESTCASEDESIGN:
2.The order in which the predicates are evaluated does not affect interpretation of the
http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

3/13

5/6/2016

rulesortheresultingactioni.e.,anarbitrarypermutationofthepredicateorderwillnot,
orshouldnot,affectwhichactiontakesplace.
3.Theorderinwhichtherulesareevaluateddoesnotaffecttheresultingactioni.e., an
arbitrarypermutationofruleswillnot,orshouldnot,affectwhichactiontakesplace.
4.Oncearuleissatisfiedandanactionselected,nootherruleneedbeexamined.
5.If several actions can result from satisfying a rule, the order in which the actions are
executeddoesn'tmatter
DECISIONTABLESANDSTRUCTURE:
Decisiontablescanalsobeusedtoexamineaprogram'sstructure.

Figure6.4:ASampleProgram
If the decision appears on a path, put in a YES or NO as appropriate. If the decision
doesnotappearonthepath,putinanI,Rule1doesnotcontaindecisionC,therefore
itsentriesare:YES,YES,I,YES.
ThecorrespondingdecisiontableisshowninTable6.1
RULE1 RULE2

RULE3

RULE4

RULE5

RULE6

CONDITIONA
CONDITIONB
CONDITIONC
CONDITIOND

YES
YES
I
YES

YES
NO
I
I

YES
YES
I
NO

NO
I
YES
I

NO
I
NO
YES

NO
I
NO
NO

ACTION1
ACTION2
ACTION3

YES
NO
NO

YES
NO
NO

NO
YES
NO

NO
YES
NO

NO
YES
NO

NO
NO
YES

Table6.1:DecisionTablecorrespondingtoFigure6.4
Asanexample,expandingtheimmaterialcasesresultsasbelow:

Similalrly,IfweexpandtheimmaterialcasesfortheaboveTable6.1,itresultsinTable
6.2asbelow:

CONDITIONA
http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

R1

RULE2

R3

RULE4

R5

R6

YY

YYYY

YY

NNNN

NN

NN
4/13

5/6/2016

CONDITIONB
CONDITIONC
CONDITIOND

YY
YN
YY

NNNN
NNYY
YNNY

YY
YN
NN

YYNN
YYYY
NYYN

NY
NN
YY

YN
NN
NN

Table6.2:ExpansionofTable6.1
SixteencasesarerepresentedinTable6.1,andnocaseappearstwice.
Consequently,theflowgraphappearstobecompleteandconsistent.
Asafirstcheck,beforeyoulookforallsixteencombinations,countthenumberofY's
andN'sineachrow.Theyshouldbeequal.Wecanfindthebugthatway.
ANOTHEREXAMPLEATROUBLESOMEPROGRAM:
ConsiderthefollowingspecificationwhoseputativeflowgraphisshowninFigure6.5:
1.If conditionA is met, do processA1 no matter what other actions are taken
orwhatotherconditionsaremet.
2.If condition B is met, do processA2 no matter what other actions are taken
orwhatotherconditionsaremet.
3.If condition C is met, do processA3 no matter what other actions are taken
orwhatotherconditionsaremet.
4.Ifnoneoftheconditionsismet,thendoprocessesA1,A2,andA3.
5.When more than one process is done, processA1 must be done first, then
A2, and thenA3. The only permissible cases are: (A1), (A2), (A3), (A1,A3),
(A2,A3)and(A1,A2,A3).
Figure6.5showsasampleprogramwithabug.

Figure6.5:ATroublesomeProgram
The programmer tried to force all three processes to be executed for the
cases
but forgot that the B and C predicates would be done again, thereby bypassing
processesA2andA3.

Table6.3:DecisionTableforFigure6.5

http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

5/13

5/6/2016

TOP
PATHEXPRESSIONS:

TOP
GENERAL:
Logicbased testing is structural testing when it's applied to structure (e.g., control
flowgraph of an implementation) it's functional testing when it's applied to a
specification.
Inlogicbasedtestingwefocusonthetruthvaluesofcontrolflowpredicates.
Apredicateisimplementedasaprocesswhoseoutcomeisatruthfunctionalvalue.
Forourpurpose,logicbasedtestingisrestrictedtobinarypredicates.
WestartbygeneratingpathexpressionsbypathtracingasinUnitV,butthistime,our
purpose is to convert the path expressions into boolean algebra, using the predicates'
truthvalues(e.g.,Aand )asweights.
BOOLEANALGEBRA:
STEPS:
1.Labeleachdecisionwithanuppercaseletterthatrepresentsthetruthvalueof
the predicate.TheYES orTRUE branch is labeled with a letter (sayA) and
theNOorFALSEbranchwiththesameletteroverscored(say ).
2.Thetruthvalueofapathistheproductoftheindividuallabels.Concatenation
or products mean "AND". For example, the straightthrough path of Figure
6.5, which goes via nodes 3, 6, 7, 8, 10, 11, 12, and 2, has a truth value of
ABC.Thepathvianodes3,6,7,9and2hasavalueof
.
3.Iftwoormorepathsmergeatanode,thefactisexpressedbyuseofaplus
sign(+)whichmeans"OR".

Figure6.5:ATroublesomeProgram
Using this convention, the truthfunctional values for several of the nodes can be
expressed in terms of segments from previous nodes. Use the node name to identify
thepoint.

There are only two numbers in boolean algebra: zero (0) and one (1). One means
"alwaystrue"andzeromeans"alwaysfalse".
RULESOFBOOLEANALGEBRA:
Booleanalgebrahasthreeoperators:X(AND),+(OR)and (NOT)
http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

6/13

5/6/2016

X : meaningAND.Also called multiplication.A statement such asAB (A X

B) means "A and B are both true". This symbol is usually left out as in
ordinaryalgebra.
+:meaningOR."A+B"means"eitherAistrueorBistrueorboth".
meaning NOT. Also negation or complementation. This is read as either
"notA"or"Abar".Theentireexpressionunderthebarisnegated.
Thefollowingarethelawsofbooleanalgebra:

Inalloftheabove,alettercanrepresentasinglesentenceoranentirebooleanalgebra
expression.
IndividuallettersinabooleanalgebraexpressionarecalledLiterals(e.g.A,B)
Theproductofseveralliteralsiscalledaproductterm(e.g.,ABC,DE).
An arbitrary boolean expression that has been multiplied out so that it consists of the
sumofproducts(e.g.,ABC+DEF+GH)issaidtobeinsumofproductsform.
Theresultofsimplifications(usingtherulesabove)isagaininthesumofproductform
and each product term in such a simplified version is called a prime implicant. For
example,ABC+AB+DEFreducesbyrule20toAB+DEFthatis,ABandDEFare
primeimplicants.
ThepathexpressionsofFigure6.5cannowbesimplifiedbyapplyingtherules.
Thefollowingarethelawsofbooleanalgebra:

Similarly,

http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

7/13

5/6/2016

Thedeviationfromthespecificationisnowclear.Thefunctionsshouldhavebeen:

Loops complicate things because we may have to solve a boolean equation to determine what
TOP
KVCHARTS:

INTRODUCTION:
downinthealgebraandmakeasmanyerrorsindesigningtestcasesastherearebugs
intheroutineyou'retesting.
KarnaughVeitchchartreducesbooleanalgebraicmanipulationstographicaltrivia.
Beyondsixvariablesthesediagramsgetcumbersomeandmaynotbeeffective.
SINGLEVARIABLE:
Figure 6.6 shows all the boolean functions of a single variable and their equivalent
representationasaKVchart.

Figure6.6:KVChartsforFunctionsofaSingleVariable.
http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

8/13

5/6/2016

ThechartsshowallpossibletruthvaluesthatthevariableAcanhave.
A"1"meansthevariablesvalueis"1"orTRUE.A"0"meansthatthevariable'svalue
is0orFALSE.
Theentryinthebox(0or1)specifieswhetherthefunctionthatthechartrepresentsis
trueorfalseforthatvalueofthevariable.
Weusuallydonotexplicitlyputin0entriesbutspecifyonlytheconditionsunderwhich
thefunctionistrue.
TWOVARIABLES:
Figure6.7showseightofthesixteenpossiblefunctionsoftwovariables.

Figure6.7:KVChartsforFunctionsofTwoVariables.
Each box corresponds to the combination of values of the variables for the row and
columnofthatbox.
Anyvariablethatchangesineitherthehorizontalorverticaldirectiondoesnotappearin
theexpression.
In the fifth chart, the B variable changes from 0 to 1 going down the column, and
becausetheAvariable'svalueforthecolumnis1,thechartisequivalenttoasimpleA.
Figure6.8showstheremainingeightfunctionsoftwovariables.

http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

9/13

5/6/2016

Figure6.8:MoreFunctionsofTwoVariables.
separately.
Theyarewrittenusingaplussign.
Itisclearnowwhytherearesixteenfunctionsoftwovariables.
EachboxintheKVchartcorrespondstoacombinationofthevariables'values.
That combination might or might not be in the function (i.e., the box corresponding to
thatcombinationmighthavea1or0entry).
Since n variables lead to 2n combinations of 0 and 1 for the variables, and each such
n

1

Consequently for one variable there are 22 = 4 functions, 16 functions of 2 variables,

256functionsof3variables,16,384functionsof4variables,andsoon.
Giventwochartsoverthesamevariables,arrangedthesameway,theirproductisthe
termbytermproduct,theirsumisthetermbytermsum,andthenegationofachartis
gottenbyreversingallthe0and1entriesinthechart.

OR

http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

10/13

5/6/2016

THREEVARIABLES:
KVchartsforthreevariablesareshownbelow.
As before, each box represents an elementary term of three variables with a bar
0or1.
Athreevariablechartcanhavegroupingsof1,2,4,and8boxes.
Afewexampleswillillustratetheprinciples:

http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

11/13

5/6/2016

Figure6.8:KVChartsforFunctionsofThreeVariables.
You'll notice that there are several ways to circle the boxes into maximumsized
coveringgroups.
FOURVARIABLESANDMORE:
Thesameprinciplesholdforfourandmorevariables.

TOP

TOP
SPECIFICATIONS:

TOP

TOP
SUMMARY:

TOP

TOP

http://www.mcr.org.in/sureshmudunuri/stm/unit6.php

12/13

5/6/2016