0% found this document useful (0 votes)
8 views

Ebook Software Testing

Uploaded by

rumanhashmi92
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Ebook Software Testing

Uploaded by

rumanhashmi92
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 89

Software Testing methodologies

Paths, Path products and


UNIT-4
Regular Expressions: Path products & path expression,
reduction procedure,
Applications, regular expressions & flow anomaly detectron.
1ogic Based Testing: Overview. decision tables.
path expressions kv charts, specifications.

Q. PATH PRODUCTS AND PATH EXPRESSION:


Path expressions is an
algebraic representations of sets of paths in a graph.
Path Expressions are converted into
structural properties of flow
Regular Expressions that can be used to examine
data flow anomaly can occur
graphs such as the number of
paths, processing time or whether

MOTIVATION:
Flow graphs
bcing an abstract representation of programs.
are

Any question about a program can be cast into an equivalent question about an
appropriate
flowgraph.
Most software development, testing and debugging tools use flow graphs analysis
techniques.
PATH PRODUCTS:
Normally flow graphs used to denote only control flow connectivity.
The simplest weight we can give to a link is a name.
Using link names as weights, we then convert the graphical flow graph into an equivalent
algebraic like expressions which denotes the set of all possible pathsfrom entry to exit for the
tlow graph.
Every link of a graph can be given a name.
The link name will be denoted by lower case italic letters.
In tracing a path or path segment through a flow graph, you traverse succession
names.
a
oflink
The name ofthe path or path segment that corresponds to those links is expressed naturally
by concatenating those link names.
For example, if you traverse links a.b,c and d along some path, the name for that path
segment is abcd. This path name is also called apath product.
eact eadf, ebct ebdt

abccie, abgifdcde, abcdim fbode


