• No results found

Genetic_Algorithm for a Use Case

N/A
N/A
Protected

Academic year: 2021

Share "Genetic_Algorithm for a Use Case"

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

Genetic_Algorithm for a Use Case

Dr. Ruchika Malhotra, Assistant Professor CS Dept., Delhi Technological University (DTU) (DCE)

Main Bawana Road, Delhi 1100 42, India [email protected]

Ashish Gupta

CS Dept., Delhi Technological University (DTU) (DCE) Main Bawana Road, Delhi 1100 42, India

[email protected]

Abstract— Genetic_Algorithms (GAs) have been considered to automate the generation of test-data for developed software in an efficient & quick manner for the various domain developed software. Genetic_Algorithms (GAs) are adaptive search techniques that improves the software testing technique to improve the testing-automation problems when traditional methods are considered too complex and time consuming. The concept of genetic_algorithms is used to optimize the automated generation of test-cases with the testing output effectiveness. A use case is studied by using Genetic Algorithms (GAs) based testing tool which generates the tests cases in an automated fashion. It is discussed that Genetic_Algorithms ( GAs) are used to generate test cases automatically & efficiently using Genetic_Algorithms ( GAs) based test generator. The major benefit in developed software program testing is its automation and easy to get results along with the quality output. This paper discusses that Genetic_Algorithms ( GAs) are useful in reducing the long testing time (TT) by generating automatic test-cases using Genetic_Algorithms ( GAs) based test generator.

Keywords— Genetic Algorithm (GA) , Testing Time (TT).

I. INTRODUCTION &GENETIC ALGORITHMS

Gas offer a robust non-linear search technique for the problems involving large numbers of variables and the GA achieves the optimum solution by the random exchange of information between increasingly fit samples and the introduction of a probability of independent random change.

As compared to the other search methods, there is a need for a strategy, which is global, efficient and robust over a broad spectrum of various problems [1-5].

The aim of this paper is to study, analyze & investigate the effectiveness of Genetic Algorithms (GAs) with regard to random testing and to automatically generate test data to traverse all branches of software. To analyze the performance of GAs under various circumstances along with the automatic testing of complex software procedures and analysis of the test data adequacy using mutation testing [5-11].

The performance of GAs in automatically generating test data for small procedures is assessed and analysed. A library of GAs is developed and then applied to larger systems. The efficiency of GAs in generating test data is compared to random testing with regard to the number of test data sets generated and the CPU time required. Prior research project presents a system for the generation of test data for software [5- 8].

II. DESIGN &IMPLEMENTATION OF TOOL

A. Flow Chart : Genetic Algorithm

GA is an optimization and machine learning algorithm (MLA) based loosely on the processes of biological evolution.

J. Holland created the GA field and it is the first major GA research paper publication. GA provides a general-purpose search methodology [4]. Genetic algorithm as an effective global smart search method, reveals its own strength and efficiency to solve the large space, optimized for high complicated problems and thus provides a new method to solve the problems of automatic generating test data [1-3]. GA has been successfully & efficiently used to automate the generation of test data and GA begins with a set of initial population which is randomly sampled for a particular problem domain.

Then GA is applied, by performing a set of operations iteratively to get a new and fitter generation and generating test data automatically reduces the time and effort of the tester [1- 6].

START

Get Initial Test Cases

Add test Cases to Generation Table

Calculate fitness value and normalized Fitness

Is Each Tescase

Covered?

Is normalize

Fitness <

0.3 Set Operation to

MUTATE Is normalize

fitness <= 0.7

Set Operation to

CROSSOVER Set Operation to

SATISFIED

NO YES

YES NO

YES NO A

B

Figure: Flow chart for Genetic Algorithm Used

(2)

A

IS Test cases Covered?

Is Operation type

= MUTATION

Mutate CrossOver

NO

YES

NO

YES

B Is Mutation or

Cross Over Possible?

END

Figure: Flow chart for Genetic Algorithm Used

The two common operations that are performed to produce efficient solution for a target problem after selection operation are Crossover and Mutation [5-7].

B. Mutation

The mutation operation picks a gene at random and changes its state according to the mutation probability as shown in below figure. Mutation maintains diversity in a generation to prevent premature convergence to a local optimal solution.

Mutation operation is carried out after Crossover. Mutation is an operation in which the chromosomal bit representation of zero’s are flipped into one’s and vice versa based on the mutation probability(pm). GA guarantees high probability of improving the quality of the individuals over several generations according to the Schema Theorem [1-11]. Mutation generally prevents GA from falling into local extremes.

Mutation shouldn’t occur frequently, because GA will change into random search [7-11].

Mutate

START

Convert input array into binary String

Randomly select a position in string

Switch the bit at the position in bit string

END

Figure: Flow chart for Mutate

C. Crossover

