Data generation method and system and electronic equipment

By generating reverse operation statements and forming reverse data files, the problem of manual writing of test preparation data is solved, and the generation of automated test preparation data is realized, and the testing efficiency and accuracy are improved.

CN119883933APending Publication Date: 2025-04-25BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510115464.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In automated testing, manually writing tests and preparing data is time-consuming and laborious, and it is prone to writing errors, resulting in test exceptions.

Method used

By obtaining the operation statements in the interface request history of the interface to be tested, an operation statement associated with the same data is determined, a reverse operation statement is generated, and these reverse operation statements are used to generate a reverse data file as test preparation data.

Benefits of technology

The process of generating test preparation data is automated, testing efficiency is improved, manual writing errors are reduced, and the accuracy and stability of the test is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883933A_ABST
    Figure CN119883933A_ABST
Patent Text Reader

Abstract

The invention discloses a data generation method and system and electronic equipment, and the method comprises the steps: obtaining a plurality of operation statements in a historical record of an interface request corresponding to a to-be-tested interface, generating corresponding reverse operation statements based on the plurality of operation statements in the historical record, enabling the plurality of reverse operation statements to form a reverse data file, and transmitting the reverse data file to a server; the reverse data file is used as test preparation data, so that the reverse data file is executed firstly before the to-be-tested interface is tested, and the data corresponding to the operation statement can be executed by the operation statement in the testing process in order to ensure that the operation statement can be executed smoothly in the testing process; the reverse operation statement is firstly executed before the test, so that the operation statement can be executed in the test process, and the condition of test abnormity is avoided; the reverse operation statement generated based on the operation statement in the historical record serves as the test preparation data and is executed before the test, so that the accuracy of the test preparation data is ensured, and the test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing, and in particular to a data generation method, system and electronic device. Background Art

[0002] In the process of writing test cases when testing an interface, data preparation is a key link. The data preparation link prepares the test preparation data that needs to be executed before testing the interface.

[0003] Currently, test preparation data is usually written manually, which is time-consuming and laborious. In addition, manually written test preparation data is prone to writing errors, which may cause abnormalities in interface testing. Summary of the invention

[0004] In view of this, the present application provides a data generation method, system and electronic device, and the specific scheme thereof is as follows:

[0005] A data generation method, comprising:

[0006] Obtain multiple operation statements in the history records of interface requests corresponding to the interface to be tested;

[0007] Determine an operation statement associated through the same data among the multiple operation statements, wherein the operation statements associated through the same data are at least two operation statements that perform operations on the same data;

[0008] generating a reverse operation statement based on the operation statement associated with the same data, wherein the reverse operation statement is used to perform a reverse operation on the same data of the operation performed by the operation statement associated with the same data;

[0009] A reverse data file is generated by using reverse operation statements of different data, and the reverse data file is used as test preparation data for execution before the test is performed on the interface to be tested.

[0010] A data generation system, comprising:

[0011] An obtaining unit, used for obtaining a plurality of operation statements in a history record of an interface request corresponding to the interface to be tested;

[0012] A determining unit, configured to determine, among the plurality of operation statements, operation statements associated by the same data, wherein the operation statements associated by the same data are at least two operation statements that perform operations on the same data;

[0013] A first generating unit, configured to generate a reverse operation statement based on the operation statement associated with the same data, wherein the reverse operation statement is used to perform a reverse operation on the same data to the operation performed by the operation statement associated with the same data;

[0014] The second generating unit is used to generate a reverse data file using reverse operation statements of different data, and the reverse data file is used as test preparation data to be executed before the test interface is tested.

[0015] An electronic device, comprising: a memory and a processor;

[0016] The memory is used to store at least one instruction;

[0017] The processor is used to execute the at least one instruction to implement the data generation method as described in any one of the above.

[0018] A computer program product includes computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the data generation methods described above.

[0019] A computer storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the data generation method as described above is implemented.

[0020] It can be seen from the above technical scheme that the data generation method, system and electronic device disclosed in the present application obtain multiple operation statements in the historical record of the interface request corresponding to the interface to be tested; determine the operation statements associated with the same data among the multiple operation statements, and the operation statements associated with the same data are at least two operation statements that perform operations on the same data; generate a reverse operation statement based on the operation statements associated with the same data, and the reverse operation statement is used to perform the reverse operation on the same data as the operation performed by the operation statement associated with the same data; generate a reverse data file using the reverse operation statements of different data, and the reverse data file is used as test preparation data for execution before the test is performed on the interface to be tested. This scheme obtains multiple operation statements in the historical record of the interface request corresponding to the interface to be tested, and generates corresponding reverse operation statements based on the multiple operation statements in the historical record, composes the multiple reverse operation statements into a reverse data file, and uses the reverse data file as test preparation data, so that before testing the interface to be tested, the reverse data file is first executed. Since the reverse operation statements composing the reverse data file are reverse to the operation statements, to ensure that the operation statements can be executed smoothly during the test, it is necessary to ensure that the data corresponding to the operation statements can be executed during the test. Executing the reverse operation statements first before the test can ensure that the operation statements can be executed during the test and avoid test abnormalities. The reverse data file composed of reverse operation statements generated based on the operation statements in the historical record is used as test preparation data and executed before the test without manual writing, thereby ensuring the accuracy of the test preparation data and improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 A flowchart of a data generation method disclosed in an embodiment of the present application;

[0023] Figure 2 A flowchart of a data generation method disclosed in an embodiment of the present application;

[0024] Figure 3 A flowchart of a data generation method disclosed in an embodiment of the present application;

[0025] Figure 4 A flowchart of a data generation method disclosed in an embodiment of the present application;

[0026] Figure 5 A block diagram of an application data generating method disclosed in an embodiment of the present application;

