CN109918300B - Test data preparation method, device, terminal and storage medium - Google Patents

Test data preparation method, device, terminal and storage medium Download PDF

Info

Publication number
CN109918300B
CN109918300B CN201910147461.4A CN201910147461A CN109918300B CN 109918300 B CN109918300 B CN 109918300B CN 201910147461 A CN201910147461 A CN 201910147461A CN 109918300 B CN109918300 B CN 109918300B
Authority
CN
China
Prior art keywords
test data
strategy
test
creating
create
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
CN201910147461.4A
Other languages
Chinese (zh)
Other versions
CN109918300A (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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN201910147461.4A priority Critical patent/CN109918300B/en
Publication of CN109918300A publication Critical patent/CN109918300A/en
Application granted granted Critical
Publication of CN109918300B publication Critical patent/CN109918300B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Test And Diagnosis Of Digital Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a test data preparation method, a device, a terminal and a storage medium, comprising the following steps: creating three test data construction strategies of Search Only, create Only and Auto; selecting a corresponding construction strategy according to the requirement of the test case on the test data; test data is prepared according to the selected build strategy. The invention can realize the rapid preparation of test parameters for the test case and greatly improve the test efficiency.

Description

Test data preparation method, device, terminal and storage medium
Technical Field
The invention belongs to the technical field of software testing, and particularly relates to a test data preparation method, a test data preparation device, a terminal and a storage medium.
Background
With the evolution of the times, software architectures gradually develop, and the preparation method of corresponding test data also has corresponding iterative updating.
Many software enterprises are still in the 1.0 era of test data preparation at present. The most typical approach in this era is to encapsulate the operations related to test data preparation into data preparation functions. These related operations may be based on either an API or a database, or a combination of both. And (4) according to actual product characteristics, combining two methods of creating data in real time and preparing data in advance to create test data. For example, encapsulating into a typical prepare function public static createUser (String num, string userName, string pass \8230;) {// create test data using API or data manner }
The method can intuitively see that a plurality of parameters needing to be transmitted can be set through encapsulating functions, so that the method can be conveniently realized without concerning details of internal generated data, but the method has the obvious defects that a plurality of parameters needing to be used are complex, one function corresponds to one function, and more than ten transmitted parameters are common.
Worse still, if the incoming parameter is the basic type data, and if the incoming parameter is also the object, or the initialization parameter corresponding to the object of the incoming parameter is also the object, some series of data creation operations can be involved, so the method is not convenient in the actual project operation.
In addition, test data are not distinguished, and the test data need to be repeatedly created when the test is needed every time, so that the test efficiency is greatly reduced.
Aiming at the problems, test data are prepared more efficiently, a solution of a test data preparation platform is provided, the efficiency and the usability are improved, and the problem that test data pain points are prepared at present is solved.
Disclosure of Invention
The invention provides a test data preparation method, a device, a terminal and a storage medium, aiming at the problem that the conventional test data preparation method is too complicated and causes low test efficiency.
In a first aspect, the present invention provides a method for preparing test data, including:
creating three test data construction strategies of Search Only, create Only and Auto, comprising the following steps: creating a Search Only strategy for searching corresponding test data through key features from a test database which is created; creating a Create Only strategy for directly creating test data according to the test data characteristics by using a Builder Pattern mode; and creating an Auto strategy for searching corresponding test data from the created test database through key features and creating test data which does not exist in the test database according to the test data features by using a Builder Pattern mode.
Selecting a corresponding construction strategy according to the requirement of the test case on the test data, wherein the construction strategy comprises the following steps: matching a Search Only strategy for a test case requiring stable test data; matching a Create Only strategy for a test case requiring unstable test data; the Auto strategy is matched for test cases requiring stable test data and unstable test data.
Test data is prepared according to the selected build strategy.
In a second aspect, the present invention provides a test data preparing apparatus comprising:
the strategy creating unit is configured to Create three test data construction strategies of Search Only, create Only and Auto, and comprises the following steps: the first establishing module is configured for establishing a Search Only strategy for searching corresponding test data through key features from a test database which is established; the second creating module is configured to Create a Create Only strategy for directly creating test data according to the test data characteristics by using the Builder Pattern mode; and the third creating module is configured to create an Auto strategy for searching corresponding test data from the created test database through key features and creating test data which does not exist in the test database according to the test data features by using the Builder Pattern mode.
The strategy selection unit is configured to select a corresponding construction strategy according to the requirement of the test case on the test data, and comprises the following steps: the first matching module is configured to match a Search Only strategy for a test case requiring stable test data; the second matching module is configured to match a Create Only strategy for the test case requiring unstable test data; and the third matching module is configured to match Auto strategies for test cases requiring stable test data and unstable test data.
A data preparation unit configured to prepare test data according to the selected build strategy.
In a third aspect, a terminal is provided, which includes:
a processor, a memory, wherein,
the memory is used for storing a computer program which,
the processor is used for calling and running the computer program from the memory so as to make the terminal execute the method of the terminal.
In a fourth aspect, a computer storage medium is provided, having stored therein instructions that, when executed on a computer, cause the computer to perform the method of the above aspects.
The beneficial effect of the invention is that,
according to the test data preparation method, the test data preparation device, the test data preparation terminal and the storage medium, the three test data construction strategies of Search Only, create Only and Auto are created, the corresponding strategy is selected according to the requirement of the test case on the test data, and then the test data is prepared according to the selected strategy, so that the optimization of the test data preparation strategy is realized, and the test data is specifically prepared for each test case. And the build Pattern mode is adopted to create the test case, and the package is not carried out in a parameter exposure mode, so that the flexibility of the parameters is ensured to the maximum extent, the maintenance cost is reduced, and the test data creating step is simplified. The invention can realize the rapid preparation of test parameters for the test case and greatly improve the test efficiency.
In addition, the invention has reliable design principle, simple structure and very wide application prospect.
Drawings
In order to more clearly illustrate the embodiments or prior art solutions of the present invention, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a schematic flow diagram of a method of one embodiment of the invention.
Fig. 2 is a schematic block diagram of an apparatus of one embodiment of the present invention.
Fig. 3 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the drawings in the embodiment of the present invention, and it is obvious that the described embodiment is only a part of the embodiment of the present invention, and not all embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, shall fall within the protection scope of the present invention.
The following explains key terms appearing in the present invention.
FIG. 1 is a schematic flow diagram of a method of one embodiment of the invention. The execution body of fig. 1 may be a test data preparation device.
As shown in fig. 1, the method 100 includes:
step 110, three test data construction strategies of Search Only, create Only and Auto are created;
step 120, selecting a corresponding construction strategy according to the requirement of the test case on the test data;
step 130, test data is prepared according to the selected build strategy.
Optionally, as an embodiment of the present invention, creating three test data construction strategies of Search Only, create Only, and Auto includes: creating a Search Only strategy for searching corresponding test data through key features from a test database which is created; creating a Create Only strategy for directly creating test data according to the test data characteristics by using a Builder Pattern mode; and creating an Auto strategy for searching corresponding test data from the created test database through key features and then creating test data which does not exist in the test database according to the test data features by using a Builder Pattern mode.
Optionally, as an embodiment of the present invention, selecting a corresponding construction policy according to a requirement of a test case on test data includes: matching a Search Only strategy for a test case requiring stable test data; matching a Create Only strategy for a test case requiring unstable test data; and matching the Auto strategy for the test cases which need stable test data and unstable test data.
In order to facilitate understanding of the present invention, the test data preparation method provided by the present invention is further described below with reference to the principle of the test data preparation method of the present invention and the process of rapidly preparing test data in the embodiments.
Specifically, the test data preparation method includes:
s1, three test data construction strategies of Search Only, create Only and Auto are created.
Create Search Only policy:
UserBuilder.withCountry(“US”).withBuildStrategy(BuildStrategy.SEARCH_ONLY.build();
using the buildstrategy SearchOnly strategy, the Builder Pattern searches a test database which is created in advance for test data which meets the conditions, and returns if the test data is found, otherwise, returning fails.
Create Create Only policy:
UserBuilder.withCountry(“US”).withBuildStrategy(BuildStrategy.CREATE_ONLY).build();
when using buildstragy. Createonly strategy, builder Pattern directly uses Builder Pattern to create test data in the tested system, and then returns the created data.
The specific method for creating test data by using the Builder Pattern is as follows:
the Builder design schema (Builder Pattern) separates the building of a complex object from its representation so that the same building process can create different representations.
The builder model is a step-by-step creation of a complex object that allows users to build complex objects by specifying their types and content without the user needing to know the specific build details inside. The builder schema belongs to the object creation type schema. This mode includes roles of:
builder: abstract builder
ConcreteBuilder: concrete constructor
A Director: director
Product: product role
Such as the following example, to implement a generator schema to generate a computer.
A computer class
Package Builder;
Public class computer{
public String mouse; // mouse
public String audio; // Sound equipment
public String screen; // display
public String keyboard; // keyboard
public void setMouse(String mouse){this.mouse=mouse;}
public void setAudio(String audio){this.audio=audio;}
public void setScreen(String screen){this.screen=screen;}
public void setKeyboard(String keyboard){this.keyboard=keyboard;}}
Establishing an abstract builder class:
Figure BDA0001980475910000071
realizing a concrete builder and associating computer builder
Figure BDA0001980475910000072
Figure BDA0001980475910000081
Then implements a director class
Figure BDA0001980475910000091
Testing codes:
Figure BDA0001980475910000092
Figure BDA0001980475910000101
testing the code as above, in this way, no matter how complex the situation is, can be done by a simple one-line code call. Such as:
example one: under the support of Builder Pattern, a line of code can be executed to create what you need
Default value with parameter-user build ();
example two: if you want a special user, such as a uk user, to be created easily,
under the support of Build Pattern, as long as you specify that the country is UK, other parameters are defaults
May, reference implementation is-user builder.country ("England"). Build ();
example three: if there is another such user, UK user and the payment method is applet, the same party
The formula can create user data meeting the requirement through a line of codes, and the implementation mode which can be referred to is —)
UserBuilder.Country(“England”).payMethod(“credit”).build();
In the above way, it can be seen that whatever the requirements on the parameter data, it can be created by a line of code in the most flexible and simplest way.
Create Auto policy:
UserBuilder.withCountry(“US”).withBuildStrategy(BuildStrategy.AUTO).build();
the Auto strategy is the combination of the Search Only strategy and the Create Only strategy, whether data meeting the test condition exist in a test database established in advance is searched, if the data meeting the test condition exist, the data meeting the requirement are returned if the data are not found, and then the data are returned.
And S2, selecting a corresponding construction strategy according to the requirement of the test case on the test data.
The test data which does not need to be changed frequently is used as stable data, and the test data which needs to be changed frequently is used as unstable data. Matching a Search Only strategy for a test case requiring stable test data; matching a Create Only strategy for a test case requiring unstable test data; the Auto strategy is matched for test cases requiring stable test data and unstable test data.
And S3, preparing test data according to the selected construction strategy.
And preparing test data for the test case according to the corresponding strategy selected in the step S2.
As shown in fig. 2, the apparatus 200 includes:
the system comprises a strategy creating unit 210, wherein the strategy creating unit 210 is used for creating three test data construction strategies of Search Only, create Only and Auto;
the strategy selection unit 220 is used for selecting a corresponding construction strategy according to the requirement of the test case on the test data;
a data preparation unit 230, the data preparation unit 230 for preparing test data according to the selected build strategy.
Optionally, as an embodiment of the present invention, the policy creating unit includes: the first creating module is configured to create a Search Only strategy for searching corresponding test data through key features from a test database which is created; the second creating module is configured for creating a Create Only strategy which is used for directly creating test data according to the characteristics of the test data by using a Builder Pattern mode; and the third creating module is configured to create an Auto strategy for searching corresponding test data from the created test database through key features and creating test data which does not exist in the test database according to the test data features by using the Builder Pattern mode.
Optionally, as an embodiment of the present invention, the policy selecting unit includes: the first matching module is configured to match a Search Only strategy for a test case requiring stable test data; the second matching module is configured to match a Create Only strategy for the test case requiring unstable test data; and the third matching module is configured to match Auto strategies for test cases requiring stable test data and unstable test data.
Fig. 3 is a schematic structural diagram of a terminal device 300 according to an embodiment of the present invention, where the terminal device 300 may be used to execute the test data preparation method according to the embodiment of the present invention.
Among them, the terminal apparatus 300 may include: a processor 310, a memory 320, and a communication unit 330. The components communicate via one or more buses, and those skilled in the art will appreciate that the architecture of the server shown in the figures is not intended to be limiting, and that it may be a bus architecture, a star architecture, a combination of more or fewer components than shown, or a different arrangement of components.
The memory 320 may be used for storing instructions executed by the processor 310, and the memory 320 may be implemented by any type of volatile or non-volatile storage terminal or combination thereof, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The executable instructions in memory 320, when executed by processor 310, enable terminal 300 to perform some or all of the steps in the method embodiments described below.
The processor 310 is a control center of the storage terminal, connects various parts of the entire electronic terminal using various interfaces and lines, and performs various functions of the electronic terminal and/or processes data by operating or executing software programs and/or modules stored in the memory 320 and calling data stored in the memory. The processor may be composed of an Integrated Circuit (IC), for example, a single packaged IC, or a plurality of packaged ICs connected with the same or different functions. For example, the processor 310 may include only a Central Processing Unit (CPU). In the embodiment of the present invention, the CPU may be a single operation core, or may include multiple operation cores.
A communication unit 330, configured to establish a communication channel so that the storage terminal can communicate with other terminals. And receiving user data sent by other terminals or sending the user data to other terminals.
The present invention also provides a computer storage medium, wherein the computer storage medium may store a program, and the program may include some or all of the steps in the embodiments provided by the present invention when executed. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a Random Access Memory (RAM).
Therefore, the method and the device realize the optimization of the test data preparation strategy by creating three test data construction strategies of Search Only, create Only and Auto, selecting the corresponding strategy according to the requirement of the test case on the test data, and then preparing the test data according to the selected strategy, thereby pertinently preparing the test data for each test case. And the build Pattern mode is adopted to create the test case, and the package is not carried out in a parameter exposure mode, so that the flexibility of the parameters is ensured to the maximum extent, the maintenance cost is reduced, and the test data creating step is simplified. The invention can realize the rapid preparation of the test parameters for the test case, thereby greatly improving the test efficiency.
Those skilled in the art will readily appreciate that the techniques of the embodiments of the present invention may be implemented using software plus any required general purpose hardware platform. Based on such understanding, the technical solutions in the embodiments of the present invention may be embodied in the form of a software product, where the computer software product is stored in a storage medium, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and the like, and the storage medium can store program codes, and includes instructions for enabling a computer terminal (which may be a personal computer, a server, or a second terminal, a network terminal, and the like) to perform all or part of the steps of the method in the embodiments of the present invention.
The same and similar parts in the various embodiments in this specification may be referred to each other. Especially, for the terminal embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for relevant points, reference may be made to the description in the method embodiment.
In the several embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
Although the present invention has been described in detail by referring to the drawings in connection with the preferred embodiments, the present invention is not limited thereto. Various equivalent modifications or substitutions can be made on the embodiments of the present invention by those skilled in the art without departing from the spirit and scope of the present invention, and these modifications or substitutions are within the scope of the present invention/any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (6)

1. A method for preparing test data, comprising:
creating three test data construction strategies of Search Only, create Only and Auto;
selecting a corresponding construction strategy according to the requirement of the test case on the test data;
preparing test data according to the selected construction strategy;
the method for creating the three test data construction strategies of Search Only, create Only and Auto comprises the following steps:
creating a Search Only strategy for searching corresponding test data through key features from a test database which is created;
creating a Create Only strategy for directly creating test data according to the test data characteristics by using a Builder Pattern mode;
and creating an Auto strategy for searching corresponding test data from the created test database through key features and creating test data which does not exist in the test database according to the test data features by using a Builder Pattern mode.
2. The method of claim 1, wherein selecting the corresponding construction strategy according to the requirement of the test case for the test data comprises:
matching a Search Only strategy for a test case requiring stable test data;
matching a Create Only strategy for the test case requiring unstable test data;
the Auto strategy is matched for test cases requiring stable test data and unstable test data.
3. A test data preparation apparatus, comprising:
the system comprises a strategy creating unit, a strategy selecting unit and a strategy creating unit, wherein the strategy creating unit is configured to Create three test data building strategies of Search Only, create Only and Auto;
the strategy selection unit is configured for selecting a corresponding construction strategy according to the requirement of the test case on the test data;
a data preparation unit configured to prepare test data according to the selected construction strategy;
the policy creating unit includes:
the first creating module is configured to create a Search Only strategy for searching corresponding test data through key features from a test database which is created;
the second creating module is configured to Create a Create Only strategy for directly creating test data according to the test data characteristics by using the Builder Pattern mode;
and the third creating module is configured for creating an Auto strategy which is used for searching corresponding test data from the created test database through the key characteristics and then creating test data which does not exist in the test database according to the test data characteristics by using the Builder Pattern mode.
4. The test data preparation apparatus according to claim 3, wherein the policy selection unit includes:
the first matching module is configured for matching a Search Only strategy for a test case requiring stable test data;
the second matching module is configured to match a Create Only strategy for the test case requiring unstable test data;
and the third matching module is configured to match Auto strategies for the test cases requiring stable test data and unstable test data.
5. A terminal, comprising:
a processor;
a memory for storing instructions for execution by the processor;
wherein the processor is configured to perform the method of any of claims 1-2.
6. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-2.
CN201910147461.4A 2019-02-27 2019-02-27 Test data preparation method, device, terminal and storage medium Active CN109918300B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910147461.4A CN109918300B (en) 2019-02-27 2019-02-27 Test data preparation method, device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910147461.4A CN109918300B (en) 2019-02-27 2019-02-27 Test data preparation method, device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN109918300A CN109918300A (en) 2019-06-21
CN109918300B true CN109918300B (en) 2022-10-18

Family

ID=66962577

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910147461.4A Active CN109918300B (en) 2019-02-27 2019-02-27 Test data preparation method, device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN109918300B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113282499B (en) * 2021-05-31 2024-02-09 长沙市到家悠享家政服务有限公司 Method, system, equipment and medium for creating test data

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109086214A (en) * 2018-09-18 2018-12-25 郑州云海信息技术有限公司 A kind of database write performance test methods, device, terminal and storage medium
CN109101382A (en) * 2018-08-06 2018-12-28 郑州云海信息技术有限公司 A kind of truncate automatic test approach, device, terminal and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109101382A (en) * 2018-08-06 2018-12-28 郑州云海信息技术有限公司 A kind of truncate automatic test approach, device, terminal and storage medium
CN109086214A (en) * 2018-09-18 2018-12-25 郑州云海信息技术有限公司 A kind of database write performance test methods, device, terminal and storage medium

Also Published As

Publication number Publication date
CN109918300A (en) 2019-06-21

Similar Documents

Publication Publication Date Title
US20160321628A1 (en) Online payment method, system, and apparatus
CN108459964B (en) Test case selection method, device, equipment and computer readable storage medium
CN107632827B (en) Method and device for generating installation package of application
CN112765023B (en) Test case generation method and device
CN111858296B (en) Interface testing method, device, equipment and storage medium
CN111651468A (en) Data updating method and device based on SQL analysis, electronic equipment and storage medium
CN112631686A (en) Data processing method, data processing device, computer equipment and storage medium
CN111506579B (en) Method, program and equipment for generating intelligent contract code
CN110149363A (en) A kind of information push method, device and storage medium
CN110990008B (en) Page updating method and device, storage medium and electronic equipment
CN112181749B (en) Hardware testing method, device, electronic equipment and storage medium
CN111949529B (en) System debugging method, device, computer equipment and storage medium
CN110875850A (en) Firmware upgrading method and system, readable storage medium and terminal equipment
US20170277526A1 (en) Software categorization method and electronic device
CN114741070A (en) Code generation method and device, electronic equipment and storage medium
CN106598662A (en) Application loading method and device based on android
CN113127108A (en) Service request processing method and device, storage medium and electronic equipment
CN109918300B (en) Test data preparation method, device, terminal and storage medium
CN114448972A (en) Distributed storage log compression downloading method, system, terminal and storage medium
CN106293679A (en) A kind of element term conflict processing method and device
WO2020233093A1 (en) Association graph generation method and apparatus, computer device, and storage medium
CN111475165A (en) Intelligent compiling method, system, terminal and storage medium for application program
CN116738954A (en) Report export method, report template configuration device and computer equipment
CN115130002A (en) Recommendation request processing method and device, computer equipment and storage medium
CN110059485A (en) Privately owned API detection method, terminal and the storage medium of IOS application

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