CN111694732A - Test data generation method and device - Google Patents

Test data generation method and device Download PDF

Info

Publication number
CN111694732A
CN111694732A CN202010433182.7A CN202010433182A CN111694732A CN 111694732 A CN111694732 A CN 111694732A CN 202010433182 A CN202010433182 A CN 202010433182A CN 111694732 A CN111694732 A CN 111694732A
Authority
CN
China
Prior art keywords
functional interface
test data
data
tested
functional
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.)
Pending
Application number
CN202010433182.7A
Other languages
Chinese (zh)
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.)
New H3C Big Data Technologies Co Ltd
Original Assignee
New H3C Big Data Technologies 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 New H3C Big Data Technologies Co Ltd filed Critical New H3C Big Data Technologies Co Ltd
Priority to CN202010433182.7A priority Critical patent/CN111694732A/en
Publication of CN111694732A publication Critical patent/CN111694732A/en
Pending legal-status Critical Current

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 present disclosure relates to the field of data testing technologies, and in particular, to a method and an apparatus for generating test data. The test data generation method comprises the following steps: acquiring original test data by using a data grabbing tool, wherein the original test data is used for manually testing each functional interface of a system to be tested; classifying and format converting the original test data to obtain test data in a specified format corresponding to each functional interface; and respectively executing the following operations aiming at the test data with the specified format corresponding to each functional interface in each functional interface: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.

Description