[0027] Figure 6 A schematic diagram of the structure of a data generation system disclosed in an embodiment of the present application;

[0028] Figure 7 A schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0029] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0030] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0031] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0032] The present application discloses a data generation method, the flow chart of which is as follows: Figure 1 As shown, including:

[0033] Step S11, obtaining multiple operation statements in the history record of the interface request corresponding to the interface to be tested;

[0034] Step S12: determining operation statements associated with the same data among the multiple operation statements, where the operation statements associated with the same data are at least two operation statements that perform operations on the same data;

[0035] Step S13: generating a reverse operation statement based on the operation statement associated with the same data, where the reverse operation statement is used to perform a reverse operation on the same data of the operation performed by the operation statement associated with the same data;

[0036] Step S14: Generate a reverse data file using reverse operation statements of different data. The reverse data file is used as test preparation data and is executed before the test interface is tested.

[0037] In the process of writing interface automated test cases, the determination of test preparation data is a key link. At present, manual writing is usually adopted, but manual writing of test preparation data will lead to low efficiency in determining test preparation data, and at the same time, it may also cause abnormal test situations due to writing errors.

[0038] Based on this, in this scheme, corresponding reverse operation statements are generated through multiple operation statements in the historical records, and reverse operation statements of different data are used to generate reverse data files, and the reverse data files are used as test preparation data. Before executing the test on the interface to be tested, the reverse data file composed of reverse operation statements is first executed to ensure that multiple operation statements can be executed smoothly during the test. For example: if an insert statement needs to be executed on a certain data during the test, then before the test, the reverse data file to be executed needs to include a delete statement, so that the data does not exist after the delete statement is executed. In this way, it can be ensured that the insert operation can be performed on the data during the test. When the insert statement is executed, the reverse operation statement needs to be generated, and the reverse data file generated by the reverse operation statement is used as the test preparation data. The test preparation data is first executed, and then the test process is executed to ensure the smooth execution of the test process. Moreover, in this scheme, the process of generating the reverse data file is automatically completed to ensure the efficiency of determining the test preparation data. At the same time, the test preparation data does not need to be manually written, which can avoid writing errors and effectively reduce the occurrence of test anomalies caused by writing errors.

[0039] Specifically, when it is determined that a certain interface needs to be tested, the interface is determined as the interface to be tested, and multiple operation statements corresponding to the interface to be tested are obtained, and the multiple operation statements are multiple structured query statements SQL, wherein the multiple operation statements corresponding to the interface to be tested can be obtained by: pre-setting the historical records of interface requests corresponding to each interface, after determining the interface to be tested, determining the interface request corresponding to the interface to be tested, and then querying the historical records of the interface requests to determine all the structured query statements SQL of the relational database recorded in the historical records of the interface requests, that is, obtaining multiple operation statements in the historical records of the interface requests corresponding to the interface to be tested.

[0040] For a certain interface to be tested, the interface corresponds to an interface request, which may include multiple SQL statements, such as query select statement, update update statement, and insert insert statement. For example, for an interface for querying history records of a certain application, the interface request may correspond to multiple SQL statements, such as querying all video information in select history records, updating video information in history records, etc. If you want to view all video history records that user A has watched in a certain application, the interface to be tested is an interface for querying history records of a certain application, and the corresponding SQL statement is: query select all watched videos where uid=user A.

[0041] The multiple operation statements for the same test interface in the historical records include operation statements for the same data and operation statements for different data. For the operation statements for the same data, that is, at least two operation statements perform operations on the same data, then the at least two operation statements are determined as operation statements associated through the same data.

[0042] It is determined whether each operation statement in the history record of the interface to be tested is an operation statement associated with other operation statements through the same data, so that when generating a reverse operation statement, one reverse operation statement is generated based on multiple operation statements associated with the same data.

[0043] For example, the multiple operation statements in the history record of the interface request corresponding to the interface to be tested include: a first statement, a second statement, a third statement, a fourth statement and a fifth statement, wherein the first statement is an operation statement for performing an operation on the first data, the second statement is an operation statement for performing an operation on the second data, the third statement is an operation statement for performing an operation on the second data, the fourth statement is an operation statement for performing an operation on the first data, and the fifth statement is an operation statement for performing an operation on the first data. It can be determined that the first statement, the fourth statement and the fifth statement are all operation statements for performing an operation on the first data, and the second statement and the third statement are all operation statements for performing an operation on the second data. It can be determined that the first statement, the fourth statement and the fifth statement are operation statements associated with the same data, i.e., operation statements associated with the first data, and the second statement and the third statement are operation statements associated with the same data, i.e., operation statements associated with the second data. Further, when generating a reverse operation statement, the first statement, the fourth statement and the fifth statement generate a reverse operation statement, which is for the first data, and the second statement and the third statement generate a reverse operation statement, which is for the second data.

[0044] The reverse operation statement is used to perform the reverse operation on the same data of the operation performed by the operation statement associated with the same data, that is, the reverse operation statement and the operation statement associated with the same data used to generate the reverse operation statement both perform operations on the same data, but the operation performed on the same data by the reverse operation statement is the opposite of the operation performed on the same data by the operation statement associated with the same data. For example, if the operation statement associated with the same data performs an insert operation on the same data, then the reverse operation statement performs a delete operation on the same data. The insert operation is the opposite of the delete operation.

[0045] Then, the correspondence between the operation and the reverse operation may be preset, so that when generating the reverse operation statement, the corresponding reverse operation statement may be directly generated based on the preset correspondence.