(

ac. abx, abbc. abbbe, abbbbe

oba, abctd, abcbcbd, sbcdcdcdd

td
Examples of paths.
PATH EXPRESSION:
Consider a pair of nodes in a graph and the set of paths between those node.
Denote that set of paths by Upper case letter such as X,Y. From Figure c, the members of
the path set can be listed as follows: ac, abc, abbc, abbbc, abbbbc.

Alternatively, the same set of paths can be denoted by


actabc+abbctabbbc+abbbbct... ..

The + sign is understood to mean "or" between the two nodes of interest, paths ac, or abc,
or abbc, and so on can be taken.

Any expression that consists of path names and "OR"'s and which denotes a set of paths
between two nodes is called a "Path Expression."
PATH PRODUCTS: The name of a path that consists of two successive path segments is
conveniently expressed by the concatenation orPath Productof the segment names
For example, if X and Y are defined as X-abcde,Y=fghij.then the path corresponding to X
followed by Y is denoted by XY abcdefghij

Similarly
YX=fghijabcde
aX aabcde
Xa-abcdea
XaX-abcdeaabcde
I f X and Y represent sets of paths or path expressions, their product represents the set of
paths that can be obtained by following every clement of X by any element of Y in all
possible ways.
For example.
X abc + def+ ghi Y =uvw +z Then.
XY abcuvw+ defuvw+ ghiuvw + abcz + defz + ghiz
If a link or segment name is repeated, that fact is denoted
by an
exponent
The exponent's value denotes the number of repetitions
al= a, a2- aa. a3 n times. Similarly, if
aaa: an= aaaa
X abcde then X1=abcde
X2- abcdeabcde = (abcde)2

X3 abcdeabcdeabecde =(abcde)2abcde= abcde(abcde)2 (abede)3


The path product is not commutative(that is XY!=YX)
The path product is Associative.RULE TA(BC)(ABC-ABC
where A,B.C are path names, set of path names or path expressions
PATH SUMS:
PATH SUMS: The "+"
sign was used to denote the fact that
path names were of the
same set of
paths. part
The "PATH SUM" denotes
paths in parallel between nodes.
If XandY are sets of paths that lie between the same
UNION of those set of paths. For pair of nodes, then X+Y denotes the
example,
The first set of parallel paths is denoted by X +Y +d and the second set by U +V + W+h,
+i+j. The set of all paths in this flowgraph is
f(X+ Y + d)g(U + V +W+h+i +j)k
The path is set union
a
operation, it is clearly Commutative and Associative.
DISTRIBUTIVE LAWS:
The product and sum operations are distributive, and the
apply: that is
ordinary rules of multiplication

RULE 4: A(B+C)=AB+AC and (B+C)D=BD+CD


Applying these rules to the below Figure (a) yields

e(a+b)(c+d)f-e(ac+ad+bc+bd)feacf+eadftebcf+ebdf
ABSORPTION RULE:
I f X and Y denote the same set of paths, then the union of these sets is unchanged,
consequently,
RULE 5: X+X=X (Absorption Rule)
For example,
ifX-ataatabc+abcd+defthenX+a =X+aa =X+abc =
X+abcd =X+def =X

LOOPS:
Loops can be understood as an infinite set of parallel paths. Say that the loop consists of a
single link b. then the set of all paths through that loop point is
b0+b1+b2+b3+b4+b5+.. °*°°°°°**'

Example
This potentially infinite sum is denoted by b* for an individual link and by X* when X is aa
path

This potentially infinite sum is denoted by b* for an individual link and by X* when X is a path expression.
The path expression for the above figure is denoted by the notation:
ab'eact+abctabbe+abbbe+.
Evidently. aa*=a*a=at and XX*=X*X=X+

2. REDUCTION PROCEDURE ALGORITHM


This section presents a reduction procedure for converting a flowgraph whose links are
abeled with names into a path expression that denotes the set of all entry/exit paths in that
lowgraph The procedure is a node-by-node removal algorithm.
The steps in Reduction Algorithm are as follows:
1. Combine all serial links by multiplying their path expressions.

2. Combine all parallel links by adding their path expressions.


3. Remove all self-loops (from anynode to itself) by replacing them with a link of the form
X*, where X is the path expression of the link in that loop.

STEPS 4-8 ARE IN THE ALGORIHTM'S LOoP:

4. Select any node for removal other than the initial or final node. Replace it with a set of
equivalent links whose path expressions correspond to all the ways you can form a product
of the set of inlinkswith the set of outlinksof that node.
5. Combine any remaining serial links by multiplying their path expressions
6. Combine all parallel links by adding their path expressions.

7. Remove all self-loops as in step 3.


8. Does the graph consist of a single link between the entry node and the exit node? If yes.
then the path expression for that link is a path expression for the original flowgraph
otherwise, retum to step 4.
A flowgraph can have many equivalent path expressions between a given pair of nodes; that
is. there are many different ways to generate the set of all paths between two nodes without
affecting the content of that set.
The appearance of the path expression depends. in general, on the order in which nodes are
removed
C

Fromtheabove diagranm, one can infer: (a +b)(c+d+e) = ac + ad + + ae + bc +bd + be


LOOP REMOVAL OPERATIONS:
There are two ways of looking at the
loop-removaloperation:
Z X

A REDUCTION PROCEDURE EXAMPLE:

3 5
a
9

TOOT
m

Remove node 10 by applying step 4 and combine by step 5 to yield

OQQ-Q*-O
10
.Remove node 9 by applying step4 and 5 to yield,

ilh
kh

10
im

Remove node 7 by steps 4 and 5, as follows,

ilh
if kh
9 10
imf

Remove node 8 by steps 4 and 5, to obtain,

9jf gkh
ilh

8 10

imt
Parallel Term: combine them to create a path expression for equivalent link whose
an path
expression is c+gkh; that is,

Loop Term: Removing node 4 leads to a loop term.


bgif
b(c+gkh)
4
2
ilh

imf

Continue the process by applying the loop-removal step as followS:

bgif)"b(c+gkh)
3
ilh
imf

Removing node 5 produces:

ilhd

3)bgin"bfc+gkh)d

imf
Remove the loop at node 6 to yield:

(bain b(c+gkh)d lhd)2D


hd)"
(ilhd) imf
Remove node 3 to yield:
a(bgj*b(c+gkh)d (ilhd)"e
)
(ilhd) imf (boír) b(c+gkh)d
Removing the loop and then node 6 result in the following expression:
a(bgj)*b(e+gkh)d(ilhd) imf(bjg)*b(c+gkh)d)*(ilhd)*e