Test data generation method and device
Technical Field
The present disclosure relates to the field of data testing technologies, and in particular, to a method and an apparatus for generating test data.
Background
The Robot Framework is an open-source automatic testing Framework written by Python, supports keyword, data and behavior drive, has the advantages of strong expansibility, strong usability, distributed testing support and the like, and is widely applied in the upper software testing field because of having rich opposite testing interface libraries in the upper software field such as the Internet and the like.
At present, the Robot Framework has an easy-to-use table test data syntax and uses a keyword-driven test method. However, the test data and the test cases of the system need to be manually compiled by a tester according to the functions of the system to be tested, the universality is poor, and after the system to be tested is upgraded and improved and the function modules are added, the original test data and the test cases need to be manually modified according to the added functions of the original function modules of the upgraded system, and the test data and the test cases need to be manually added according to the added function modules of the system.
Disclosure of Invention
The embodiment of the application provides a test data generation method and device, which are used for solving the problem of low test case generation efficiency in the prior art.
The embodiment of the application provides the following specific technical scheme:
in a first aspect, the present application provides a method for generating test data, where the method includes:
acquiring original test data by using a data grabbing tool, wherein the original test data is used for manually testing each functional interface of a system to be tested;
classifying and format converting the original test data to obtain test data in a specified format corresponding to each functional interface;
and respectively executing the following operations aiming at the test data with the specified format corresponding to each functional interface in each functional interface: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.
Optionally, the step of acquiring the original test data by using the data capture tool includes:
when each functional interface of the system to be tested is tested manually, a Fiddler is used for grabbing request packets sent to each functional interface of the system to be tested.
Optionally, the step of classifying and format converting the original test data to obtain test data in a specific format corresponding to each functional interface includes:
determining original test data corresponding to each functional interface;
and aiming at each functional interface in the functional interfaces, extracting data with specified attributes from the original test data corresponding to the functional interface, and converting the extracted data with the specified attributes into json files corresponding to the functional interface, wherein the data with the specified attributes at least comprises url, method, data and params.
Optionally, the step of generating the corresponding test case based on the test data in the specified format corresponding to the functional interface includes:
taking data and params included in the json file corresponding to the functional interface as data of a test case corresponding to the functional interface;
and packaging url and method included in the json file corresponding to the functional interface into Library corresponding to the functional interface.
In a second aspect, the present application provides a test data generating apparatus, the apparatus comprising:
the system comprises an acquisition unit, a test unit and a control unit, wherein the acquisition unit is used for acquiring original test data by using a data grabbing tool, and the original test data is used for manually testing each functional interface of a system to be tested;
the processing unit is used for classifying and converting the format of the original test data to obtain test data in a specified format corresponding to each functional interface;
a generating unit, configured to execute the following operations for the test data in the specified format corresponding to each functional interface in each functional interface: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.
Optionally, when the original test data is acquired by using the data capture tool, the acquiring unit is specifically configured to:
when each functional interface of the system to be tested is tested manually, a Fiddler is used for grabbing request packets sent to each functional interface of the system to be tested.
Optionally, when the classification and format conversion processing is performed on the original test data to obtain test data in the specified format respectively corresponding to each functional interface, the processing unit is specifically configured to:
determining original test data corresponding to each functional interface;
and aiming at each functional interface in the functional interfaces, extracting data with specified attributes from the original test data corresponding to the functional interface, and converting the extracted data with the specified attributes into json files corresponding to the functional interface, wherein the data with the specified attributes at least comprises url, method, data and params.
Optionally, when the test case corresponding to the test data in the specified format is generated based on the test data in the specified format corresponding to the functional interface, the generating unit is specifically configured to:
taking data and params included in the json file corresponding to the functional interface as data of a test case corresponding to the functional interface;
and packaging url and method included in the json file corresponding to the functional interface into Library corresponding to the functional interface.
In a third aspect, the present application provides another RAID card failure processing apparatus, including:
a memory for storing program instructions;
and a processor, configured to call the program instructions stored in the memory, and execute any one of the methods according to the first aspect according to the obtained program.
In a fourth aspect, the present application provides a computer storage medium having stored thereon computer-executable instructions for causing a computer to perform the method of any of the first aspects.
The beneficial effect of this application is as follows:
in summary, the test data generation method provided by the present application obtains original test data by using a data capture tool, where the original test data is used when each functional interface of a system to be tested is manually tested; classifying and format converting the original test data to obtain test data in a specified format corresponding to each functional interface; and respectively executing the following operations aiming at the test data with the specified format corresponding to each functional interface in each functional interface: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.
By adopting the test data generation method provided by the application, the original test data when the system to be tested is tested manually is automatically acquired, the original test data is classified and subjected to format conversion, and the test case of the functional interface is generated according to the converted test data corresponding to each functional interface, so that the automatic generation of the test case is realized, and the generation efficiency of the test case is improved.
Drawings
Fig. 1 is a schematic flowchart of a test data generation method according to an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of a test data generating apparatus according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of another test data generation apparatus according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
First, the term "and" in the embodiment of the present application is only one kind of association relationship describing an associated object, and means that three kinds of relationships may exist, for example, a and B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
When the present application refers to the ordinal numbers "first", "second", "third" or "fourth", etc., it should be understood that this is done for differentiation only, unless it is clear from the context that the order is actually expressed.
The scheme of the present application will be described in detail by specific examples, but the present application is not limited to the following examples.
Exemplarily, referring to fig. 1, a schematic flow chart of a test data generation method provided by the present application is shown, and a detailed flow chart of the test data generation method is as follows:
step 100: and acquiring original test data by using a data grabbing tool, wherein the original test data is used for manually testing each functional interface of the system to be tested.
In the embodiment of the present application, when the data capture tool is used to obtain the original test data, a preferred implementation manner is to capture the request packet sent to each functional interface of the system under test by using the Fiddler when each functional interface of the system under test is manually tested.
In practical application, the system to be tested includes several service functions, such as adding a user, providing a user list, deleting a user, etc., different service functions are implemented by different function interfaces (or function modules), and when a certain service function needs to be provided by the system to be tested, a request packet needs to be sent to a function interface corresponding to the service function. Then, testing a certain service function of the system under test means testing a functional interface corresponding to the service function. Obviously, the process of manually testing a functional interface may include: the user inputs test data (HTTP request packet) through the terminal and sends the test data to the functional interface, and when the functional interface receives the test data, response data corresponding to the test data is generated according to the service logic, so that the user can judge whether the functional interface passes the test according to the response data.
In the embodiment of the present application, when each functional interface of the system to be tested is manually tested, a data packet capture tool (e.g., Fiddler) may be used to capture interactive data between the terminal and each functional interface.
Step 110: and classifying and converting the original test data to obtain the test data with the specified format corresponding to each functional interface.
In the embodiment of the present application, when the original test data is classified and format-converted to obtain the test data in the specified format corresponding to each functional interface, a preferred implementation manner is to determine the original test data corresponding to each functional interface; for each functional interface in the functional interfaces, extracting data with specified attributes from original test data corresponding to the functional interface, and converting the extracted data with the specified attributes into json files corresponding to the functional interface, wherein the data with the specified attributes at least comprises url (address locator), method (method function), data (data requesting to be filled) and params (character string type).
In practical application, the url is carried by the original test data of each functional interface, and the url carried in the original test data is used for indicating that the test data is sent to a specific functional interface, so that the original test data can be classified based on the url carried by each original test data, and since each functional interface corresponds to a unique url, all the original test data to be captured is divided into the original test data corresponding to each functional interface.
Further, based on each python-based recursion method and/or data crawling function, the original test data corresponding to each functional interface is filtered, and specified data (such as url, method, data and params) are extracted and stored as a corresponding json format file.
Step 120: aiming at the test data with the specified format corresponding to each functional interface in the functional interfaces, the following operations are respectively executed: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.
In the embodiment of the application, when the test case corresponding to the functional interface is generated based on the test DATA in the specified format corresponding to the functional interface, a preferred implementation manner is that DATA and params included in a json file corresponding to the functional interface are used as DATA of the test case corresponding to the functional interface; and packaging url and method included in the json file corresponding to the functional interface into Library corresponding to the functional interface.
In practical application, a test case at least includes a function/command to be called and data to be filled in a sent request packet. In the embodiment of the present application, when a test case corresponding to one functional interface is generated, DATA and DATA with params attribute in a json file corresponding to the one functional interface, which are obtained after filtering and converting the format, may be used as DATA of the test case corresponding to the one interface function, and DATA with url and method attribute in the json file corresponding to the one functional interface, which are obtained after filtering and converting the format, may be encapsulated, and the encapsulated DATA may be used as Library of the test case corresponding to the one interface function.
As can be seen from the above, in the embodiment of the present application, the test cases corresponding to the functional interfaces are respectively obtained according to the json files corresponding to the functional interfaces, and then when a Robot Framework is used to test other systems to be tested (the same system to be tested, which may be understood as the system to be tested installed on different terminals), one way is: a user carries out testing by inputting keywords, for example, a corresponding function in Library is called directly according to the keywords input by the user, and a request filled with test DATA is sent to an interface corresponding to url by using the corresponding test DATA (DATA and params DATA) in DATA; the other mode is that according to the url carried by the request, a function corresponding to the url in the Library is determined, corresponding test DATA (DATA and params DATA) in the DATA is determined, and the request filled with the test DATA is sent to an interface corresponding to the url.
Based on the foregoing embodiment, referring to fig. 2, a test data generating apparatus provided by the present application includes:
the system comprises an acquisition unit 20, a data capture tool and a data acquisition unit, wherein the acquisition unit is used for acquiring original test data by using the data capture tool, and the original test data is used for manually testing each functional interface of a system to be tested;
a processing unit 21, configured to classify and format-convert the original test data to obtain test data in a specified format corresponding to each functional interface;
a generating unit 22, configured to execute the following operations for the test data in the specified format corresponding to each of the functional interfaces: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.
Optionally, when the original test data is acquired by using the data capture tool, the acquiring unit 20 is specifically configured to:
when each functional interface of the system to be tested is tested manually, a Fiddler is used for grabbing request packets sent to each functional interface of the system to be tested.
Optionally, when the classification and format conversion processing is performed on the original test data to obtain test data in the specified format respectively corresponding to each functional interface, the processing unit 21 is specifically configured to:
determining original test data corresponding to each functional interface;
and aiming at each functional interface in the functional interfaces, extracting data with specified attributes from the original test data corresponding to the functional interface, and converting the extracted data with the specified attributes into json files corresponding to the functional interface, wherein the data with the specified attributes at least comprises url, method, data and params.
Optionally, when the test case corresponding to the test data in the specified format based on the functional interface is generated, the generating unit 22 is specifically configured to:
taking data and params included in the json file corresponding to the functional interface as data of a test case corresponding to the functional interface;
and packaging url and method included in the json file corresponding to the functional interface into Library corresponding to the functional interface.
Further, referring to fig. 3, the present application also provides a test data generating apparatus including a memory 30 and a processor 31, wherein,
a memory 30 for storing program instructions;
and a processor 31 for calling the program instructions stored in the memory 30 and executing any one of the above method embodiments according to the obtained program.
Still further, the present application provides a computer storage medium having computer-executable instructions stored thereon for causing a computer to perform any of the above-described method embodiments.
In summary, the test data generation method provided by the present application obtains original test data by using a data capture tool, where the original test data is used when each functional interface of a system to be tested is manually tested; classifying and format converting the original test data to obtain test data in a specified format corresponding to each functional interface; and respectively executing the following operations aiming at the test data with the specified format corresponding to each functional interface in each functional interface: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.
By adopting the test data generation method provided by the application, the original test data when the system to be tested is tested manually is automatically acquired, the original test data is classified and subjected to format conversion, and the test case of the functional interface is generated according to the converted test data corresponding to each functional interface, so that the automatic generation of the test case is realized, and the generation efficiency of the test case is improved.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various changes and modifications may be made in the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if such modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to encompass such modifications and variations.

