GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
Gaur11428
1. Implementation of Algorithm for
Logic Based Testing
Dissertation
Submitted in fulfillment of the
Requirement for the award of the Degree
Master of Technology (IT)
Of
Banasthali Vidyapith
Jaipur Campus
2009-2011
Under The Supervision Of: Submitted By:
Mrs. Usha Badhera Priyanka Gaur
Astt. Professor(AIM & ACT) M.Tech. (IT)
Banasthali Vidyapith, Jaipur Campus Roll No. - 11428
2. Overview
• Logic Based Testing
• Cause Effect Graphing Technique
• Application of Genetic Algorithm in Software Testing
• Test cases
• Decision table
• Commonly used Process for CEG
• Analysis of Myer’s CEG Approach
• Possible Solution to Drawback of Myers’Approach
• Implementation of Converting a Cause Effect Graph into Decision-
Table
•Implementation of Algorithm on Cases
• Screenshots
• Advantages of CEG Technique
3. • Implementation of Algorithm on Cases
• Screenshots
• Advantages of CEG Technique
• Analysis of Previous and Implemented Algorithm
•Weighted Graph and Path Testing
• Genetic Algorithm
• Advantage of GA in Software Testing
• Generating Effective Test Cases with GA
• Code with weighted Control Flow Diagram
• Working of Algorithm for Control Flow Graph
• Results
• Conclusion
• References
4. Logic Based Testing
• The functional requirement of many programs can be specified by decision
table , which provide the useful basis for program and test case Design.
• Consistency and completeness can be analyzed by Boolean Algebra, which
can also be used as a basis for test Design.
• Logic based testing translates the specification that are dominated by logic
and combination of test cases into either Decision Table and develop
functional test cases from those representation.
• Cause Effect Graphing technique is used for develops test cases to
represents input events (Causes) and the corresponding actions(output).
5. Cause Effect Graphing Technique
• A cause Effect Graphing is basically a hardware testing technique
adapted to software testing .The CEG technique is a black box
method. This is a testing technique that aids in selecting test cases
that logically relate causes to effect to produce test cases.
• Cause – “A Cause is any distinct input condition in the
requirements that may affect the programs output. A cause is
always positive and atomic”.
• Effect – “An Effect is the response of the program to some
combination of input conditions”.
• Constraints - “ Constraint represent external constraints on the
system”.
6. Application of Genetic Algorithm in
Software Testing
• Automatic Test Case Generation. This Technique extends the random
testing by the use of genetic algorithm.
• GA technique can be applied for finding the most critical path for
software testing efficiency.
• The fitness function of GA for selecting the best possible Test Suit.
• This technique is useful where
(i) a program may contain an infinite number of paths when the
program has loops.
(ii) The number of paths in a program is exponential to the number of
branches in it and many of them is unfeasible.
(iii) the number of test cases is too large
It is impossible to cover all possible paths in Software, The problem
of path testing selects a subset of paths to execute and find test data
to cover it.
7. Decision table
• Test Cases: A Good test case is a test case whose chances to
finding a bug are more.
• A Decision Table is the method used to build a complete set of
test cases without using the internal structure of the program in
question. In order to create test cases we use a table to contain
the input and output values of a program.
Basically Decision Table has three parts:
• Condition stubs: Lists condition relevant to decision
• Action stubs: Actions that result from a given set of conditions
• Rules: Specify which actions are to be followed for a given set
of conditions.
8. Commonly used Process for CEG
The commonly used process for CEG can be described in the
following six steps:
• Step 1: Break the specification down into workable pieces.
• Step 2: Identify the causes and effects.
(a) Identify the causes and assign each one a unique number.
(b) Identify the effects or system transformation and assign each
one a unique number.
• Step 3: The semantic content of the specification is analyzed and
transformed into a Boolean graph linking the causes and effects.
This is the cause-effect graph.
9. Commonly used Process for CEG
• Step 4: Annotate the graph with constraints describing
combinations of causes and/or effects .
• Step 5: Methodically trace state conditions in the graphs,
converting them into a limited-entry decision table. Each column
in the table represents a test case.
• Step 6: The columns in the decision table are converted into test
cases.
11. Analysis of Myers’ CEG Approach
• Some inconsistencies in
Myers’ CEG Techniques-
i. Difficulty in
identifying causes &
effects because of their
vague description in
Natural language
specification .
ii. Error proneness based
on semantics of natural
language specification
12. Example – Send file Command
• Each column in the decision
table is converted into a test
case.
• Suppose file f, server r, and
user u are all correct
arguments, then the test case
derived from column 1 in the
decision table will be send and
the expected result is that file f
is successfully sent.
13. Problem in Myers’ approach -
Observation 1
• Tracing back through an and node
whose output should be 0 all
combination of input leading to a 0
output must be enumerated ,except in
the case where one input is 0 and one
or more of others are 1.
1) If we consider cause c is set to 1 all
the combinations of causes a and b
leading to output 0 at node d should
be considered.
2) Cause c is set to 1 only one situation
where output d is set to zero is
considered(in fig 2.4(c) ).
Ambiguity occurred which misleads
the user.
14. Observation 2
• Decision table is different If
the syntax is different of the
Cause Effect Graph but the
semantic is same.
• Therefore with these rules,
the set of test cases obtained
from CEG will depend on
how effect e is formulated
thus the rules contradict a
reasonable requirement for
logical inconsistency.
15. Observation 3
• When building a Decision table , if often happens that some
entries are left blank meaning that irrelevant for presence/
absent of given effect.
• Don’t care conditions are unspecified.
16. Observation 4
• Missing in the description in
of the CEG Technique is
nothing is said about verifying
conformance of CEG to its
corresponding-natural
language specification may
lead to faulty and incomplete
test cases.
17. Problems in Myers’ approach –
Observation 5
• Myers’ does not consider when deriving test cases is the forcing of
effects to be absent. He concentrate only on their present.
18. Possible Solution to Drawbacks in
Myers’Approach
• Cause Set – A cause set of an effect is the set of causes that can affect the
presence or absence of that effect.
• Path Sensitization Technique – In path sensitization Technique
combination of causes are derived from the CEG by sensitizing each
effect of the system to each cause in its corresponding cause set. The
combination of causes obtained can be used to derive actual test data
when the implementation of the system is tested
• Advantage of Path sensitization method:
• They all are algorithmic & they consist of Straightforward and
ambiguous rules for deriving a DT from a CEG.
19. Implementation of CEG into Decision-
Table
Procedure for generating a decision table from Cause-effect graph.
1. input: A template containing causes C1,C2.....Cp, effects
E1,E2.....Eq then relationship and constraints.
2. output: A decision table DT containing N = p + q rows and M
columns, where M depends on the relationship between the
causes –effect as captured in the cause effect graph.
Procedure CEG_TO_DT:
• Step 1: Read causes and effects from template and for each of the
effect construct binary tree that specifies that effect in terms of
cause’s relationship.
• Step 2: Initialize DT to an empty decision table.
• Step 3: For each of the E, Create Decision Table EDTi as empty
decision table.
20. Step 4: Execute the following steps for i=1 to q
4.1 – Select the next effect to be processed, Let e = E
4.2 – Starting at e, traverse the effect tree created in previously step and
identify the causes C1, C2 ........etc that are there in tree. Identify all
possible combinations of these causes that lead e to be present. Make
sure that the combinations satisfy any constraints.
4.3 – Add all these possible entries into the decision t able EDTi .
Step 5: Do OR-Operation between all effects that gives all combination of
effects do following:
5.1 Select the decision tables EDTi for all effects that are present in this
combination.
5.2 Take all possible combination of entries of different tables. In this
combination if there is a cause that is there in two or more effect
decision table then take combination in which.
5.3 Enter all these entries into decision table that satisfy all constrain.
End of Procedure: CEG_TO_DT
21. Implementation Of Algorithm On
Cases
We consider the following set of requirements for implementing the
algorithm:
Requirements for Calculating Car Insurance Premiums:
• r1 For females less than 65 years of age, the premium is $500
• r2 For males less than 25 years of age, the premium is $3000
• r3 For males between 25 and 64 years of age, the premium is $1000
• r4 For anyone 65 years of age or more, the premium is $1500
There are two variables that will determine what the premium will be:
Gender and age. Therefore there are 5 distinct causes or input conditions:
Sex is either male or female, and age is either less than 25, between 25
and 64 inclusive or 65 or more. There are also 4 distinct effects or output
conditions: the premium is$500, $1000, $1500, or $3000.
27. Advantages of CEG Technique
• CEG technique is a useful testing technique to test the
implementation of the system by using test cases derived from
the natural language specification of the system.
• Technique is valid only for Natural language specification that
satisfies the customer intention.
28. Analysis of Previous and Implemented
Algorithm
• In existing algorithm for each effect binary tree is
generated so complexity for finding all possible
combination is less in comparison with previous
algorithm. Algorithm given is not generating all
possible test cases in all case whereas our algorithm
generates all possible test cases in all the cases.
• Decision Table show in is generated by existing
algorithm which has all possible test cases where as
Decision Table generated according to previous
algorithm has less number of cases.
29. Weighted Graph and Path Testing
• Weighted Graph : A graph is a weighted graph if a number
(weight) is assigned to each edge. Such weights might
represent, for example, costs, lengths or capacities, etc.
depending on the problem. The weight of the graph is the sum
of the weights given to all edges.
• Path Testing : Testing in which all paths in the program source
code are tested at least once.
30. Genetic Algorithm
A genetic algorithm (GA) is a heuristic used in computer
science to find an approximate solutions to combinatorial
optimization problems. Genetic algorithms are a particular
class of evolutionary algorithms that use techniques inspired
by evolutionary biology such as inheritance, mutation, natural
selection, and recombination (or crossover).
31. Advantage of GA in Software-
Testing
• One major advantage of GA is that other searches do not cover ,is
that of a false solution. A problem may have several solutions, some
are better than others. If another type of search finds that one path is
worth pursuing, and discards the other, it may be leading to a
solution which is not best, or even not to solution at all.
• GA have several individuals in its population, each one of which
could be a potential solution to a problem. Which means that it is
even possible for the search to find more than one solution.
32. Generating Effective Test Cases
with GA
• The problem of test set generation is a typical optimization problem
in a combinatorial search space: we are looking for a minimal set of
test cases that are most likely to reveal faults presenting in a given
program.
• Representation: Each test case can be represented as a vector of
binary or continuous values related to the inputs of the tested
software.
• Initialization: An initial test set can be generated randomly in the
space of possible input values.
• Genetic Operators: Selection, crossover, and mutation operators can
be adapted to representation of test cases for a specific program.
• Evaluation function: Test cases can be evaluated by their fault-
exposing-potential using mutated versions of the original program.
33. Code with weighted Control Flow
Diagram 0. gcd(int m, int n)
{
int r;
1. if(n>m) {
2. r = m;
3. m = n;
4. n = r;
}
5. r = m % n ;
6. while(r!=0) {
7. m = n ;
8. n = r ;
9. r = m % n;
10. }
11. return n;
12. }
34. Working of Algorithm for Control
Flow Graph
• Selection : selection for parents for reproduction is done according
to probability distribution based on individual’s fitness values. First
the fitness value is calculated. Here X denotes the test data.
• F(x) : corresponding fitness value calculated for each data set, by
adding the weights of the path followed by it in the CFG.
n
• F=∑ Wi (where Wi weight assigned to ith edge on the path under consideration)
i=1
• Probability of selection pj for each path j
• Pj = F(xi)/ ∑ F(xi) (where i=1 to n and n = initial population size)
k
• Calculate cumulative probability Ci = ∑ pj
j=1
35. • Ran: Random number generated for the test data
• Ns : Test data numbers that has cumulative probability just greater
than the corresponding random number.
• Mating pool : This column contains the number of times a test
data appears in the Ns column.
• Steps for carrying out cross over and mutation:
• Mutation: For each entry in the new data set, bit-wise random
number are generated. And for random number values less than
0.3, that corresponding bit is flipped to obtain a new data entry.
• Same procedure is carried out for the new data set obtained for
further crossover and mutation until we start getting better values
of the fitness function F(x).
36. Example 1: Initial population: (n, m) (15, 4), (5, 6), (6, 2), (4, 12)
Fitness function used: Summation of weights of path traversed by
a given input data in CFG For example (15, 4) will travel the path
0-1-2-3-4-5-6-7-8-9-6-7-8-9-6-10-11-12 and therefore its fitness
value is 108 Since the mating pool consists of only (15, 4) therefore
this is the test data that should be used for the testing of the code
during execution. This is because the mating pool depicts the
population that will mate in the next iteration. Here since the only
value in mating pool is (15, 4), this shows that no further
improvement in the fitness function value can be achieved with
further reproduction and mutation. Thus (15, 4) is the test data that
should be used as input for software testing.
40. S.No X F(x) Pi Ci Ran Ns Mating
pool
1 (4,3) 76 0.178 0.178 0.098 1 1
2 (7,12) 170 0.399 0.577 0.275 2 3
3 (13,10) 106 0.249 0.826 0.325 2 0
4 (2,6) 74 0.174 1.000 0.487 2 0
Iteration 4: Table 13
Result : From the Table 13 the optimized path 170 because its rank is high which is 3.
41. Conclusion
• The goal is to validate the informal specification is well. We
developed a tool to derive the decision table and the customer-
directed scenarios automatically from a given Cause-Effect Graph
specification. The CEG is input in a text format; our tool gives
outputs the decision table and the customer directed scenarios.
• we applied some optimization approach for more effective software
Testing. Genetic algorithms are often used for optimization
problems in which the evolution of a population is a search for a
satisfactory solution given a set of constraints.
• We have demonstrated that it is possible to apply Genetic Algorithm
techniques for finding the most critical paths for improving software
testing efficiency. The Genetic Algorithms also outperforms the
exhaustive search and local search techniques.
42. References
[1] Aditya P mathur, “Foundation of Software Testing”, 1st edition Pearson Education 2008.
[2] Alander, J.T., Mantere, T., and Turunen, P, “Genetic Algorithm Based Software Testing,”
http://citeseer.ist.psu.edu/40769.html, 1997.
[3] Berndt, D.J., Fisher, J., Johnson, L., Pinglikar, J., and Watkins, A., “High Volume
Software Testing with Genetic Algorithms,” In Proceedings of the Thirty-Eighth Hawaii
International Conference on System Sciences (HICSS-38), Hawaii, January 2005.
[4] Cai Ferriday, “A Review paper on Decision Table Based Testing”, 2007
[5] Goldberg, D.E, “Genetic Algorithms: in Search, Optimization & Machine Learning,”
Addison Wesley, MA. 1989.
[6] Khenaidoo Nursimulu, Robert L. Probert,“Cause-Effect Graphing Analysis and
validation of Requirements”, CASCON '95 Proceedings of the 1995 conference of the
Centre for Advanced Studies on Collaborative research.
43. [7] Kuo-Chang Tai 1, Amit Paradkar 2, Husn Kang Su and Mladen A. Vouk, “Fault
BasedTest Generation for Cause-Effect Graphs”, CASCON '93 Proceedings of the 1993
conference of the Centre for Advanced Studies on Collaborative research.
[8] Myers, G.L., “The Art of Software Testing ”,Wiley-Interscience , New-York.
[9] Praveen Ranjan Srivastava, Parshad Patel, Siddharth Chatrola “Converting Cause Effect
Graph to Decision Table.” Vol. 2, No.4, October 2009
[10] Praveen Ranjan Srivastava, Tai-hoon Kim, “Application of Genetic Algorithm in
software Testing” International Journal of Software Engineering and Its Applications
Vol. 3, No.4, October 2009
[11] Reeves, C. R.: Using Genetic Algorithms with Small Populations, Proc. of the Fifth
International Conference on Genetic Algorithms and Their Applications, Morgan
Kaufmann, (1993) 92-99.
44. [12] Rex Black,“Advanced Software Test Design Techniques, Decision Tables and
cause-Effect Graphs”, Advanced Software Testing: Vol. 1, 2009
[13] Schroeder P. J., and Korel, B. “Black-Box Test Reduction Using Input-Output
Analysis”. In Proc. of ISSTA '00 (2000),173-177.
[14] Vouk, M.A. and R.E. Coyle (1989), “BGG: A Testing Coverage Tool,” In
Proceedings of 7th Annual Pacific Northwest Software Quality Conference,
Lawrence and Craig, Inc., Portland, OR, pp. 212–233.
[15] The Westfall Team, “Cause-Effect Graphing by Theresa Hunt”, 2007.