Q.APPLICATIONS:
The purpose of the node removal algorithm is to present one very generalized concept- the
path expression and way of getting it.
Every application follows this common
pattern:
Convert the program or graph into a path expression.
2. Identify a property of interest and derive an appropriate set of "arithmetic" rules that
characterizes the property.
3. Replace the link names by the link weights for the property of interest. The path
expression has now been converted to an expression in some algebra,

such as ordinary algebra, regular expressions, or boolean algebra. This algebraic expression
summarizes the property of interest over the set of all paths.
4. Simplify or evaluate the resulting "algebraic" expression to answer the question you
asked.

Q.REGULAR EXPRESSIONS AND FLOW ANOMALY DETECTION:


THE PROBLEM:
The generic flow-anomaly detection problem (note: not just data-flow anomalies, but any
flow anomaly) is that of looking for a specific sequence of options considering all possible
paths through a routine.
Let the operations be SET and RESET, denoted by s and r respectively, and we want to
know if there is a SET followed immediately a SET or a RESET followed immediately by a
RESET (anssoranrrsequence).

Somemore application examples:


1. A file can be opened (o), closed (c), read (r), or written (w). If the file is read or written to
after it's been closed, the sequence is nonsensical. Therefore,crandcware anomalous.
:Similarly, if the file is read before it's been written, just after opening, we

may have a bug. Therefore,oris also anomalous. Furthermore.ooandce, though not actual
bugs, are a waste of time and therefore should also be exanmined.
2. A tape transport can do a rewind (d), fast-forward (), read (r), write (w), stop (p), and skip
(k). There are rules concerning the use of the transport; for example, you cannot go from
rewind to fast-forward without an intervening stop or from rewind or
fast-forward to read or
write without an intervening stop. The following sequences are anomalous:df.dr.dwfd, andfr.
Does the flowgraph lead toanomalous sequences on any path? If so, what sequences and
under what circumstances?
3 The data-flow anomalies discussed in Unit 4 requires us to detect thedd,dk,kk,
andkusequences. Are there paths with anomalous data flows?

THE METHOD:
Annotate cach link in the graph with the appropriate operator or the null operator 1.
Simplity things to the extent possible, using the fact that a + a= a and 12 1 .
You now have a regular expression that denotes all the possible sequences of operators in
that graph. You can now examine that regular expression for the sequences of interest.
EXAMPLE: Let A, B, C, be nonempty sets of character sequences whose smallest string
is at least one character long. Let T be a two-character string of characters. Then if T is a
Substring of (ie., if T appears within) ABnC, then T will appear in AB2C. (HUANG's
Theorem)

Asan example, let

A pp
B sIT
CP
T= ss
The theorem states that ss will appear in pp(srr)nrp if it appears in pp(srr)2rp.
However, let
A p t pp +
ps
B psr +
ps(r + ps)
Cp
T P4
Is it obvious that there is a p4 sequenee in ABnC? The thcorem states that we have only to
look t
(pt pp ps]psr +ps(r+ ps)|2rp
Multiplying out the espression and simplilying shows that there is no p4 sequence.
Incidentally. the above observation is an informal proof of the wisdom of' loop1ng twice
discussed in Unit 2. Because data-low anomalies are represented by two-character
scquences, it tollows the bove theorem that looping twice is what you need to do to find
such anoalies.
LIMITATIONS:
1lang's theorem can be easily generalized to cover sequences of greater length than two
characters. Beyond three characters, though, things get complex and this method has
probably reached its utilitarian limit for manual application.
There are some nice theorems for finding sequences that occur at thebeginnings and ends
of strings but no nice algorithms for finding strings buried in an expression.
Static low analysis methods can't determine whether a path is or is not achievable. Unless
the tlow analysis includes symbolic execution or similar techniques, the impact of
unachievable paths will not be included in the analysis.
The low-anomaly application, for example, doesn't tell us that there will be a flow
anomaly -it tells us that if the path is achievable, then there will be a flow anomaly. Such
analytical problems go away, of course, if you take the trouble to design routines for which
all paths are achievable.

