CN108415846B - Method and device for generating minimum automatic test case set - Google Patents

Method and device for generating minimum automatic test case set Download PDF

Info

Publication number
CN108415846B
CN108415846B CN201810355603.1A CN201810355603A CN108415846B CN 108415846 B CN108415846 B CN 108415846B CN 201810355603 A CN201810355603 A CN 201810355603A CN 108415846 B CN108415846 B CN 108415846B
Authority
CN
China
Prior art keywords
test case
data
test
interface
generating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810355603.1A
Other languages
Chinese (zh)
Other versions
CN108415846A (en
Inventor
郭雅雯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wacai Network Technology Co ltd
Original Assignee
Wacai Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wacai Network Technology Co ltd filed Critical Wacai Network Technology Co ltd
Priority to CN201810355603.1A priority Critical patent/CN108415846B/en
Publication of CN108415846A publication Critical patent/CN108415846A/en
Application granted granted Critical
Publication of CN108415846B publication Critical patent/CN108415846B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to a method and a device for generating a minimum automation test case set. The method comprises the following steps: generating multiple groups of parameter data, including generating data sources and combining the data sources; constructing an interface script, wherein the interface script comprises compiling an interface test case and constructing a test case library, and the input parameter data is associated to the test case library; running a script of the test case, recording the code coverage rate by means of the plug-in, and recording a test result; and reserving the test case with the highest coverage rate in the same test result. The device comprises an input parameter data generating unit, a test case constructing unit and a test case running unit. The invention generates the test case based on the code structure based on the combination of machine learning and genetic algorithm, wherein the searched solution space is the test data space, the optimal solution is the test data meeting the specific test target, the algorithm complexity can be effectively reduced, and the effective test case can be obtained.

Description

Method and device for generating minimum automatic test case set
Technical Field
The invention relates to the field of software automation test, in particular to a method and a device for generating a minimum automation test case set.
Background
In the software testing process, effective software testing cases are generated and selected, a series of cases with high recurrence error probability can be screened out, and the method plays a vital role in saving the cost of testing personnel and ensuring the software quality. The test optimization mainly comprises two aspects, namely, on the premise of meeting test requirements, finding out a minimum test case set; and secondly, the test cases which meet the test requirements and are not repeated can be automatically expanded under a certain number of test cases. The technical patent mainly introduces an algorithm for generating a minimum test case.
At present, most of web-side algorithms aiming at the minimum test case set generate test cases based on greedy algorithm in machine learning. The method is characterized in that test cases are screened according to log mining, so that the test cases are classified, and finally the test cases meeting the test requirements are selected.
Disclosure of Invention
In order to solve the above problems, an object of the present invention is to provide a method and an apparatus for generating a minimum automation test case set. The test case based on the code structure is generated based on the combination of machine learning and genetic algorithm, wherein the searched solution space is the test data space, the optimized solution is the test data meeting the specific test target, the algorithm complexity can be effectively reduced, and meanwhile, the effective test case is obtained.
In order to solve the above technical problem, the application embodiment is implemented as follows:
the method for generating the minimized test case set provided by the embodiment of the application comprises the following steps:
generating multiple groups of parameter data, including generating data sources and combining the data sources;
constructing an interface script, wherein the interface script comprises compiling an interface test case and constructing a test case library, and the input parameter data is associated to the test case library;
running a script of the test case, recording the code coverage rate by means of the plug-in, and recording a test result;
and reserving the test case with the highest coverage rate in the same test result.
Preferably, the generating data source includes:
constructing a parameter generator, classifying data sources according to multiple dimensions, personalizing access rules of each data type, and establishing a rule function;
the data sources are classified and then stored as a database.
Preferably, before running the script of the test case, the method further includes: and selecting public parameter data under the same test case.
Preferably, the selecting the public parameter data under the same test case includes:
the input parameter data is stored in a test case library, a data table of the database comprises a field interface _ name used for representing the name of an external interface of a test case, and the interface _ names of all the input parameter data of the same interface test case are the same;
and screening all input parameters of the same interface _ name as a data source of the test case by using the dataprovider of the TestNg through the connection of the database.
Preferably, the step of retaining the test case with the highest coverage rate in the same test result includes:
placing the test cases with the same test result into the same screening pool;
selecting the test case with the highest coverage rate in each screening pool, marking the test case as an available case, and marking other cases in the screening pool as unavailable cases;
the unavailable use case is deleted.
The device for generating the minimized test case set provided by the embodiment of the application comprises the following components:
an input parameter data generating unit: generating multiple groups of parameter data, including generating data sources and combining the data sources;
a test case construction unit: constructing an interface script, wherein the interface script comprises compiling an interface test case and constructing a test case library, and the input parameter data is associated to the test case library;
a test case operation unit: running a script of the test case, recording the code coverage rate by means of the plug-in, and recording a test result; screening unit: and reserving the test case with the highest coverage rate in the same test result to form a minimum case set.
According to the technical scheme provided by the embodiment of the application, the embodiment of the application generates the test case based on the code structure based on the combination of machine learning and genetic algorithm, wherein the searched solution space is the test data space, and the optimized solution is the test data meeting the specific test target, so that the algorithm complexity can be effectively reduced, and meanwhile, the effective test case can be obtained.
Drawings
FIG. 1 is a flow diagram of a method of generating a minimized set of test cases.
Figure 2 is a block diagram of an apparatus for generating a minimized set of test cases,
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more of the examples in this specification. Rather, they are merely examples of apparatus and methods consistent with aspects of one or more embodiments of the specification, as detailed in the claims which follow.
It should be noted that: in other embodiments, the steps of the respective methods need not be performed in the order illustrated and described herein, and in some other embodiments, the methods may include more or less steps than those described herein. Moreover, the individual steps described in this description may in other embodiments be combined into a single step.
As shown in fig. 1, the method may include the steps of:
step 1, generating multiple groups of parameter data, including generating data sources and combining the data sources.
Step 1 may comprise the steps of:
step 101, generating a data source;
step 102, constructing an input parameter generator.
The fabric parameter generator comprises: the data sources are classified according to multiple dimensions, the access rule of each data type is individualized, and a rule function is established.
Taking an interface as an example, data elements are first classified according to the following dimensions:
dimension one, whether transmission is necessary or not;
dimension two, data type: int, String, List, Long, etc.;
dimension three, data value range: including data type and boundary values, special characters and business meanings.
Then, the access rule of each data type is personalized, and an int data generation rule is used for example:
define order number: int payId. Firstly, the int range can be judged to be [ -2^31-1.2^31], the total value can be 2^32, but after the business meaning is considered, the value of payId can be determined to be: 1. a negative number; 2. 2^31, 3, character, 4, 100 (any number between boundary values).
In the same way, other value rules of the input parameters can be designed, and a rule function is established.
And 103, classifying the data processed by the parameter generator and storing the classified data into a database. The data source is stored in a data _ resource table, and the storage fields of the data source are shown in table 1:
table 1:
id necessity value Data_name Data_type useful
1
wherein id is the primary key, and the business records whether the field must be filled, wherein 0 is not necessary filled, and 1 is necessary filled; value is the value of the data; data _ name is meaning or name of the reference; data _ type is a data type; useful indicates whether this parameter value is to be used in step 104, and useful of 1 indicates that this value is to be used when combining parameters; at 0, the combination reference is stated without taking this parameter value into account.
And step 104, combining the data sources.
And for the data source stored in the data _ resource table, arranging and combining all necessary fields according to different input parameter names to obtain multiple groups of input parameter data, wherein each group of input parameter data comprises multiple data.
Step 2, constructing a test case library, comprising:
compiling an interface test case script;
and constructing a test case base test _ case, and associating the input parameter data to the test case base.
the storage fields of the test _ case table are shown in table 2:
Figure BDA0001634507880000041
id is a main key, and interface _ name provides an interface name for the service end to the outside; associating the parameter data through the data field; test _ result is used for recording the test result; coverage _ percentage is used for code coverage; the useful is used to mark whether the use case is reserved, wherein 0 represents abandonment and 1 represents reservation.
And 3, running the script of the test case. Before the script of the test case is run, the method further comprises the following steps: and selecting public parameter data under the same test case.
In the test case library, the input parameter data generated in the step 1 is stored under a data field of the test case library, and a data table in the database comprises the following fields: the Interface _ name ensures that the Interface _ names of all the access parameter data of the same Interface test case are the same, so that the access parameter data of the same Interface name can be screened out as a data source of the test case by using the dataprovider of the TestNg through the connection of a database, and the test case needs to be operated next.
When the test case is run, after each data source is counted as an entry parameter by means of a Cobertura plug-in eCoobertura of Eclipse, the coverage rate of the code is used as a scoring standard, and a test result is recorded in a test _ result field of a test _ case.
And 4, reserving the test case with the highest coverage rate in the same test result.
Placing the test cases with the same test result into the same screening pool;
selecting the test case with the highest coverage rate in each screening pool, marking the test case as an available case, and marking other cases in the screening pool as unavailable cases;
the unavailable use case is deleted.
Through the steps, the minimum case set can be obtained automatically.
Fig. 2 shows an apparatus for generating a minimized test case set, which includes:
input parameter data generating unit 21: generating multiple groups of parameter data, including generating data sources and combining the data sources;
test case construction unit 22: constructing an interface script, wherein the interface script comprises compiling an interface test case and constructing a test case library, and the input parameter data is associated to the test case library;
test case execution unit 23: running a script of the test case, recording the code coverage rate by means of the plug-in, and recording a test result;
the screening unit 24: and reserving the test case with the highest coverage rate in the same test result to form a minimum case set.

Claims (5)

1. A method for generating a minimized test case set, comprising:
generating multiple groups of parameter data, including generating data sources and combining the data sources; the generating data source comprises: constructing a parameter generator, classifying data sources according to multiple dimensions, personalizing access rules of each data type, and establishing a rule function; classifying the data sources and storing the data sources into a database; for the data source stored in the data _ resource table, arranging and combining all necessary fields according to different input parameter names to obtain multiple groups of input parameter data, wherein each group of input parameter data comprises multiple data;
constructing an interface script, wherein the interface script comprises compiling an interface test case and constructing a test case library, and the input parameter data is associated to the test case library;
running a script of the test case, recording the code coverage rate by means of the plug-in, and recording a test result;
and reserving the test case with the highest coverage rate in the same test result.
2. The method of claim 1, wherein before running the script of the test case, the method further comprises: and selecting public parameter data under the same test case.
3. The method according to claim 2, wherein the selecting common reference data under the same test case comprises:
the input parameter data is stored in a test case library, a data table of the database comprises a field interface _ name used for representing the name of an external interface of a test case, and the interface _ names of all the input parameter data of the same interface test case are the same;
and screening all input parameters of the same interface _ name as a data source of the test case by using the dataprovider of the TestNg through the connection of the database.
4. The method according to claim 1, wherein the step of retaining the test case with the highest coverage rate in the same test result comprises:
placing the test cases with the same test result into the same screening pool;
selecting the test case with the highest coverage rate in each screening pool, marking the test case as an available case, and marking other cases in the screening pool as unavailable cases;
the unavailable use case is deleted.
5. An apparatus for generating a minimized test case set, comprising:
an input parameter data generating unit: generating multiple groups of parameter data, including generating data sources and combining the data sources; the generating data source comprises: constructing a parameter generator, classifying data sources according to multiple dimensions, personalizing access rules of each data type, and establishing a rule function; classifying the data sources and storing the data sources into a database; for the data source stored in the data _ resource table, arranging and combining all necessary fields according to different input parameter names to obtain multiple groups of input parameter data, wherein each group of input parameter data comprises multiple data;
a test case construction unit: constructing an interface script, wherein the interface script comprises compiling an interface test case and constructing a test case library, and the input parameter data is associated to the test case library;
a test case operation unit: running a script of the test case, recording the code coverage rate by means of the plug-in, and recording a test result;
screening unit: and reserving the test case with the highest coverage rate in the same test result to form a minimum case set.
CN201810355603.1A 2018-04-19 2018-04-19 Method and device for generating minimum automatic test case set Active CN108415846B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810355603.1A CN108415846B (en) 2018-04-19 2018-04-19 Method and device for generating minimum automatic test case set

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810355603.1A CN108415846B (en) 2018-04-19 2018-04-19 Method and device for generating minimum automatic test case set

Publications (2)

Publication Number Publication Date
CN108415846A CN108415846A (en) 2018-08-17
CN108415846B true CN108415846B (en) 2021-10-15

Family

ID=63136002

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810355603.1A Active CN108415846B (en) 2018-04-19 2018-04-19 Method and device for generating minimum automatic test case set

Country Status (1)

Country Link
CN (1) CN108415846B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109684209A (en) * 2018-12-17 2019-04-26 北京奇虎科技有限公司 A kind of method for generating test case, device and electronic equipment
CN112306855B (en) * 2019-08-02 2022-06-17 北大方正集团有限公司 Interface automation test method, device, terminal and storage medium
CN110795297B (en) * 2019-10-31 2023-04-28 杭州迪普科技股份有限公司 Electronic equipment testing method and device
CN111949520A (en) * 2020-07-31 2020-11-17 上海中通吉网络技术有限公司 Automatic interface test method and equipment
CN111950202A (en) * 2020-08-12 2020-11-17 广东电网有限责任公司佛山供电局 Simulation case reduction processing method for system chip
CN113918474B (en) * 2021-12-15 2022-03-11 杭银消费金融股份有限公司 Test case management method and device based on data mode
US11934300B2 (en) 2022-05-04 2024-03-19 Red Hat, Inc. Reducing computing power for generating test scenario files for decision models

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101482596A (en) * 2009-01-06 2009-07-15 南京大学 Fast fault recognition method for multifactor industrial system
CN101706751A (en) * 2009-11-23 2010-05-12 中兴通讯股份有限公司 Method and system for calculating coverage rate of service functions of software
CN102945204A (en) * 2012-11-14 2013-02-27 清华大学 Operating system standard conformance test adequacy evaluation method based on interface model
CN102999320A (en) * 2011-09-15 2013-03-27 阿里巴巴集团控股有限公司 Automatic test case generation method and system
CN103268285A (en) * 2013-05-31 2013-08-28 百度在线网络技术(北京)有限公司 Method and device for automatic generation of robustness test case of API interface
CN106021094A (en) * 2016-04-29 2016-10-12 南京慕测信息科技有限公司 Program static analysis based Java unit test teaching feedback method

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8527813B2 (en) * 2011-12-19 2013-09-03 Siemens Aktiengesellschaft Dynamic reprioritization of test cases during test execution
WO2015088316A1 (en) * 2013-12-09 2015-06-18 Mimos Berhad Functional test automation framework using user defined ontology
CN104461887A (en) * 2014-12-11 2015-03-25 吴翔虎 Embedded software black-box test case generation method based on dynamic model
US9910763B1 (en) * 2016-08-18 2018-03-06 International Business Machines Corporation Test case reduction in application binary interface (ABI) compatibility testing
CN106383778A (en) * 2016-08-25 2017-02-08 浪潮电子信息产业股份有限公司 Test case reusability improving method
CN107291620A (en) * 2017-06-30 2017-10-24 郑州云海信息技术有限公司 A kind of method for generating test case and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101482596A (en) * 2009-01-06 2009-07-15 南京大学 Fast fault recognition method for multifactor industrial system
CN101706751A (en) * 2009-11-23 2010-05-12 中兴通讯股份有限公司 Method and system for calculating coverage rate of service functions of software
CN102999320A (en) * 2011-09-15 2013-03-27 阿里巴巴集团控股有限公司 Automatic test case generation method and system
CN102945204A (en) * 2012-11-14 2013-02-27 清华大学 Operating system standard conformance test adequacy evaluation method based on interface model
CN103268285A (en) * 2013-05-31 2013-08-28 百度在线网络技术(北京)有限公司 Method and device for automatic generation of robustness test case of API interface
CN106021094A (en) * 2016-04-29 2016-10-12 南京慕测信息科技有限公司 Program static analysis based Java unit test teaching feedback method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
通讯系统自动化通用测试平台的研究与实现;李菲;《中国优秀博硕士学位论文全文数据库(硕士) 信息科技辑》;20061015(第10期);第I138-189页 *
面向敏捷开发模式的测试管理系统的设计与实现;李文杰;《中国优秀硕士学位论文全文数据库 信息科技辑》;20150615(第06期);第I138-171页 *

Also Published As

Publication number Publication date
CN108415846A (en) 2018-08-17

Similar Documents

Publication Publication Date Title
CN108415846B (en) Method and device for generating minimum automatic test case set
CN107958057B (en) Code generation method and device for data migration in heterogeneous database
US11163744B2 (en) Test data generation and scale up for database testing using unique common factor sequencing
EP2565802B1 (en) Data masking setup
CN109543942A (en) Data verification method, device, computer equipment and storage medium
US6760732B2 (en) Method and system for viewing a record of an organization having a hierarchy of departments
CN101504672A (en) Method and system for dynamically configuring physical data table
CN103914439A (en) Method, device and system for online document edition
CN102222012A (en) Static type checking against external data sources
CN105630590A (en) Business information processing method and device
US11003635B2 (en) Database scheme for storing generic data
CN106933823A (en) Method of data synchronization and device
CN105912601A (en) Partition storage method for distributed real-time memory database of energy management system
CN101626576B (en) Method for generating parameter configuration template and method for configuring parameters by utilizing template
CN109245910B (en) Method and device for identifying fault type
CN110309214A (en) A kind of instruction executing method and its equipment, storage medium, server
US8498963B2 (en) Method and system for data synchronization
CN107291777A (en) A kind of method and apparatus of hot spot data identification and processing
CN106911634A (en) A kind of login method and equipment
US9852385B2 (en) Processing of business object identifiers in master data integration scenarios involving non-local identifiers
CN107784548A (en) Order processing method and apparatus
CN105045937B (en) A kind of efficiency detection data redundancy approach
CN106648444B (en) A kind of message treatment method and equipment
CN114610803A (en) Data processing method and device, electronic equipment and storage medium
CN107291610A (en) Testing case management and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant