Font Size: a A A

Research On Unit Testing Technology Based On Java Platform

Posted on:2006-07-11Degree:MasterType:Thesis
Country:ChinaCandidate:B YuFull Text:PDF
GTID:2178360182470102Subject:Computer software and theory
Abstract/Summary:PDF Full Text Request
Today, with Java technologies being prevailed increasingly and regarded abroad, how to enhance creadibility of Java applications is a key problem that isn't ignored. Unit testing of Java applications is a key of assuring software qualities and improving software dependability. It is consuming and tedious that unit testing is executed manually, but automatic unit testing has already been an important means that economizes the cost of software development and enchances software creability. Therefore, the researches are on how to generate test data for unit testing of Java applications automatically and improve automatic level of unit testing in this paper.First, in this paper, we analyze the relations of subtype behavior and class compatibility, utilize a map that transforms subtype behavior specification into class compatibility implementation correctly, and create class invariant, precondition and post-condition of method. Accurate class invariant and method post-condition can act as a test oracle. At the same time, and class invariant and method precondition can act as the inputs of partitioning equivalence class and analyzing boundary values.Second, this paper provides two means of generating test data for unit testing which is required to compute expected values for test data manually. Seeing about generating test data based on enumeration method and normal statistical methods, such as, orthogonal design method, uniform design method, which are usually used in production and experiment, the experiment results show the improved uniform design method can generate effective test data with the tradeoff between test time cost and test effects. Then, the means of generating test data based on genetic algorithm is presented. It adopts mixed coding which combines binary coding for integer, char, byte, with float coding for float, double, adds instrumentation for Java class under test expressed by byte codes, generates test data stochastically, monitors test data executing on unit under test, takes the test coverage rate as fitness value, executes genetic operations, and gains a test data set. The experiment results show that improved genetic algorithm can be applied to generate test data efficiently for Java class under test.Third, we provides various patterns of test case in this paper, which aim at the abstract class, interface including inner class, other inner class and normal class, for class test of a Java program. According to the patterns and the need of the Liskov substitution principle for class test, an automatic tool is implemented that generates test case template automatically Junit based.At last, with above-mentioned researches on unit testing of Java applications, we have developed a prototype tool on Java platform based on Junit. With the tool, the programmers can generate test data set and test case template automatically, only put the expected values for test data into the framework of test case to acquire a completed test case when they develop it, improve the efficiency of developing software and enhance the creditability of software unit.
Keywords/Search Tags:unit testing, class testing, genetic algorithm, uniform design, test data
PDF Full Text Request
Related items