Claims (10)

1. A method of test data generation, the method comprising:
acquiring original test data by using a data grabbing tool, wherein the original test data is used for manually testing each functional interface of a system to be tested;
classifying and format converting the original test data to obtain test data in a specified format corresponding to each functional interface;
and respectively executing the following operations aiming at the test data with the specified format corresponding to each functional interface in each functional interface: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.
2. The method of claim 1, wherein the step of acquiring raw test data using a data capture tool comprises:
when each functional interface of the system to be tested is tested manually, a Fiddler is used for grabbing request packets sent to each functional interface of the system to be tested.
3. The method according to claim 1, wherein the step of classifying and converting the original test data to obtain the test data in the designated format corresponding to each functional interface comprises:
determining original test data corresponding to each functional interface;
and aiming at each functional interface in the functional interfaces, extracting data with specified attributes from the original test data corresponding to the functional interface, and converting the extracted data with the specified attributes into json files corresponding to the functional interface, wherein the data with the specified attributes at least comprises url, method, data and params.
4. The method of claim 3, wherein the step of generating the corresponding test case based on the test data in the specified format corresponding to the functional interface comprises:
taking data and params included in the json file corresponding to the functional interface as data of a test case corresponding to the functional interface;
and packaging url and method included in the json file corresponding to the functional interface into Library corresponding to the functional interface.
5. A test data generation apparatus, characterized in that the apparatus comprises:
the system comprises an acquisition unit, a test unit and a control unit, wherein the acquisition unit is used for acquiring original test data by using a data grabbing tool, and the original test data is used for manually testing each functional interface of a system to be tested;
the processing unit is used for classifying and converting the format of the original test data to obtain test data in a specified format corresponding to each functional interface;
a generating unit, configured to execute the following operations for the test data in the specified format corresponding to each functional interface in each functional interface: and generating a corresponding test case based on the test data in the specified format corresponding to the functional interface.
6. The apparatus of claim 5, wherein, when the raw test data is obtained using the data capture tool, the obtaining unit is specifically configured to:
when each functional interface of the system to be tested is tested manually, a Fiddler is used for grabbing request packets sent to each functional interface of the system to be tested.
7. The apparatus according to claim 5, wherein when the original test data is classified and format-converted to obtain test data in a specific format corresponding to each functional interface, the processing unit is specifically configured to:
determining original test data corresponding to each functional interface;
and aiming at each functional interface in the functional interfaces, extracting data with specified attributes from the original test data corresponding to the functional interface, and converting the extracted data with the specified attributes into json files corresponding to the functional interface, wherein the data with the specified attributes at least comprises url, method, data and params.
8. The apparatus according to claim 7, wherein, when the test case corresponding to the test data in the specified format is generated based on the test data corresponding to the functional interface, the generating unit is specifically configured to:
taking data and params included in the json file corresponding to the functional interface as data of a test case corresponding to the functional interface;
and packaging url and method included in the json file corresponding to the functional interface into Library corresponding to the functional interface.
9. A computing device, wherein the computing device comprises:
a memory for storing program instructions;
a processor for calling the program instructions stored in the memory and executing the method of any one of claims 1 to 4 according to the obtained program.
10. A computer storage medium having computer-executable instructions stored thereon for causing a computer to perform the method of any one of claims 1-4.
CN202010433182.7A 2020-05-21 2020-05-21 Test data generation method and device Pending CN111694732A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010433182.7A CN111694732A (en) 2020-05-21 2020-05-21 Test data generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010433182.7A CN111694732A (en) 2020-05-21 2020-05-21 Test data generation method and device