[0046] Specifically, the correspondence between the preset operations and the reverse operations can be: the insert operation is the reverse correspondence to the delete operation, the query select operation is the reverse correspondence to first deleting the delete operation and then inserting the insert operation, and the update update operation is the reverse correspondence to first deleting the delete operation and then inserting the insert operation. Accordingly, the insert statement is the reverse correspondence to the delete statement, the query select statement is the reverse correspondence to first deleting the delete statement and then inserting the insert statement, and the update update statement is the reverse correspondence to first deleting the delete statement and then inserting the insert statement.

[0047] Since the multiple operation statements include both operation statements for the same data association and operation statements for different data, after generating a reverse operation statement through the operation statements associated with the same data in the multiple operation statements, a reverse operation statement will be generated for each data-associated operation statement, thereby obtaining multiple reverse operation statements corresponding to the multiple operation statements, wherein the number of reverse operation statements is less than or equal to the number of operation statements, such as: there are 10 operation statements in the multiple operation statements obtained, each operation statement corresponds to 1 data, and different operation statements correspond to different data, then 10 reverse operation statements will be obtained, at this time, the number of reverse operation statements is equal to the number of operation statements; if 2 operation statements in the 10 operation statements correspond to the same data, then at this time, there will be 2 operation statements that jointly generate a reverse operation statement, then the number of reverse operation statements will be less than the number of operation statements.

[0048] A reverse data file can be generated by combining all reverse operation statements corresponding to multiple operation statements, so that before testing the interface to be tested, the reverse data file is executed first, so that the interface to be tested can complete the test smoothly; since the data in the reverse data file is automatically generated based on the operation statements in the historical records, there will be no writing errors, which reduces the consumption of manpower and material resources and improves the efficiency and accuracy of reverse data file acquisition.

[0049] In addition, it should be noted that if there is an operation statement among multiple operation statements that does not have an operation statement associated with the same data, then one reverse operation statement may be generated based on only the one operation statement.

[0050] The data generation method disclosed in the present embodiment obtains multiple operation statements in the historical record of the interface request corresponding to the interface to be tested, and generates corresponding reverse operation statements based on the multiple operation statements in the historical record, and the multiple reverse operation statements are composed of a reverse data file, and the reverse data file is used as test preparation data, so that before the test is performed on the interface to be tested, the reverse data file can be executed first. To ensure that the operation statement can be executed smoothly during the test, it is necessary to ensure that the data corresponding to the operation statement can be executed by the operation statement during the test. Since the reverse operation statements and the operation statements that constitute the reverse data file are reversed, then, executing the reverse operation statements first before the test can ensure that the operation statement can be executed during the test to avoid test abnormalities. The reverse data file composed of the reverse operation statements generated based on the operation statements in the historical record is used as test preparation data and executed before the test without manual writing, thereby ensuring the accuracy of the test preparation data and improving the test efficiency.

[0051] This embodiment discloses a data generation method, and its flow chart is as follows: Figure 2 As shown, including:

[0052] Step S21, obtaining multiple operation statements in the history record of the interface request corresponding to the interface to be tested;

[0053] Step S22: determining index information of each operation statement in the plurality of operation statements;

[0054] Step S23: If there are at least two operation statements with the same index information, determine that the at least two operation statements with the same index information are operation statements associated with the same data;

[0055] Step S24: generating a reverse operation statement based on the operation statement associated with the same data, wherein the reverse operation statement is used to perform a reverse operation on the same data of the operation performed by the operation statement associated with the same data;

[0056] Step S25: Generate a reverse data file using reverse operation statements of different data. The reverse data file is used as test preparation data for execution before the test is performed on the interface to be tested.

[0057] When obtaining multiple operation statements in the historical records of interface requests corresponding to the interface to be tested and generating reverse operation statements based on the operation statements, in order to avoid repeated operations, the multiple operation statements can be divided to determine the operation statements associated with the same data, and a reverse operation statement can be generated for at least two operation statements associated with the same data, without repeatedly generating multiple reverse operation statements for multiple operation statements of the same data.

[0058] Specifically, to determine the operation statements associated through the same data among the multiple operation statements, it is possible to determine whether at least two operation statements are operation statements associated through the same data by determining index information of each operation statement.

[0059] The index information may be determined by: a primary key index or a unique key index of an operation statement.

[0060] Determine the primary key index of each operation statement. If at least two operation statements have the same primary key index, it can be determined that the at least two operation statements are operation statements associated with the same data.

[0061] A unique index unique key of each operation statement is determined. If at least two operation statements have the same unique index unique key, it can be determined that the at least two operation statements are operation statements associated with the same data.

[0062] That is, the operation statements associated with the same data can be determined only through the index information, and the operation statements associated with the same data can be determined only through the primary key index primary key in the index information, and the operation statements associated with the same data can also be determined only through the unique index unique key in the index information.

[0063] For example, if it is determined that the primary key index of the first operation statement is the same as the primary key index of the second operation statement, then it is determined that the first operation statement and the second operation statement are operation statements associated with the same data; for another example, if it is determined that the unique index unique key of the first operation statement is the same as the unique index unique key of the second operation statement, then it is determined that the first operation statement and the second operation statement are operation statements associated with the same data;

[0064] In addition, if the primary key index of the first operation statement is different from the primary key index of the second operation statement, it is necessary to further determine whether the unique index unique key of the first operation statement is the same as the unique index unique key of the second operation statement.

[0065] If the primary key indexes of the first operation statement and the second operation statement are different, but the unique indexes of the first operation statement and the second operation statement are the same, then it can be determined that the first operation statement and the second operation statement are operation statements associated by the same data; and if the primary key indexes of the first operation statement and the second operation statement are different, the unique indexes of the first operation statement and the second operation statement are also different, then it is necessary to judge whether all the data information of the first operation statement and the second operation statement is the same.

[0066] Alternatively, it may also be determined whether at least two operation statements are operation statements associated by the same data only through all data information of each operation statement.

[0067] Determine all data information of each operation statement, and compare all data information of the operation statement with all data information of other operation statements. If it is determined that all data information of at least two operation statements is the same, it can be determined that at least two operation statements are operation statements associated by the same data.

[0068] Furthermore, it is also possible to determine whether at least two operation statements are operation statements associated with the same data through the index information and all the data information at the same time.

[0069] For example, when it is determined that all data information of the first operation statement and the second operation statement are different, continue to judge based on the index information of the first operation statement and the second operation statement to determine whether the first operation statement and the second operation statement are operation statements associated by the same data.

[0070] Alternatively, the index information of each operation statement is determined, and the operation statements with the same index information are selected therefrom, and the operation statements with the same index information are determined as operation statements associated through the same data. For other operation statements that have not been selected, all the data information needs to be determined, and when determining all the data information of the operation statements that have not been selected, all the data information can be further determined for each data from the operation statements that have been determined to be associated through the same data, and all the determined all the data information is compared to select the operation statements with the same all the data information, and the selected operation statements with the same all the data information are determined as operation statements associated through the same data, so as to ensure the accuracy of the result of determining whether the operation statements are associated through the same data and avoid omissions.

[0071] Furthermore, in the data generation method disclosed in this embodiment, determining the operation statements associated with the same data among multiple operation statements includes:

[0072] The multiple operation statements are grouped according to data types, and the operation statements associated by the same data are determined from the multiple operation statements included in the same group.

[0073] When multiple operation statements are obtained in the historical records of the interface request corresponding to the interface to be tested, the multiple operation statements can be classified first so that multiple operation statements corresponding to the same data type can be divided into the same group, ensuring that the operation statements associated with the same data are all divided into the same group, reducing the workload and time in determining the operation statements associated with the same data.

[0074] Multiple operation statements can be grouped according to data types, and when grouped into different groups, for multiple operation statements included in each group, operation statements associated with the same data are determined. In addition, the operation statements included in each group can be sorted according to the occurrence time of the operation statements.

[0075] For example, if user A clicks on a video record of a certain application program that has been watched, the video record will be divided into: movie video record, TV series video record, cartoon video record, etc. Then the video records will be grouped according to their categories, and the videos belonging to the same category will be placed in the same group, and the videos belonging to different categories will be placed in different groups. Different groups can be represented in the form of tables, that is, video records in the same group are placed in the same table, and video records in different groups are placed in different tables. For example, table K1 records movie video records, table K2 records TV series video records, and table K3 records cartoon video records. If you want to query the video records of movies that have been watched, you can get the operation statement: select watched movies from table K1 where uid=user A.

[0076] By storing multiple operation statements in groups, it is possible to search only from one group to determine the operation statements associated with the same data, thereby reducing the amount of data search and improving processing efficiency.

[0077] The data generation method disclosed in the present embodiment determines whether at least two operation statements are operation statements associated with the same data through the index information of each operation statement, or determines whether at least two operation statements are operation statements associated with the same data through the entire data information of each operation statement. By judging whether at least two operation statements are operation statements associated with the same data through different information, the accuracy of determining whether at least two operation statements are operation statements associated with the same data is ensured, and the situation that the operation statements are associated with the same data but the judgment is wrong due to incomplete information during the determination is avoided.

[0078] This embodiment discloses a data generation method, and its flow chart is as follows: Figure 3 As shown, including:

[0079] Step S31, obtaining multiple operation statements in the history record of the interface request corresponding to the interface to be tested;

[0080] Step S32: determining operation statements associated with the same data among the multiple operation statements, where the operation statements associated with the same data are at least two operation statements that perform operations on the same data;

[0081] Step S33: determining a first insert statement that performs an insert operation on the first data in the operation statement associated with the first data, parsing the first insert statement, and determining a first field name and a corresponding value corresponding to the first insert statement;

[0082] Step S34, determining a second field name and a corresponding value corresponding to other operation statements associated with the first insert statement through the first data;

[0083] Step S35: merge the first field name and the corresponding value with the second field name and the corresponding value to obtain a merge result, generate a first delete statement for performing a delete operation on the first data based on the merge result, and determine the first delete statement as a first reverse operation statement corresponding to the operation statement associated with the first data;

[0084] Step S36: Generate a reverse data file using reverse operation statements of different data. The reverse data file is used as test preparation data for execution before the test is performed on the interface to be tested.

[0085] After obtaining multiple operation statements in the historical records of the interface request corresponding to the interface to be tested, and determining the operation statements in the multiple operation statements that are associated through the same data, it is necessary to generate a reverse operation statement based on the operation statements associated through the same data. The generation of the reverse operation statement may be different based on the different statements included in the operation statements associated through the same data.

[0086] Specifically, it is determined whether the operation statements associated through the same data include an insert statement. If the insert statement is included, a reverse operation statement is first generated for the operation statements associated through the same data including the insert statement.

[0087] If it is determined that the operation statements associated with the first data include a first insert statement, and the first insert statement is a statement for performing an insert operation on the first data, a first delete statement for performing a delete operation on the first data is generated directly based on the first insert statement, and the first delete statement is used as the first reverse operation statement corresponding to the operation statement associated with the first data.

[0088] For example, the first insert statement is: insert into tableK1 (A, B, C) values ​​(a, b, c). By parsing the first insert statement, the corresponding field names and corresponding values ​​can be parsed, such as: the field names (column names, such as: A, B, C) and corresponding values ​​(values, such as: a, b, c) in Table 1, that is, inserting value a into column A of Table 1, inserting value b into column B of Table 1, and inserting value c into column C of Table 1. The first data parsed based on the first insert statement can be as follows:

[0089] Table 1

[0090] Column Name A B C value a b c

[0091] If it is determined that the operation statement associated with the first insert statement through the same data includes an update statement, the update statement is: update tableK1 set B=b',D=d where A=a, the update statement is parsed to parse out the corresponding field name and the corresponding value, that is, it is determined that b' is updated in column B of table 1, column D is d value, and column A is a value, then the first data parsed based on the update statement is:

[0092] Table 2

[0093] Column Name A B D value a b’ d

[0094] Then the first insert statement is merged with the update statement to obtain a merged result, which is the first data finally obtained, as shown in Table 3:

[0095] Table 3

[0096] Column Name A B C D value a b’ c d

[0097] In this example, the operation statements associated with the same data include the first insert statement and the above-mentioned update statement for explanation. In this example, in the actual test process, the first insert statement and the first update statement need to be executed. Then, in the actual test, the first insert statement inserts a piece of data when Table 1 is empty, and the update statement executed later is executed on the inserted piece of data. Then, before executing the test, it is necessary to ensure that the data inserted by the first insert statement does not exist in Table 1. Therefore, in the test preparation process, that is, before the test starts, it is necessary to ensure that there is no data inserted by the first insert statement in Table 1, that is, it is necessary to execute the first delete statement corresponding to the first insert statement. As long as the first delete statement is executed, it can be ensured that Table 1 is empty, and the first insert statement can be successfully executed during the test. If, during the test process, the first data corresponding to the first insert statement exists in Table 1, then when the first insert statement is executed, since the first data already exists in Table 1, an execution exception problem will occur. Therefore, in this example, the first delete statement is directly generated based on the first insert statement to determine the test preparation data, and it is not necessary to consider what other operation statements associated with the first insert statement through the same data are.

[0098] Among them, the generation condition of the first reverse operation statement may be only related to the insert statement, such as: including index information corresponding to the insert statement. In addition, it may also include: the positions corresponding to other statements except the insert statement in the operation statements associated by the first data, such as the position in the first data corresponding to the query statement, so that the generated first delete statement can not only delete the corresponding data in the insert statement, but also delete the data corresponding to other statements.

[0099] Therefore, as long as the operation statements associated through the same data include an insert statement, a delete statement is directly generated based on the insert statement, and the generated delete statement is used as the reverse operation statement corresponding to the operation statement associated through the same data.

[0100] In actual use, there may be multiple operation statements associated with the same data, which will not be described in detail here.

[0101] In this embodiment, if it is determined that the operation statement associated through the first data includes the first insert statement, a first delete statement is directly generated based on the first insert statement, and the first delete statement is used as the reverse operation statement corresponding to the operation statement associated through the first data, without determining other statements other than the first insert statement in the operation statement associated through the first data for analysis to determine what the other operation statements are specifically, and the first delete statement is directly generated based on the first insert statement, thereby simplifying the steps of generating the reverse operation statement and improving the efficiency of generating the reverse operation statement; in addition, based on the first field name and the corresponding value corresponding to the first insert statement, and the second field name and the corresponding value corresponding to other operation statements associated with the first insert statement through the first data, they are merged to generate the first delete statement, thereby realizing the determination of the position of the first data corresponding to the first delete statement based on the first insert statement and other associated operation statements to ensure the accuracy of the delete statement.

[0102] This embodiment discloses a data generation method, and its flow chart is as follows: Figure 4 As shown, including:

[0103] Step S41, obtaining multiple operation statements in the history record of the interface request corresponding to the interface to be tested;

[0104] Step S42: determining operation statements associated with the same data among the multiple operation statements, where the operation statements associated with the same data are at least two operation statements that perform operations on the same data;

[0105] Step S43, determining an operation statement associated with the second data, where the operation statement associated with the second data consists of a query statement and / or an update statement;

[0106] Step S44, sequentially perform operations on the second data in the order of the operation statements associated with the second data, and obtain a data result after the operation statements associated with the second data are performed on the second data, the data result including: a third field name and a corresponding value;

[0107] Step S45, generating a second reverse operation statement based on the second data and the data result of the second data;

[0108] Step S46: Generate a reverse data file using reverse operation statements of different data. The reverse data file is used as test preparation data for execution before the test is performed on the interface to be tested.

[0109] After obtaining multiple operation statements in the historical records of the interface request corresponding to the interface to be tested, and determining the operation statements in the multiple operation statements that are associated through the same data, it is necessary to generate a reverse operation statement based on the operation statements associated through the same data. The generation of the reverse operation statement may be different based on the different statements included in the operation statements associated through the same data.

[0110] Specifically, if the operation statements associated with the same data consist of query statements and / or update statements, that is, the operation statements associated with the same data do not include insert statements, it is necessary to determine the reverse operation statement based on each statement in the operation statements associated with the same data.

[0111] If the operation statement associated with the second data does not include an insert statement but is composed of a query statement and / or an update statement, the corresponding operations must be performed on the second data in sequence according to the order of the operation statements in the operation statement associated with the second data to obtain the final data result.

[0112] Specifically, determine the operation statements associated through the second data, and determine the order of the operation statements associated through the second data, parse each operation statement associated through the second data to determine the fourth field name and the corresponding value corresponding to each operation statement; merge the fourth field name and the corresponding value corresponding to each determined operation statement in the order of the operation statements to obtain the final data result, that is, the third field name and the corresponding value.

[0113] After obtaining the data result of the second data, a second reverse operation statement is generated based on the data result of the second data (i.e., a second reverse operation statement is generated based on the third field name and the corresponding value), that is, a second reverse operation statement is generated, which can be specifically: a second delete statement and a second insert statement are generated, and in the order of the second delete statement and the second insert statement, the second delete statement and the second insert statement are used as the second reverse operation statement of the operation statement associated with the second data.