This operation is used to produce the descendants that make up the next generation as shown in below figure. This

operation involves the following cross breeding procedures [1- 11].

i. Randomly select two individuals as a couple from the parent generation.

ii. Randomly select a position of the genes, corresponding to this couple, as the cross over point. Thus, each gene is divided into two parts.

iii. Exchange the first parts of both genes corresponding to the couple.

iv. Add the two resulted individuals to the next generation.

Cross Over

START

Convert input array into binary String

Randomly select a position in string

Swap right portions of two strings at the selected position

END Select two test cases

Figure: Flow chart for Cross Over

D. Select Cases and Fitness

A fitness function for test data generation is developed based on GA. The goal of the test data generation problem is to find a program input ‘x’ on which P will be traversed.

Select two test cases START

Select two test cases with highest Fitness

Is two test cases

selected

?

Cross Over

Is one test case

selected

?

Take muted test case with highest fitness as 2nd

test case

Is two test case

selected

?

Take satisfied test case with lowest fitness as

2nd test case

Is two test case

selected

? NO

YES

NO

NO

YES YES

YES

END

END NO

Figure: Flow chart for Case Selection

This GA concept was used in our approach to test the data.

(3)

compute the number of paths required to be tested. We have generated test data for a single feasible with respect to the test data.

E. Use Case Diagram

The concept of GA has been applied to the problem of automated test data generation process. Here the test data is referred to as population in GA. In initial population, each individual bit string (chromosome) is a test data. This set of chromosomes is used to generate test data for feasible basis paths. The system for generating automated test data for feasible basis paths using GA has been coded in C++. It randomly generates the initial population, evaluates the individual chromosome based on the fitness function value and applies the GA operations such as selection, crossover and mutation to produce next generation. This iterative process stops when the GA finds optimal test data.

Figure: Flow chart for Use-Case

III. TOOL OUTPUT

The principle of GAs has been applied to generate test data automatically. The developed system generates optimal test data automatically on the basis of basis paths in the control flow graph. The first generation is generated randomly and then by performing the basic GA steps, fitness of individuals gets improved. The system first generates the individual test data randomly, and then calculates fitness for each individual chromosome (test data) and on the basis of their fitness values it performs mutation and crossover. This process continues until all individuals reach to the maximum fitness. The system performs all operations from initial population to last generation automatically; it does not require the user interference. Generating test data automatically reduces the time and effort of the tester.

Genetic Algorithms are more efficient than random testing in generating test data. The efficiency will be measured as the number of tests required to obtain full branch coverage. A standard set of parameters for Genetic Algorithms can be established which will apply to a variety of procedures with different input data types. Test cases can be generated for loops with zero, one, two and more than two iterations. Genetic Algorithms generate adequate test data in terms of mutation testing and generating test data for the original (unmutated) software is better.

1) Testing Criteria:

The criterion of testing in prior research is branch testing.

Our aim is to develop a test system to exercise every branch of the software under test. In order to generate the required test data for branch testing Genetic Algorithms and random testing are used. These two testing techniques will be compared by means of the percentage of coverage, which each of them can achieve and by the number of test data which have to be generated before full branch coverage has been attained.

2) Tool: Scope & Limitations

This tool takes in ready created test cases and does the refinement of the cases. Refinement criteria is to select the best-fitted test case for the given source code. This tool currently supports only maximum 500 iterations for the refinement and finding the best-suited test cases. Current design of the tool is such that the Fitness Function has to be provided by user and has to be compiled every time. But this limitation can be removed using DLL.

Below are some screen shots of this tool output in terms of generations:-

A. Genetic algorithm for test data generation

The following steps show the algorithmic approach followed to generate test data for the basis path derived from CFG using GA.Figure-4 shows the schematic representation of test data generation using GA.

Figure: Algorithm Input and Output 1) Generation 1

Algorithm

Input: Randomly generated numbers (initial population act as test data) based on

the target path to be covered.

Output: Test data for the target path.

(4)

2) Generation 2

3) Generation 3

4) Generation 4

B. Experimental Settings

The following sets of parameters were considered for test data generation using GA.

 Fitness function

 Coding Binary String

 Length of the string in the chromosome

 Population Size (N)

 Selection method

 Two-point crossover and pc

 Mutation probability( pm)

 Stopping Criteria; number of generation

First set of test data was generated randomly. The test Data that we derived based on the set of basis paths, depends on the programs structure with an aim to traverse every executable statement in the program. The fitness function used was derived on the basis of branch distance[2]. The input variables were represented in binary form. The main objective of using GAs lies in their ability to handle input data which may be complex in nature. Thus, the problem of test data generation is treated entirely as an optimization problem. One of the merits of using GAs is that through the search and optimization process, test data sets are improved in a manner that they are close to the input domain.

C. Output