LOGICBASED TESTING: OVERVIEW OF LOGICBASED TESTING


."Logic" is one ofthe most often used words in programmers' vocabularies but one
of their least used techniques.
.Logic has been, for several decades, the primary tool of hardware logic designers.
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 ground for software testing methods.
A s programming and test techniques have improved, the bugs have shifted closer
to the process front end, to requirements and their specifications. These bugs
range from 8% to 30% of the total and because they're first-in and last-out,

they're the costliest of al.


Higher-order logic systems are needed and used for formal specifications.
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 large extent based on boolean algebra.
KNOWLEDGE BASED SYSTEM: o The knowledge-based system (also expert
system, or "atificial intelligence" system) has become the programming construct
of choice for many applications that were once considered very difficult. o
Knowledge-based 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 domain. o
One implementation of knowledge-based systems is to incorporate the expert's
knowledge into a set of rules. The user can then provide data and ask questions
based on that data. o The user's data is processed through the rule base to yield
conclusions (tentative or definite) and requests for more data. The processing is
done by a program called the inference engine. o Understanding knowledge-
based systems and their validation problems requires an understanding of formal
logic. Decision tables are extensively used in business data processing; Decision-
table preprocessors as extensions to COBOL are in common use; boolean
algebra
is embedded in the implementation of these processors

QWhat is Decision Table in Software Testing? , m


A decision table is a good way to deal with different combination inputs with their associated
outputs. It is a black box test design technique to determine the test scenarios for complex
business logic. In this article, know more about how the decision table in software testing helps in
testdesign technique in the following sequence
What is Decision Table in Software Testing?
.Why is Decision Tableimportant?
Advantages of Decision Table in Software Testing
Way to Use Decision Table: Example

What is Decision Table in Software Testing?


The decision table is a software testing technique which is used for testing the system behavior for
different input combinations. This is a systematic approach where the different input combinations
and their corresponding system behavior are captured in a tabular form.

This table helps you deal with different combination inputs with their associated outputs. Also, it is
known as the cause-effect table because of an associated logical diagramming technique called
cause-effect graphing that is basically used to derive the decision table.

Why is Decision Table lImportant?A decision table is an outstanding technique N


used for testing and requirements management. Some of the reasons why the decision table is
important include:
Decision tables are very much helpful in test design technique.
t helps testers to search the effects of combinations of different inputs and other software
states that implement business rules.
t provides a regular way of stating complex business rules which benefits the developers
as well as the testers.
It assists in the development process with the developer to do a better job. Testing with all
combination might be impractical.
It the most preferable choice for testing and requirements management.
It is a structured exercise to prepare requirements when dealing with complex business
rules
. I t is also used in model complicated logic.

Advantages of Decision Table in Software Testing


There are different advantages of using the decision table in software testing such as:

Any complex business flow can be easily converted into the test scenarios & test cases
using this technique.
Decision tables work iteratively. Therefore, the table created at the first iteration is used as
the input table for the next tables. The iteration is done
only if the initial table is not
satisfactory.
Simple to understand and everyone can use this method to
design the test scenarios&
cases.
test
Itprovides complete coverage of test cases which help to reduce the rework on writing test
scenarios & test cases.
These tables guarantee that we consider every
possible combination of condition values.
This is known as its completeness property.

Way to use Decision Table: Example ye


A Decision Table is tabular
a
representation of inputs versus rules, cases or test conditions.
Let's take an example and see how to create a decision table for a login screen:

Let's Get Starteci

Forgot ?

Login
D o r t have an acCOunt? Sign Up

The condition states that if the user


redirected to the homepage. If
provides the correct username and password the user will be
any of the input is wrong,
an error
message will be displayed.
Conditions Rule 1 Rule 2 Rule 3 Rule 4
Username F T F T
Password
T
Output E E E H
In the above
example,
T-Correct username/password
F-Wrong username/password
E -

Error message is
displayed
H Home screen
is displayed
Now let' s understand the
interpretation of the above cases:
Case 1- Username and
password both were wrong. The user is shown an error message
Case 2-Username was correct, but the
password was wrong. The user is shown an error
message
Case 3- Username was wrong, but the password was correct. The user is shown an error
message.
Case 4- Username and password both were correct, and the user is navigated to the
homepage
So, this was an example of building a decision table in software
the end of this article. testing. with this we have come to