[0114] That is, after obtaining the data result of the second data, the second deletion statement and the second insertion statement are directly generated according to the numerical value in the data result of the second data, so as to realize the generation of the reverse operation statement of the operation statement associated through the second data when the operation statement associated through the second data does not include the insertion statement, so as to ensure the accuracy of the generation of the reverse operation statement.

[0115] For example, for the operation statements associated with the second data, the first statement is determined to be a query select statement according to the time sequence of each operation statement, which is: select A, B, C from tableK2 where A=a, and returns a, b, and c. Then, the query select statement is parsed to obtain the following data:

[0116] Table 4

[0117] Column Name A B C value a b c

[0118] For the operation statement associated with the second data, the second statement is determined as a query select statement according to the time sequence of each operation statement, which is: select C from tableK2 where A=a and D=d, and c is returned. Then, the query select statement is parsed to obtain the following data:

[0119] Table 5

[0120] Column Name A C D value a c d

[0121] Then after combining the first statement with the second statement, we get:

[0122] Table 6

[0123] Column Name A B C D value a b c d

[0124] If the operation statement associated by the second data only includes the first statement and the second statement, a reverse operation statement needs to be generated based on the data in Table 6. Since the first statement and the second statement are both select statements, to ensure that the first select statement and the second select statement can be successfully executed during the test, it is necessary to ensure that there is correct data in the table. Only when there is correct data in the table can the select statement be successfully executed. In order to ensure that there is correct data in the table, before the test starts, in the test preparation stage, the data in the table is first deleted, and then the correct data is added to the table. That is, in the test preparation stage, it is necessary to first execute a delete statement and then execute an add insert statement. The generated reverse operation statement includes: deleting a delete statement and adding an insert statement, and the delete statement is first executed, and then the add insert statement is executed. The column names corresponding to the delete statement are A, B, C, and D, and the column names corresponding to the add insert statement are A, B, C, and D, and the corresponding values ​​are a, b, c, and d. That is, the reverse operation statement finally generated is completely consistent with the data in Table 6.

[0125] In addition, if the operation statements associated with the second data are used to determine the existence of a third statement according to the time sequence of each operation statement, and the third statement is an update statement, which is: update tableK2 set A=a', E=e whereD=d, then the data obtained based on the third statement is:

[0126] Table 7

[0127] Column Name A D E value a’ d e

[0128] Then after combining the third statement with the first and second statements, we get:

[0129] Table 8

[0130] Column Name A B C D E value a’ b c d e

[0131] If the operation statement associated by the second data only includes the first statement, the second statement and the third statement, it is necessary to generate a reverse operation statement based on the data in Table 8. Since the first and second statements are select statements and the third statement is an update statement, to ensure that the first select statement, the second select statement and the third update statement can be executed smoothly during the test, it is necessary to ensure that the correct data exists in the table. Only when the correct data exists in the table can the select statement and the update statement be executed smoothly. In order to ensure that the correct data exists in the table, before the test starts, in the test preparation stage, the data in the table is first deleted, and then the correct data is added to the table. That is, in the test preparation stage, it is necessary to first execute a delete statement and then execute an add insert statement. The generated reverse operation statement includes: deleting a delete statement and adding an insert statement, and first executing a delete statement and then executing an add insert statement. Among them, the column names corresponding to deleting the delete statement are A, B, C, D, and E, and the column names corresponding to adding the insert statement are A, B, C, D, and E. , the corresponding values ​​are a, b, c, d, !e, that is, the reverse operation statement finally generated needs to determine the added value, the value opposite to the updated value in the third statement, and the value that does not need to be updated is the same as the value in the second statement, that is, the value of column A needs to be updated in the third statement, and the value a is updated to a', while the first and second statements are both selections, and the value of column A does not need to be changed. Then, the value of column A needs to be guaranteed to be a in the reverse operation statement, so that after executing the first select statement and the second select statement, the value of column A can still be guaranteed to be a, so that the third update statement can be executed smoothly. For other values ​​that do not need to be updated in the third statement, since the first and second statements are both select statements, as long as other values ​​that do not need to be updated are guaranteed to maintain their original values, the three statements can be executed smoothly during testing. For example: for the value c of column C, since the first select statement, the second select statement and the third update statement are all value c, therefore, as long as the value of column C in the reverse operation statement is guaranteed to be c, the first select statement, the second select statement and the third update statement can be executed smoothly during testing.

[0132] As shown in Table 9, the values ​​to be added for the reverse operation statement are:

[0133] Table 9

[0134] Column Name A B C D E value a b c d !e

[0135] Determine the values ​​corresponding to each column in the added insert statement in the second reverse operation statement according to the values ​​of each column in Table 9, wherein the generation conditions of the second reverse operation statement need to include the position corresponding to each operation statement, that is, the position in the second data corresponding to the operation statement, and also need to include the index information of the second data.

[0136] The method disclosed in this embodiment is used to realize the generation of corresponding reverse operation statements when the operation statements associated through the second data are composed of query statements and / or update statements. That is, if the operation statements associated through the second data do not include insert statements and update statements, delete statements and insert statements are directly generated according to the values ​​in the data results obtained after the operation statements associated through the second data are executed. If the operation statements associated through the second data do not include insert statements but include update statements, it is necessary to first determine the values ​​before the update statements are executed according to the values ​​in the data results obtained after the operation statements associated through the second data are executed, and generate delete statements and insert statements according to the values ​​before the update statements are executed.

[0137] Furthermore, in the data generation method disclosed in this embodiment, the query statements included in the operation statements associated with the second data can be specifically limited to query statements with results, and for query statements without results, that is, query statements with empty query results, then:

[0138] Determine a query statement among multiple operation statements. If a query result when the query statement performs a query operation on the third data is empty, generate a third deletion statement for performing a deletion operation on the third data. Determine the third deletion statement as a third reverse operation statement. The third reverse operation statement is a reverse operation statement corresponding to the query statement whose query result is empty when the query operation is performed on the third data.

[0139] That is, as long as it is determined that there is a query statement and the query result of the query statement is empty, a third deletion statement is directly generated and determined as a reverse operation statement corresponding to the query statement, regardless of whether the query statement has an operation statement associated with the third data.

[0140] The generation condition of the third reverse operation statement needs to include the position corresponding to the query statement, that is, the third reverse operation statement is generated based on the position of the position corresponding to the query statement in the third data.

[0141] The data generation method disclosed in this embodiment, when determining that the operation statement associated with the second data is composed of query statements and / or update statements, executes the corresponding statements in sequence based on the order in the operation statement associated with the second data to obtain the data result of the second data after the execution is completed, so as to generate a reverse operation statement based on the data result of the second data, thereby ensuring that the reverse operation statement is completely corresponding to the operation statement associated with the second data, avoiding the problem of abnormality in the test of the interface to be tested due to inaccurate execution of the reverse operation.

[0142] Specifically, the acquisition of data used in the data generation method disclosed in this embodiment and the application of the generated test preparation data can be based on the following: Figure 5 The block diagram shown is implemented, namely: first, the user performs a manual test to test the service under test, and during the test, a traffic recording tool is mounted to record the test to obtain the data operation record during the manual test, and after the manual test is completed, the data operation record is sent to the traffic recording database for storage; when it is necessary to generate a reverse data file by the data generation method disclosed in this embodiment, the data generation method disclosed in this embodiment can obtain relevant data from the traffic recording database, and use the data generation method to generate a reverse data file (i.e., test preparation data), and then, the test preparation data is used to automatically perform the test to realize the process of generating test preparation data and automatic testing.

[0143] This embodiment discloses a data generation system, and its structural diagram is as follows: Figure 6 As shown, including:

[0144] An obtaining unit 61 , a determining unit 62 , a first generating unit 63 and a second generating unit 64 .

[0145] The obtaining unit 61 is used to obtain multiple operation statements in the history record of the interface request corresponding to the interface to be tested;

[0146] The determining unit 62 is used to determine the operation statements associated with the same data among the multiple operation statements, where the operation statements associated with the same data are at least two operation statements that perform operations on the same data;

[0147] The first generating unit 63 is used to generate a reverse operation statement based on the operation statement associated with the same data, and the reverse operation statement is used to perform a reverse operation on the same data to the operation performed by the operation statement associated with the same data;

[0148] The second generating unit 64 is used to generate a reverse data file using reverse operation statements of different data, and the reverse data file is used as test preparation data for execution before the test interface is tested.

[0149] Furthermore, the determination unit is used to:

[0150] Determine index information of each operation statement in the plurality of operation statements; if it is determined that at least two operation statements have the same index information, determine that the at least two operation statements with the same index information are operation statements associated by the same data;

[0151] or,

[0152] Determine all data information of each operation statement in the plurality of operation statements; if there are at least two operation statements with the same all data information, determine that the at least two operation statements with the same all data information are operation statements associated by the same data.

[0153] Furthermore, the first generating unit is used for:

[0154] Determine a first insert statement that performs an insert operation on the first data among the operation statements associated with the first data; parse the first insert statement to determine a first field name and a corresponding value corresponding to the first insert statement; determine a second field name and a corresponding value corresponding to other operation statements associated with the first insert statement through the first data; merge the first field name and the corresponding value with the second field name and the corresponding value to obtain a merged result, generate a first delete statement that performs a delete operation on the first data based on the merged result, and determine the first delete statement as a first reverse operation statement corresponding to the operation statement associated with the first data.

[0155] Furthermore, the first generating unit is used for:

[0156] Determine an operation statement associated through the second data, the operation statement associated through the second data consisting of a query statement and / or an update statement; perform operations on the second data in sequence according to the order of the operation statements associated through the second data, and obtain a data result after executing the operation statements associated through the second data on the second data, the data result including: a third field name and a corresponding value; and a second reverse operation statement generated based on the data result of the second data.

[0157] Furthermore, the first generating unit is used for:

[0158] A second delete statement and a second insert statement are generated based on the data result of the second data; and the second delete statement and the second insert statement are used as second reverse operation statements of the operation statement associated with the second data in the order of the second delete statement and the second insert statement.

[0159] Furthermore, the data generation system disclosed in this embodiment may also include:

[0160] The third generating unit is used to determine a query statement among multiple operation statements; if it is determined that the query result when the query statement performs a query operation on the third data is empty, a third deletion statement for performing a deletion operation on the third data is generated, and the third deletion statement is determined as a third reverse operation statement, and the third reverse operation statement is a reverse operation statement corresponding to the query statement whose query result when the query operation is performed on the third data is empty.

[0161] Furthermore, the determination unit is used to:

[0162] Multiple operation statements are grouped according to data types; and operation statements associated with the same data are determined from the multiple operation statements included in the same group.

[0163] The data generation system disclosed in this embodiment is implemented based on the data generation method disclosed in the above embodiment, which will not be described in detail here.