The approach followed for test data generation for path testing using GA, the following four basic steps were processed viz., Control Flow Graph Construction, Target Path Selection, Test Data generation and Execution, Test Result Evaluation.

Below Results show the fitness value range of test data, user input and the classification of individual chromosome into their respective classes based on fitness value.

D. Priority Function

E. User Input

F. Analysis

The idea and objective of the research is to investigate the effectiveness of test data generation using Genetic Algorithms.

Therefore, a test harness was developed in order to apply branch, boundary and loop testing criteria which was to iterate

(5)

a loop zero, one, two, and more than two times. As the example in the research shows, the obvious desire is to achieve an optimum solution for a particular function. How a GA works is shown with a simple problem.

The main characteristics of GAs are listed below:

1. Concentrates on chromosomes with above average fitness.

2. Exploits information about a large number of values while processing a small Population

3. Prevents search from stagnating at a local optimum.

4. They take advantage of old knowledge held in a population of solutions to generate new solutions with improved performance.

IV. CONCLUSION

The primary objective of this paper is to study and analyze GA-based software test data generator and to demonstrate its feasibility with a use case. In this paper, the genetic algorithms (GAs) are used to generate test cases automatically using Genetic Algorithms (GAs) based test generator. The major merit of GAs in software program testing is its automation and easy to get results along with quality output. This paper discusses that Genetic Algorithms ( GAs) are useful in reducing the long testing time (TT) by generating automatic test cases using Genetic Algorithms ( GAs) based test generator.

ACKNOWLEDGMENT

This paper is specifically meant for educational purpose for completing M.Tech. degree with Delhi Technological University (DTU), Delhi India. This paper is prepared for submission for publication as a part of M.Tech. course work.

The authors are very much thankful to Samsung Electronics India and Delhi Technological University (DTU) (DCE).

REFERENCES

[1] Alander, J.T., Mantere, T., and Turunen, P. Genetic Algorithm Based Software Testing. http://citeseer.ist.psu.edu/40769.html. 1997.

[2] Baresel, A., Sthamer, H., and Schmidt, M. Fitness Function Design to improve Evolutionary Structural Testing. In Proceedings of the Genetic and Evolutionary Computation Conference, GECCO-2002, New York, USA, 9-13th July 2002.

[3] Beizer, B. Software Testing Techniques. Van Nostrand Reinhold, New York. 1982.

[4] Harmen - Hinrich Sthamer , “The Automatic Generation of Software Test Data Using Genetic Algorithms”, University of Glamorgan, Thesis, Doctor of Philosophy, November 1995

[5] Deason W. H., Brown D. B., Chang K.H.and Cross J. H.: 'A rule-based software test data generator', IEEE Transactions on Knowledge and Data Engineering, Vol. 3, No. 1, pp. 108-117, March 1991

[6] FERGUSON, R. and KOREL , B. , The Chaining Approach for Software Test Data Generation, ACM Transactions on Software Engineering and Methodology , January 1996

[7] Gupta , N., Mathur, A.P., Soffa, M.L., Automated Test Data Generation Using An Iterative Relaxation Method, ACM, 1998

[8] Graham, D. R.: 'Software Testing Tools: A New Classification Scheme', Journal of Software Testing, Verification and Reliability, Vol. 1, No. 2, pp. 18-34, 1992

[9] Hamlet, R. G.: 'Probable correctness theory', Information Processing Letters, Vol. 25, pp. 17-25, 1987

[10] Ince, D. C.: 'The Automatic Generation Of Test Data', The Computer Journal, Vol. 30, No. 1, pp. 63-69, 1987

[11] Jones, B. F., Sthamer, H. - H., Yang, X. and Eyres, D. E., The automatic generation of software test data using adaptive search techniques, Proceedings of third Int. Conf. on Software Quality Management SQM '95, Seville, pp. 435 - 444, 1995

References

Related documents

a) CSO representatives shall include the Senior Information Technology Security Officer (SITSO) for PST or his/her designee as the Chair and CSO voting member. 2) Office

contacts formed only in the native (pink) or activated (green) register).. The activated Rec dimer allows formation of a catalytically competent GGDEF dimer. a) Changes in

The following is a discussion of the research results of observations, FGDS and the discourse analyses conducted for this study, presented according to emerging themes, which

The study is helpful for many players in Home Appliances to make following strategies related to advertising for any particular company: -..  Advertising

Newby indicated that he had no problem with the Department’s proposed language change.. O’Malley indicated that the language reflects the Department’s policy for a number

An estimate of the mass flow rate through the stack was based on a balance between the driving pressure due to the buoyant force of the air and the pressure drop due to turbulent

10.6 Switch the mode selector to the desired position and set the room thermostat to the desired temperature. 10.7 Your boiler is now ready

Creating value through capital discipline, cost reduction and portfolio management. Entering a phase of strong cash flow