Software testing is an important part of ensuring software quality.Designing test cases is an important step in testing.Existing automated test tools,such as c++test and Testbed,can’t generate test cases that meet the software requirements of key areas.Most of the test cases in unit testing still rely on manual design by testers.However,for complex programs,handdesigned test cases can hardly meet the coverage criteria of key domain software.Therefore,in order to improve test quality and reduce test costs,this paper studies the automatic generation of test cases for Modified Condition/Decision Coverage(MC/DC).Based on the existing test case generation technology,this paper proposes a new whale optimization genetic algorithm and applies it to the field of MC/DC test case generation to make up for the inefficiency of the existing algorithm in generating MC/DC test cases.The main research work is as follows.(1)Analyze the related theories of software testing,focus on the structure-oriented test case automatic generation technology and existing methods,and make a systematic summary of related technical methods,and propose the concept of using intelligent optimization algorithms to solve the problem of automatic test case generation.(2)A detailed analysis of the application of genetic algorithm and whale optimization algorithm in the automatic generation of test cases.The whale optimization algorithm and genetic algorithm are combined to form a whale optimization genetic algorithm to avoid the genetic algorithm falling into local optimum.Since the fixed probability threshold in the whale optimization genetic algorithm cannot play a positive role in guiding the evolution of the population,a new type of whale optimization genetic algorithm is proposed that introduces the population diversity to dynamically adjust the probability threshold.(3)A tool for automatic generation of MC/DC test cases is designed and implemented by using new whale optimization genetic algorithm.Two benchmark programs are used for experimental verification,and the new whale optimization genetic algorithm is compared with genetic algorithm,whale optimization algorithm,and particle swarm algorithm.The improved algorithm proposed in this paper has a fast convergence speed and avoids falling into the local optimum.The generated test cases have great advantages in MC/DC coverage.Experiments have proved that the MC/DC test case generation tool based on the new whale optimization genetic algorithm can implement software unit testing automatically and with high coverage. |