Now that you have understood Decision Table in Software


Testing, check out the Software
Testing Fundamentals Course by Edureka. This course is designed to introduce to the
complete software testing ife-cycle. You will be learning different levels of you
environment setup, test case design technique, test data creation, test execution, testing, test
Ci/CD pipeline in DevOps, and other essential concepts of software bug reporting,
testing
Q.PATH EXPRESSIONS: che
GENERAL:

.
Logic-based 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.
.In logic-based testing we focus on the truth values of control flow
predicates
A predicate is implemented as a process whose outcome is a
truth-functional value.
For our purpose, logic-based testing is restricted to binary
predicates.
.We start by generating path expressions by path tracing as in
Unit V, but this time, our purpose is to convert the
path
expressions into boolean algebra, using the predicates' truth
values (e.g., A and ä) as weights.
. KV CHARTS:INTRoDUCTION:

I f you had to deal with expressions in four, five, or six variables, you could
get bogged down in the algebra and make as many errors in designing
test cases as there are bugs in the routine you're testing.
Karnaugh-Veitch chart reduces boolean algebraic manipulations to
graphical trivia.
Beyond six variables these diagrams get cumbersome and may not be
effective.
.SINGLEVARIABLE:
o Figure 6.6 shows all the boolean functions of a single variable and
their equivalent representation as a KV
chart

0 The function is never true

0 The function is true when A is true

The function is true when A is false

The function is aiways true

Figure 6.6: KV Charts for Functions of a Single Variable.

o The charts show all possible truth values that the variable A can
have.
o A "1" means the variable's value is "1" or TRUE. A "O" means that
the variable's value is 0 or FALSE.
o The entry in the box (0 or 1) specifies whether the function that the
LO
chart represents is true or false for that value of the variable.
oWe usually do not explicitly put in 0 entries but specify only the
conditions under which the function is true.
.TWOVARIABLES:
o Figure 6.7 shows eight of the sixteen possible functions of two
variables

AB NANO AB A Md o: 8

AB 8 nd not A A8 Amd 8

:
Figure 6.7: KV Charts for Functions of Two Variables.

o Each box corresponds to the combination of values of the variables


for the row and column of that box.
A pair may be adjacent either horizontally or vertically but not
diagonally.
Any variable that changes in either the horizontal or vertical
direction does not appear in the expression.
o In the fifth chart, the B variable changes from 0 to 1 going down the
column, and because the A variable's value for the column is 1, the
chart is equivalent to a simple A.
Figure 6.8 shows the remaining eight functions of two variables.

O
AB AB AB AB
A ANO ONY F8 ExCLUSIvE OR

A 8 A 8
OR A IMPLIES 8

A 8 A
8MPLIES A

UNIVEASAL ALSE UNiVERSAL TRUE

Figure 6.8 ; More Functions of Two Variables.

oThe first chart has two 1's in it, but because they are not adjacent,
each must be taken separately.
They are written using a plus sign.
o It is elear naw why there are sixteen functions of two variables
WwtaAERtrer LENTUnctions
Each BeX IA he OAEPtaerESPends. to a combination of the
varlables valHes r t corresponds of two
oThat combinatioh might or might not Be Irfthernotiao(iaDe box variables
corresponding to that combination might h¡ve a 1 or 0 entry)
Since n variables lead to 2" combinations of 0 and 1 for the
variables, and each such combination (box) can be filled or not
filled, leading to 2" ways of doing this.
o Consequently for one variable there are 22 = 4 functions, 16
functions of 2 variables, 256 functions of 3 variables, 16,384
functions of 4 variables, and so on.
Given fwo charts over the same variables, arranged the same way.
their product is the term by term product, their sum is the term by
term sum, and the negation of a chart is gotten by reversing all the
O and 1 entries in the chart.

A AB A B

OR