Publications (1)

Publication Number Publication Date
CN111694732A true CN111694732A (en) 2020-09-22

Family

ID=72477085

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010433182.7A Pending CN111694732A (en) 2020-05-21 2020-05-21 Test data generation method and device

Country Status (1)

Country Link
CN (1) CN111694732A (en)

Similar Documents

Publication Publication Date Title
CN107193750B (en) Script recording method and device
CN107453960B (en) Method, device and system for processing test data in service test
CN108584598B (en) Elevator fault automatic analysis and early warning method, storage medium and intelligent terminal
CN109376088B (en) Automatic test system and automatic test method
US9632899B2 (en) Method for analyzing request logs in advance to acquire path information for identifying problematic part during operation
CN111241073B (en) Data quality inspection method and device
CN105607986A (en) Acquisition method and device of user behavior log data
CN110515795B (en) Big data component monitoring method and device and electronic equipment
CN109190368B (en) SQL injection detection device and SQL injection detection method
CN110019067A (en) A kind of log analysis method and system
CN117215910A (en) Interface test frame generation method, test method, electronic device and storage medium
CN111090593A (en) Method, device, electronic equipment and storage medium for determining crash attribution
CN106648912B (en) Modularization method and device for data processing in data acquisition platform
CN111694732A (en) Test data generation method and device
EP2990983B1 (en) Method and apparatus for scanning files
CN109542775B (en) Test script generation and execution method and device
CN110716866A (en) Code quality scanning method and device, computer equipment and storage medium
CN115757174A (en) Database difference detection method and device
CN115987821A (en) Gateway routing test method and device
CN110768957B (en) Network security cooperative processing method, system and storage medium
AU2013206622B2 (en) Download management method and device based on Android browser
CN110019448B (en) Data interaction method and device
CN112597119A (en) Method and device for generating processing log and storage medium
CN113806205A (en) Software performance testing method and device, electronic equipment and readable storage medium
CN114818645B (en) Automatic report generation method, device, equipment and medium based on data body

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