[0164] The data generation system disclosed in the present embodiment obtains multiple operation statements in the historical records of interface requests corresponding to the interface to be tested; determines the operation statements associated with the same data among the multiple operation statements, and the operation statements associated with the same data are at least two operation statements that perform operations on the same data; generates a reverse operation statement based on the operation statements associated with the same data, and the reverse operation statement is used to perform a reverse operation on the same data as the operation performed by the operation statement associated with the same data; generates a reverse data file using the reverse operation statements of different data, and the reverse data file is used as test preparation data for execution before the test is performed on the interface to be tested. This scheme obtains multiple operation statements in the historical record of the interface request corresponding to the interface to be tested, and generates corresponding reverse operation statements based on the multiple operation statements in the historical record, composes the multiple reverse operation statements into a reverse data file, and uses the reverse data file as test preparation data, so that before testing the interface to be tested, the reverse data file is first executed. Since the reverse operation statements composing the reverse data file are reverse to the operation statements, to ensure that the operation statements can be executed smoothly during the test, it is necessary to ensure that the data corresponding to the operation statements can be executed during the test. Executing the reverse operation statements first before the test can ensure that the operation statements can be executed during the test and avoid test abnormalities. The reverse data file composed of reverse operation statements generated based on the operation statements in the historical record is used as test preparation data and executed before the test without manual writing, thereby ensuring the accuracy of the test preparation data and improving the test efficiency.

[0165] This embodiment discloses an electronic device, and its structural diagram is as follows: Figure 7 As shown, including:

[0166] Memory 71 and processor 72.

[0167] Wherein, the memory 71 is used to store at least one instruction;

[0168] The processor 72 is configured to execute at least one execution to implement any of the above data generation methods.

[0169] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any data generation method provided in the embodiment of the present application.

[0170] The present application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the data generation methods provided in the present application.

[0171] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0172] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0173] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0174] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A data generation method, characterized in that: include: Obtain multiple operation statements in the history records of interface requests corresponding to the interface to be tested; Determine an operation statement associated through the same data among the multiple operation statements, wherein the operation statements associated through the same data are at least two operation statements that perform operations on the same data; generating a reverse operation statement based on the operation statement associated with the same data, wherein the reverse operation statement is used to perform a reverse operation on the same data of the operation performed by the operation statement associated with the same data; A reverse data file is generated by using reverse operation statements of different data, and the reverse data file is used as test preparation data for execution before the test is performed on the interface to be tested.

2. The method according to claim 1, characterized in that The determining of the operation statements among the multiple operation statements that are associated by the same data includes: Determining index information of each operation statement in the plurality of operation statements; If there are at least two operation statements with the same index information, determining that the at least two operation statements with the same index information are operation statements associated with the same data; or, Determining all data information of each operation statement in the plurality of operation statements; If there are at least two operation statements with all data information being identical, it is determined that the at least two operation statements with all data information being identical are operation statements associated by the same data.

3. The method according to claim 1, characterized in that The generating a reverse operation statement based on the operation statement associated by the same data comprises: Determine a first insert statement that performs an insert operation on the first data among the operation statements associated with the first data; parse the first insert statement to determine a first field name and a corresponding value corresponding to the first insert statement; Determine a second field name and a corresponding value corresponding to other operation statements associated with the first insert statement through the first data; The first field name and the corresponding value are merged with the second field name and the corresponding value to obtain a merged result, and based on the merged result, a first delete statement is generated to perform a delete operation on the first data, and the first delete statement is determined as a first reverse operation statement corresponding to the operation statement associated with the first data.

4. The method according to claim 1, characterized in that: The generating a reverse operation statement based on the operation statement associated by the same data comprises: Determine an operation statement associated with the second data, wherein the operation statement associated with the second data consists of a query statement and / or an update statement; According to the order of the operation statements associated with the second data, operations are sequentially performed on the second data to obtain data results after the operation statements associated with the second data are performed on the second data, the data results comprising: a third field name and a corresponding value; A second reverse operation statement is generated based on the data result of the second data.

5. The method according to claim 4, characterized in that The second reverse operation statement generated based on the data result of the second data includes: Generate a second delete statement and a second insert statement based on the data result of the second data; According to the order of the second delete statement and the second insert statement, the second delete statement and the second insert statement are used as second reverse operation statements of the operation statement associated by the second data.

6. The method according to claim 4, characterized in that Before determining the operation statement associated with the second data, the method further includes: Determining a query statement among the multiple operation statements; If it is determined that the query result when the query statement performs a query operation on the third data is empty, a third deletion statement is generated to perform a deletion operation on the third data, and the third deletion statement is determined as a third reverse operation statement, and the third reverse operation statement is a reverse operation statement corresponding to the query statement whose query result when the query operation is performed on the third data is empty.

7. The method according to claim 1, characterized in that The determining of the operation statements among the multiple operation statements that are associated by the same data includes: Grouping the multiple operation statements according to data types; From a plurality of operation statements included in the same group, operation statements associated by the same data are determined.

8. A data generation system, characterized in that: include: An obtaining unit, used for obtaining a plurality of operation statements in a history record of an interface request corresponding to the interface to be tested; A determining unit, configured to determine, among the plurality of operation statements, operation statements associated by the same data, wherein the operation statements associated by the same data are at least two operation statements that perform operations on the same data; A first generating unit, configured to generate a reverse operation statement based on the operation statement associated with the same data, wherein the reverse operation statement is used to perform a reverse operation on the same data to the operation performed by the operation statement associated with the same data; The second generating unit is used to generate a reverse data file using reverse operation statements of different data, and the reverse data file is used as test preparation data to be executed before the test interface is tested.

9. An electronic device, characterized in that: The electronic device comprises: a memory and a processor; The memory is used to store at least one instruction; The processor is used to execute the at least one instruction to implement the data generation method according to any one of claims 1 to 7.

10. A computer program product, characterized in that It comprises computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the data generating method as claimed in any one of claims 1 to 7.

11. A computer storage medium, characterized in that: The computer storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the data generation method according to any one of claims 1 to 7 is implemented.