THREE VARIABLES:
o KV charts for three variables are shown below.
o As before, each box represents an elementary term of three
variables with a bar appearing or not appearing according to
whether the row-column heading for that box is 0 or 1.
A three-variable chart can have groupings of 1, 2, 4, and 8 boxes.
o A few examples will illustrate the principles:
8

Page 1 9
AB AD
01 1
01

AB
10 00 01

10 01

A 8C t

Figure 6.8: KV Charts for Functions of Three Variables.

o Yo'll notice that there are several ways to circle the boxes into
maximum-sized covering groups.
FOUR VARIABLES AND MORE:
O The same principles hold for four and more variables.

Q.What is Specification Based Testing?


Specification Based Testing Technique is also known as Behavior Based Testing and Black
Box Testing techniques because in this testers view the software as a black-box. As they have no
knowiedge of how the system or component is structured inside the box. In essence, the tester is
only concentrating on what the software does, not how it does it.
Both Functional Testing and Non-Functional Testing is a type of Specification Based Testing.
Specification Based Test Design Technique uses the specification of the program as the point
of reference for test data selection and adequacy. A specification can be anything like a written
document, collection of use cases, a set of models or a prototype
Tyres of Specification Based Testing Techniques
1. Equivalence Partitioning: Software Testing technique that divides the input data ofa
software unit into partitions of equivalent data from which test cases can be derived Learn
2 Boundary
More Value Analysis: Software Testing technigque in which tests are designed to
include representatives of boundary values in a range
3. Decision Tables: Software Testing technique in which tests are more focused on
business logic or business rules. A decision table is a good way to deal with combin ations
of inputs
State Transitioning: Software Testing technique which is used when the system is
defined in terms of a finite number of states and the transitions between the states is
govemed by the rules of the system.
UNIT Y
UNIT-V
STATES, STATE GRAPHS, AND TRANSITION TESTING
State, State Graphs and Transition testing: State graphs, good & bad state graphs state testing, Testability tips.
Graph Matrices and Application: Motivational overview, matrix of graph, relations, power of a matrix, Node
reduction algorithm. building tools. (Student should be given an exposureto a tool like J Mcter or Win runner.)

Introduction

The finite state machine is as fundamental to software engineering as boolean algebra to logic.
State testing strategies are based on the use of finite state machine models for software structure,
software behavior, or specifications of software behavior.
Finite state machines can also be implemented as table-driven software, in which case they are a
powerful design option.
State Graphs
A state is defined as: *A combination of circumstances or attributes belonging for the time being to a
person or thing."
For example, a moving automobile whose engine is running can have the following states with respect to
its transmission.
Reverse gear
Neutral gear
First gear
Second gear
Third gear
Fourth gear

State graph - Example

For example, a program that detccts the character sequence "ZCZC" can be in the following states.
Neither ZCZC nor any part of it has been detected.
Z has been detected.
ZC has been detected.
ZCZ has been detected
ZCZC has been detected.

A,C A,C 2,C,A

None

States are represented by Nodes. State are numbered or may identified by words or whatever else is
convenient.

Inputs and Transitions


Whatever is being modeled is subjected to inputs. As a result of those inputs, the state changes, or is
said to have made a Transition.
.Transitions are denoted by links that join the states.
.The input that causes the transition are marked on the link, that is, the inputs are link weights.
. There is one out link from every state for every input.
f several inputs in a state cause a transition to the same subsequent state, instead of drawing a bunch
ofparallel links we can abbreviate the notation by listing the several inputs as in: "inputl, input2,
input..
Finite State Machine
A finite state machine is an abstract device that can be represented by a state graph having a finite
number of states and a finite number of transitions between states.
Outputs
An output can be associated with any link.
Out puts are denoted by letters or words and are separated from inputs by a slash as follows:
"input output".
As always. output denotes anything of interest that's observable and is not restricted to explicit
outputs by devices.
Outputs are also link weights.
Ifevery input associated with a transition causes the same output, then denoted it as:
"input1, input2, input3............/output
State Tables

Big state graphs are cluttered and hard to follow.


It's more convenient to represent the state
graph as a table (the state table or state transition table)
that specifies the states, the inputs, the transitions and the
outputs.
The following conventions are used:
Each row of the table corresponds to a statc.
Each column corresponds to an input condition.
The box at the intersection of a and column
row a
specifies the next state (the transition) and the
output, if any.

State Table-Examplee

inputs
STATE Z C A
NONE Z NONE NONE
Z ZC NONE
ZC ZCZ NONE NONE
ZCZ z ZCZC NONE
ZCZC ZCZC ZCZC ZcZC

Time Versus Sequence


State graphs don't represent time-they
represent sequence.
A transition might take microseconds or
centuries;
A system could be in one state for milliseconds and another
same because it has no notion of time.
for years-the state graph would be the (2
Although the finite state machines model carn be elaborated to include notions of time in addition to
sequence, such as time Petri Nets.
Software implementation
There is rarely a direct correspondence between programs and the behavior of a process described as
a state graph.
The state graph represents, the total behavior consisting of the transport, the software, the executive,
the status returns, interrupts, and so on.
There is no simple corespondence between lines of code and states. The state table forms the basis.

Good State Graphs and Bad


.What constitutes a good or a bad state graph is to some extent biased by the kinds ofstate graphs that
are likely to be used in a software test design context.
Here are some principles for
judging
The total number of states is equal to the product of the possibilities of factors that make up the state.
For every state and input there is exactly one transition specified to exactly one, possibly the same,
state.
For every transition there is one output action specified. The output could be trivial, but at least one
output does something sensible.
For every state there is a sequence of inputs that will drive the system back to the same state.

Important graphs
State Bugs-Number of States
The number of states a state graph is the number of states we choose to recognize or model.

1,2
State c a n n e v e r be left, t h e initial s t a t e c a n
n e v e r b e e n t e r e d againn

State C cannot be entered.

1,2S t a t e s A and B are not reachable

1,2 Two transitions are specified for


a n inpput of 1 in s t a t e A

The state is directly or indirectly recorded as a combination of values of variables that appear in the
data base.
For example, the state could be composed of the value of a counter whose possible values ranged
from 0 to 9, combined with the setting of two bit flags, leading to a total of 2*2*10=40 states.
The number of states can be computed as follows:
ldentify all the component factors of the state.
Identify all the allowable values for each factor.
The number of states is the product of the number of allowable values of all the factors.
Before you do anything else, before you consider one test case, discuss the number of states you
think there are with the number of states the programmer thinks there are.
There is no point in designing tests intended to check the system's behavior in various states if
there's no agreement on how many states there are.
Impossible States
Some times some combinations of factors may appear to be impossible.
The discrepancy between the programmer's state count and the tester' s state count is often due to a
difference of opinion concerning "impossible states".
A robust piece of software will not ignore impossible states but will recognize them and invoke an
illogical condition handler when they appear to have occurred.
(3
Equivalent States
Two states are Equivalent if every sequence of inputs starting from one state produces exactly the
same sequence of outputs when started from the other state. This notion can also be extended to set
of states.

Merging of Equivalent States

a,b

Recognizing Equivalent States


Equivalent states can be recognized by the following procedures:
The rows corresponding to the two states are idetical with respect to input output next state but the
name of the next state could differ.
There are two sets of rows which, except for the state names, have identical state graphs with respect
to iransitions and outputs. The two sets can be merged.

Transition Bugs- unspecified and contradictory Transitions


.Every input-state combination must have a specilied transition
If the transition is impossible, then there must be a mechanism that prevents the input from occurring
in that state.
Exactly one transition must be specificd for every combination of input and state
A program can't have contradictions or ambiguities.
Ambiguities are impossible because the program will do something for every input. Even the state
does not change, by delinition this is a transition to the same state.

Unreachable States
A n unreachable state is like unreachable code
A state that no input sequence can
reach
A n unreachable state is not
impossible, just as unreachable code is not impossible
There may be transitions from unreachable state to other states; there usually because the state
became unreachable as a result of incorrect transition.
There are two possibilities for unreachable states:
There is a bug; that is some transitions are missing.
The transitions are there, but you don't know about it.

Dead States
A dead state is a state that once entered cannot be left
This is not necessarily a bug but it is suspicious.
Output Errors

dead unreachable states,


The states, transitions, and the inputs could be correct, there could be no or

but the output for the transition could be incorrect.


Output actions must be verified independently of states and transitions

State Testing Impact of Bugs

If a routine is specitied as a state graph that has been verified as correct in all details. Program code
or table or acombination of both must still be implemented
A bug can symptoms
manifest itseif as one of the following
Wrong number of states.
Wrong transitions for a given state-input combiation
Wrong output for a given transition.
Pairs of states or sets of states that are inadvertently made equivalent.
States or set of states that are
split to create in equivalent duplicates.
States or sets of states that have become
dead.
States or sets of states that have become
unreachable.
Principles of State Testing
The strategy for state
testing is
analogous to that used for path testing flow graphs.
Just as it's
impractical to go through every possible path in a flow graph, it's impractical to
through every path ina state graph. go
The notion of
coverage is identical to that used for flow graphs.
ven though more state
testing is done as a single case in a grand tour, it's impractical to do it that
way for several reasons.
In the early
phases of testing, you will never complete the grand tour because of
Later, maintenance, testing
in bugs.
have to be tested. A
objectives are understood, and
only a few of the states and transitions
grand tour is waste of time.
Theirs is no much
history in a long test sequence and so much has happened that verification is
difficult.

Starting point of state testing


Define a set of covering input sequences that get back to the initial state when
initial state. starting from the
For each step in each
input sequence, define the expected next state, the expected transition, and the
expected output code.
A set of tests, then, consists
of three sets of sequences:
Input sequences
Corresponding transitions or next-state names
Output sequences
Limitations and Extensions
State transition coverage in a state
graph model does not guarantee complete testing.
How defines a hierarchy of
paths and methods for combining paths to produce covers of state graphs.
The simplest is called a "0 switch" which corresponds to testing each transition
The next level consists of testing transitions individually.
switches" sequences consisting of two transitions called "1
The maximum length switch is "n-1 switch" where there are n numbers of states.
Situations at which state testing is useful
Any processing where the output is based on the occurrence of one or more
such asdetection of specified input sequences of events,
situations in which the order of sequences, sequential format validation, parsing, and other
is inputs important.
Most protocols between systems, between humans and machines, between
Device drivers such as for tapes and discs that have components ofa system.
the state. Whenever a feature is complicated retry
action depends on and recovery procedures if the
more state transition tables. directly and explicitly implemented as one or
CHAPTER-II
GRAPH MATRICES AND APPLICATIONS

Problem with Pictorial Graphs


Graphs were introduced as an abstraction of software structure
Whenever a graph is used as a model. sooner or later we trace paths through it- to find a set of
covering paths, a set of values that will sensitize paths, the logic function that controls the flow, the
processing time of the routine, the equations that define the domain, or whether a state is reachable
or not
P'ath is not casy, and it's subjcct to crror You can miss a link here and there or cover some links
twice
One solution to this problem is to represent the graph matrix and to use matrix
as a
operations
cquivalent to path tracing. These methods are more methodical and mechanical and don't depend on
your ability to see a path they are more reliable

Tool Building
If you build test tools or want to know how they work, sooner or later you will be implementing or
investigating analysis routines based on these methods.
It is hard to build algorithms over visual graphs so the properties or graph matrices are fundamental
to tool building.

The Basic Algorithms


The basic tool kit consists of.
Matrix multiplication, which is used to get the path expression from every node to every other node.
A partitioning algorithm for converting graphs with loops into loop free graphs or equivalence
classes
A collapsing process which gets the path expression from any node to any other node.

The Matrix of a Graph


A graph matrix is a
square array with one row and one column for every node in the graph.
Each row-column combination corresponds to a relation between the node corresponding to the row
and the node corresponding to the column.
The relation for example, could be as simple as the link name, if there is link between the
a
nodes
Some of the things to be observed:
The size of the matrix equals the number of nodes.
There is a place to put every possible direct connection or link between any and any other node.
The entry at a row and column intersection is the link weight of the link that connects the two nodes
in that direction.
A connection from node i toj does not imply a connection from node j to node i.
Ifthere are several links between two nodes, then the entry is a sum; the**" sign denotes parallel
links as usual.

You might also like