Method, device and equipment for determining test data model and generating test data

By generating a test data model based on historical logs, the problem of low reliability of test script data in the financial technology field is solved, and more accurate test results are achieved.

CN112231232BActive Publication Date: 2025-03-11WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011294901.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-18
Publication Date
2025-03-11
Estimated Expiration
2040-11-18

AI Technical Summary

Technical Problem

In the field of financial technology, the data constructed in test scripts are less reliable, resulting in inaccurate test results.

Method used

By determining the first field in the data table update operation related to the operation scenario, and generating a test data model based on the number of occurrences of field values ​​in the historical log, it is used to generate a diverse field value in the test scenario.

Benefits of technology

Improve the reliability of the test data, reduce the probability of repeated field values, and thus improve the accuracy of the test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112231232B_ABST
    Figure CN112231232B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and equipment for determining a test data model and generating test data. The method for determining a test data model comprises: determining the first field corresponding to the update of each data table update operation in all data table update operations related to a set operation scenario; based on at least one historical log corresponding to the set operation scenario, determining all field values ​​of each first field in all first fields that appear in the at least one historical log and the number of occurrences corresponding to the field value; based on all field values ​​of each first field that appear in the at least one historical log and the number of occurrences corresponding to the field value, generating a test data model corresponding to the set operation scenario; the test data model represents all field values ​​that can be obtained by each first field in all first fields and the corresponding occurrence probabilities of the field values; the test data model is used to generate a field value for testing for each first field when testing the set operation scenario.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software testing, and in particular to a method, device and equipment for determining a test data model and generating test data. Background Art

[0002] With the development of computer technology, more and more technologies are applied in the financial field. Traditional finance is gradually transforming into financial technology. However, due to the security and real-time requirements of the financial industry, financial technology also puts forward higher requirements on technology. In the field of financial technology, in order to better simulate the real test environment, it is necessary to construct the data of each parameter in the test script. However, in the related technology, the data constructed in the test script is single and prone to duplicate data, resulting in low reliability of the constructed data, which in turn leads to inaccurate corresponding test results. Summary of the invention

[0003] In view of this, embodiments of the present invention are intended to provide a method, apparatus and device for determining a test data model and generating test data, so as to solve the technical problem of low reliability of data constructed in test scripts in related technologies.

[0004] To achieve the above object, the technical solution of the present invention is achieved as follows:

[0005] An embodiment of the present invention provides a method for determining a test data model, including:

[0006] Determine a first field to be updated for each data table update operation in all data table update operations related to the set operation scenario;

[0007] Based on at least one historical log corresponding to the set operation scenario, determine all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log;

[0008] Based on all the field values ​​of each first field in all the determined first fields that appear in the at least one historical log and the number of occurrences of the field values, a test data model corresponding to the set operation scenario is generated; wherein,

[0009] The test data model represents all field values ​​that can be obtained by each first field in all first fields and the corresponding occurrence probabilities of the field values; the test data model is used to generate a field value for testing for each first field in all first fields when testing the set operation scenario.

[0010] In the above scheme, the method further includes:

[0011] Monitor the operation of all databases and obtain the log files of each database in all databases;

[0012] All obtained log files are parsed to determine at least one historical log corresponding to the set operation scenario.

[0013] In the above scheme, when generating the test data model corresponding to the set operation scenario based on all field values ​​of each first field in all determined first fields appearing in the at least one historical log and the number of occurrences corresponding to the field value, the method includes:

[0014] Determine a first identifier corresponding to the first field based on all field values ​​of the first field that appear in the at least one historical log and the number of occurrences of the field values; the first identifier represents the distribution of all field values ​​that appear in the at least one historical log;

[0015] A setting algorithm corresponding to the first identifier is used to determine all field values ​​that can be obtained by the first field and the corresponding occurrence probabilities of the field values.

[0016] In the above solution, the setting algorithm corresponding to the first identifier is used to determine all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values, including one of the following:

[0017] When the first identifier indicates that only one field value of the first field appears in the at least one historical log, determining that all field values ​​that the first field can take are the one field value, and determining that the occurrence probability corresponding to the one field value is 1;

[0018] When the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, and the number of field values ​​of the at least two field values ​​is less than or equal to the set number, determining that all field values ​​that can be obtained by the first field are the at least two field values, and determining the occurrence probability of each field value in the at least two field values ​​based on the number of occurrences of each field value in the at least two field values ​​and the total number of occurrences of all field values ​​in the at least two field values;

[0019] In the case where the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and the distribution of the at least two field values ​​has a distribution boundary, a first field value interval is determined based on the at least two field values, and an occurrence probability corresponding to each field value in the first field value interval is determined based on a first occurrence number of the minimum field value and a second occurrence number of the maximum field value in the at least two field values; all field values ​​that can be obtained by the first field are represented as all field values ​​in the first field value interval;

[0020] When the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and there is no distribution boundary for the distribution of the at least two field values, the second field value interval is determined based on the first data type corresponding to the first field, and the occurrence probability corresponding to each field value in the second field value interval is determined based on the number of occurrences of each field value in the at least two field values; the field values ​​that can be obtained by the first field are represented as all field values ​​in the second field value interval; the first data type includes integer type or character type.

[0021] In the above scheme, based on at least one historical log corresponding to the set operation scenario, all field values ​​and the corresponding number of occurrences of each first field in all first fields appearing in the at least one historical log are determined, including: when the number of log entries in the at least one historical log is greater than the set number, all field values ​​and the corresponding number of occurrences of each first field in all first fields appearing in the at least one historical log are determined.

[0022] The embodiment of the present invention also provides a method for generating test data, comprising:

[0023] Determine a first field to be updated for each data table update operation in all data table update operations related to the set operation scenario;

[0024] For each of all the determined first fields, all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​are determined based on the test data model, and a field value for testing is generated for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values; wherein,

[0025] The test data model is generated based on any of the above methods for determining the test data model.

[0026] In the above scheme, for each of all the determined first fields, determining all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​based on the test data model, and generating a field value for testing for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values, the method includes:

[0027] Determine a probability interval corresponding to each field value that can be obtained by the first field based on the occurrence probability corresponding to each field value among all field values ​​that can be obtained by the first field;

[0028] Determine the probability interval in which the randomly generated probability value lies based on the probability interval corresponding to each field value that can be obtained by the first field;

[0029] The field value corresponding to the probability interval of the randomly generated probability value is determined as the field value of the first field for testing; wherein the probability intervals corresponding to all the field values ​​that the first field can obtain constitute a complete set probability range.

[0030] In the above scheme, the method further includes:

[0031] The field value for testing corresponding to the first field is written into the software system under test.

[0032] The embodiment of the present invention also provides a device for determining a test data model, including:

[0033] A first determining unit, used to determine a first field to be updated corresponding to each data table update operation in all data table update operations related to a set operation scenario;

[0034] A second determining unit, configured to determine, based on at least one historical log corresponding to the set operation scenario, all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log;

[0035] A construction unit, configured to generate a test data model corresponding to the set operation scenario based on all field values ​​of each first field in all determined first fields that appear in the at least one historical log and the number of occurrences of the field values; wherein,

[0036] The test data model represents all field values ​​that can be obtained by each first field in all first fields and the corresponding occurrence probabilities of the field values; the test data model is used to generate a field value for testing for each first field in all first fields when testing the set operation scenario.

[0037] The embodiment of the present invention further provides a device for generating test data, comprising: a determination unit, configured to determine a first field corresponding to an update of each data table update operation in all data table update operations related to a set operation scenario;

[0038] A generating unit is used to determine, for each of all the determined first fields, all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​based on the test data model, and generate a field value for testing for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values; wherein,

[0039] The test data model is generated based on any of the above methods for determining the test data model.

[0040] An embodiment of the present invention further provides an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor,

[0041] Wherein, when the processor is used to run the computer program, at least one of the following is performed:

[0042] Any of the steps of the method for determining a test data model above.

[0043] The steps of any of the above methods for generating test data.

[0044] An embodiment of the present invention further provides a storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, at least one of the following is implemented:

[0045] Any of the steps of the method for determining a test data model above.

[0046] The steps of any of the above methods for generating test data.

[0047] In an embodiment of the present invention, the first field corresponding to each data table update operation in all data table update operations related to the set operation scenario is determined; based on at least one historical log corresponding to the set operation scenario, all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log are determined; based on all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log determined, a test data model corresponding to the set operation scenario is generated. When testing the set operation scenario, the field value for testing corresponding to each first field corresponding to the set operation scenario can be constructed based on all field values ​​that can be obtained by the first field in the test data model and the probability of occurrence corresponding to each field value. The field value for testing is generated based on all field values ​​corresponding to the first field and the probability of occurrence corresponding to the field value, thereby diversifying the field values ​​for testing, reducing the probability of duplication of the field value for testing corresponding to the first field, improving the reliability of the data, and thus improving the accuracy of the test results. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A schematic diagram of the implementation flow of the method for determining a test data model provided by an embodiment of the present invention;

[0049] Figure 2 A schematic diagram of an implementation flow of determining a historical log in a method for determining a test data model provided in an embodiment of the present invention;

[0050] Figure 3 A schematic diagram of an implementation flow of determining the occurrence probability corresponding to a field value in a method for determining a test data model provided in an embodiment of the present invention;

[0051] Figure 4 A schematic diagram of an implementation flow of a method for generating test data provided by an embodiment of the present invention;

[0052] Figure 5 A schematic diagram of an implementation flow of generating a field value for testing for a corresponding first field in a method for generating test data provided by an embodiment of the present invention;

[0053] Figure 6 A schematic diagram of the structure of an apparatus for determining a test data model provided by an embodiment of the present invention;

[0054] Figure 7 A schematic diagram of the structure of a device for generating test data provided by an embodiment of the present invention;

[0055] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0056] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0057] Figure 1 The following is a schematic diagram of the implementation flow of the method for determining a test data model provided by an embodiment of the present invention. In the embodiment of the present invention, the execution subject of the method for determining a test data model is an electronic device, which includes a terminal and a server, and the terminal includes a computer and the like.

[0058] Reference Figure 1 , the method for determining the test data model provided in the embodiment of the present application includes:

[0059] S101: Determine a first field to be updated corresponding to each data table update operation in all data table update operations related to a set operation scenario.

[0060] Here, the electronic device can determine all data table update operations related to the set operation scenario based on the set correspondence between the operation scenario and the data table update operation. Among them, the data table update operation represents the operation performed on the data table related to the set operation scenario. The types of data table update operations include insert, delete, and update. It should be noted that each data table update operation corresponds to a data table, and different data table update operations can correspond to the same data table or different data tables.

[0061] In the case of determining all data table update operations related to the set operation scenario, all data tables related to the set operation scenario are determined, and based on all the determined data table update operations and all the determined data tables, the first field corresponding to the update of each data table update operation in all the data table update operations related to the set operation scenario is determined. Wherein, all data tables related to the set operation scenario can be determined based on the set corresponding relationship between the operation scenario and the data table; or all data tables related to the set operation scenario can be determined based on the data table update operation.

[0062] The first field updated corresponding to the data table update operation is a field allowed to write data and contained in the data table corresponding to the corresponding data table update operation.

[0063] In actual applications, the set operation scenarios include account opening, credit limit verification, etc. When the set operation scenario is "account opening", the set operation scenario-related data tables include the first user information table, the second user information table, the card opening data table, the data verification table, and the external resource table. The first user information table can be used to record information such as the user's name. The second user information table can be used to record user information other than all information recorded in the first user information table.

[0064] Among them, the name of the first user information table may be user_info; the name of the second user information table may be login_info; the name of the card opening data table may be open_card; the name of the data verification table may be validation; and the name of the external resource table may be outer_source.

[0065] S102: Based on at least one history log corresponding to the set operation scenario, determine all field values ​​of each first field in all first fields that appear in the at least one history log and the number of occurrences of the field values.

[0066] Here, when the electronic device determines all data tables related to the set operation scenario, it determines the database corresponding to each data table related to the set operation scenario based on the set correspondence between the data table and the database; based on the set correspondence between the database and the server, it determines the server that provides services for the database corresponding to each data table related to the set operation scenario, and obtains at least one historical log related to the corresponding database from the corresponding server, and determines the historical logs obtained from all determined servers as the historical logs corresponding to the set operation scenario.

[0067] When the electronic device obtains the history log corresponding to the set operation scenario, it parses each history log in all the obtained history logs to obtain the parsing result corresponding to the history log. From the parsing result corresponding to the history log, the electronic device determines all the field values ​​of each first field in all the first fields that appear in all the parsed history logs and the number of occurrences corresponding to the field value.

[0068] It should be noted that the data table update operation can be triggered when the user inputs or selects data related to the data table update operation through the corresponding interactive interface, and at least one historical log corresponding to the setting operation scenario is generated when the relevant data of the data table update operation is verified and the data table update operation is successfully executed. The relevant data of the data table update operation refers to the relevant data used to perform the data table update operation, such as data entered or selected by the user. Verification of the relevant data of the data table update operation refers to checking the relevant data based on the data type corresponding to the data table update operation (the data type can be a character type or an integer type), and determining whether the relevant data is in the data range corresponding to the data type; when the received relevant data is in the data range corresponding to the first data type, the verification is passed.

[0069] S103: Based on all the field values ​​of each first field in all the determined first fields that appear in the at least one historical log and the number of occurrences of the field values, generate a test data model corresponding to the set operation scenario; wherein:

[0070] The test data model represents all field values ​​that can be obtained by each first field in all first fields and the corresponding occurrence probabilities of the field values; the test data model is used to generate a field value for testing for each first field in all first fields when testing the set operation scenario.

[0071] Here, the electronic device determines all the field values ​​that can be obtained for each first field based on all the field values ​​that appear in all the acquired historical logs for each first field among all the determined first fields; determines the probability of occurrence of each field value that can be obtained for each first field based on the number of occurrences of each field value of each determined first field in all the parsed historical logs; and generates a test data model corresponding to the set operation scenario based on all the field values ​​that can be obtained for each first field among all the first fields related to the set operation scenario and the probability of occurrence corresponding to the field value. Among them, all the field values ​​that can be obtained for the first field can be the same as or different from all the field values ​​that appear in the historical logs for the first field.

[0072] It should be noted that when a new historical log is detected, the test data model corresponding to the set operation scenario generated in S103 can be updated based on the new historical log, or the test data model corresponding to the set operation scenario can be regenerated based on the new historical log and the historical log obtained in S102.

[0073] In the scheme provided in this embodiment, the first field corresponding to each data table update operation in all data table update operations related to the set operation scenario is determined; based on at least one historical log corresponding to the set operation scenario, all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log are determined; based on all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log, a test data model corresponding to the set operation scenario is generated. When testing the set operation scenario, the field value for testing corresponding to each first field corresponding to the set operation scenario can be constructed based on all field values ​​that can be obtained by the first field in the test data model and the probability of occurrence corresponding to each field value. The field value for testing is generated based on all field values ​​corresponding to the first field and the probability of occurrence corresponding to the field value, thereby diversifying the field values ​​for testing, reducing the probability of duplication of the field value for testing corresponding to the first field, improving the reliability of the data, and thus improving the accuracy of the test results.

[0074] As another embodiment of the present invention, Figure 2 The following is a schematic diagram of the implementation process of determining the historical log in the method for determining the test data model provided by the embodiment of the present invention. Figure 2 , when determining all field values ​​and the number of occurrences of each first field in all first fields that appear in the at least one historical log corresponding to the set operation scenario based on the at least one historical log, the method for determining the test data model further includes:

[0075] S201: Monitor the operation status of all databases and obtain the log file of each database in all databases.

[0076] Here, the electronic device monitors the operation of all detectable databases and obtains the log file of the corresponding database from the server corresponding to each database. All detectable databases include databases related to the set operation scenario and databases unrelated to the set operation scenario.

[0077] It should be noted that the electronic device can use the "data monitoring service" to monitor the operation of all databases and obtain the log files of each database in all databases; the "data analysis service" can be used to determine at least one historical log corresponding to the set operation scenario, as well as all field values ​​and the corresponding number of occurrences of each first field in all the first fields determined in the at least one historical log.

[0078] S202: Parse all obtained log files to determine at least one historical log corresponding to the set operation scenario.

[0079] Here, the electronic device parses all acquired log files to obtain parsing results of the log files, and determines at least one historical log corresponding to the set operation scenario from the parsing results of the log files. The parsing results of the log files may include historical logs corresponding to the set operation scenario, and may also include historical logs corresponding to other operation scenarios, real-time logs, etc.

[0080] In one embodiment, the electronic device may also determine at least one historical log corresponding to the set operation scenario in the following manner:

[0081] The electronic device stores configuration information related to the data table update operation, and the configuration information includes address information of servers corresponding to all databases related to the data table update operation and identifiers of database log files stored in each server. The number of address information in the configuration information may be one or at least two. The server corresponds to the address information one by one. The database log file is used to record related operations performed on the database, such as data table update operations performed on the data tables in the database.

[0082] In a set operation scenario, the electronic device monitors the operation status of all databases related to the data table update operation, thereby determining all databases related to the set operation scenario. The database related to the set operation scenario refers to a database whose data is changed in the set operation scenario.

[0083] When all databases related to the set operation scenario are determined, the electronic device determines the address information of the server corresponding to each database related to the set operation scenario from the configuration information, and determines the identifier of the database log file stored in each server from the configuration information; based on the determined address information of the server and the identifier of the database log file stored in each server, the electronic device determines the database log file matching the corresponding identifier from each server, and obtains at least one historical log corresponding to the set operation scenario. The address information of the server is used to access the corresponding server. The historical log is used to record the historical data table update operations related to the set operation scenario.

[0084] In the solution provided in this embodiment, at least one historical log corresponding to the set operation scenario is determined based on the log files in the database, without traversing all log files in the corresponding server, which can improve the efficiency of obtaining the historical log corresponding to the set operation scenario.

[0085] Based on the configuration information, a log file related to the set operation scenario is obtained from a server corresponding to a database related to the set operation scenario, so as to determine at least one historical log corresponding to the set operation scenario from the obtained log file. There is no need to traverse the log files in the server corresponding to the database that is not related to the set operation scenario, which can further improve the efficiency of obtaining the historical logs corresponding to the set operation scenario.

[0086] As another embodiment of the present invention, Figure 3 The following is a schematic diagram of the implementation process of determining the occurrence probability corresponding to a field value in the method for determining a test data model provided by an embodiment of the present invention. Figure 3 , when generating the test data model corresponding to the set operation scenario based on all the field values ​​of each first field in all the determined first fields that appear in the at least one historical log and the number of occurrences of the field values, the method includes:

[0087] S301: Determine a first identifier corresponding to the first field based on all field values ​​of the first field appearing in the at least one historical log and the number of occurrences of the field values; the first identifier represents the distribution of all field values ​​appearing in the at least one historical log.

[0088] Here, the electronic device can determine the number of all field values ​​corresponding to the first field based on all field values ​​that appear in all determined historical logs of the first field; and determine the first identifier corresponding to the first field based on the number of all field values ​​corresponding to the first field and the number of occurrences corresponding to each field value. The first identifier can represent the distribution of all field values ​​that appear in all acquired historical logs of the first field.

[0089] In one embodiment, the electronic device may record the relevant information of the data table update operation related to the setting operation scenario through the following table:

[0090]

[0091] Among them, 5 data table update operations are shown in the above table, and one row corresponds to one data table update operation. "Name of operation scenario" is the primary key of the above table; the column "Database name" is used to write the name of the database accessed in the corresponding operation scenario; the column "Data table" is used to write the name of the setting data table called in the corresponding operation scenario; the column "Type of data table update operation" is used to write the type of update operation performed on the corresponding setting data table in the corresponding operation scenario; the column "Priority" is used to write the order of the corresponding data table update operation in the corresponding operation scenario; the column "Related information corresponding to the data table update operation" is used to write the relevant information of the first field corresponding to the update of the corresponding data table update operation in the corresponding operation scenario. The relevant information of the first field includes the identifier of the first field, the first data type corresponding to the first field, the second data type corresponding to the first field, and the field domain of the first field; the field domain represents all field values ​​corresponding to the first field, the probability of each field value appearing, and can also represent the number of times each field value appears.

[0092] The relevant information of the first field can be described by the following fields:

[0093] field_name, used to describe the identifier of the first field;

[0094] field_type, used to describe the first data type corresponding to the first field;

[0095] field_domain_type, used to describe the second data type corresponding to the first field;

[0096] field_domain, used to describe the field domain of the first field.

[0097] The first data type includes an integer type or a character type. The second data type corresponds to the first identifier, which represents the distribution of all field values ​​appearing in the at least one historical log.

[0098] It should be noted that, when generating a test data model, the electronic device may also determine the priority corresponding to the first field corresponding to the data table update operation based on the priority corresponding to each data table update operation. The generated test data model may also characterize the priority corresponding to the first field corresponding to each data table update operation, so that when the test data model is used to test the set operation scenario, a field value for testing corresponding to each first field is generated based on the priority corresponding to the first field.

[0099] It should be noted that the data in the above table can be updated dynamically. The generated test data model corresponding to the set operation scenario can record the relevant data in the form of the above table.

[0100] S302: Using a setting algorithm corresponding to the first identifier, determine all field values ​​that can be obtained by the first field and the corresponding occurrence probabilities of the field values.

[0101] Here, the first identifier is used to determine the second data type corresponding to the field value that the first field can obtain, and the second data type includes a fixed value, an enumerated value, a bounded random value, and an unbounded random value.

[0102] The algorithm is configured to determine all field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​based on at least one of the following:

[0103] The number of all field values ​​that appear in all acquired historical logs;

[0104] The number of occurrences corresponding to each field value;

[0105] The number of historical logs;

[0106] The identifier of the first field.

[0107] Since the identifier of the first field can represent the field type of the first field, and the field type can represent the range of field values ​​that the first field can take, the field value that the first field value can take can be determined based on the identifier of the first field. Exemplarily, when the identifier of the first field is "gender", the field values ​​that the first field can take include "male" and "female". When the identifier of the first field is "ID number", the ID number of the same user is fixed and the number of data digits of the ID number is also fixed.

[0108] In actual applications, when the first identifier represents that all field values ​​of the first field appearing in all historical logs obtained are the same, the second data type corresponding to the field value representing the first field is a fixed value, and the setting algorithm corresponding to the first identifier is used to determine the field value that can be obtained for the first field as the fixed field value, and determine the occurrence probability corresponding to the fixed field value as 1.

[0109] In actual applications, when the first identifier represents that there are different field values ​​among all field values ​​of the first field appearing in all historical logs obtained, the setting algorithm corresponding to the first identifier can be used to determine all field values ​​that can be obtained by the first field and the corresponding occurrence probabilities of the field values ​​based on the number of all field values ​​that appear in all historical logs obtained for the first field, the number of occurrences corresponding to each field value, and the identifier of the first field.

[0110] For example, when the first identifier represents that there are different field values ​​of the first field among all field values ​​that appear in all historical logs obtained, and the identifier of the first field is "gender", the electronic device can determine all field values ​​of the first field that appear in all historical logs as the obtainable field values ​​of the first field, and determine the occurrence probability corresponding to each field value based on the number of occurrences corresponding to each field value and the total number of occurrences corresponding to all field values.

[0111] In one embodiment, the use of a setting algorithm corresponding to the first identifier to determine all field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​includes one of the following:

[0112] When the first identifier indicates that only one field value of the first field appears in the at least one historical log, determining that all field values ​​that the first field can take are the one field value, and determining that the occurrence probability corresponding to the one field value is 1;

[0113] When the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, and the number of field values ​​of the at least two field values ​​is less than or equal to the set number, determining that all field values ​​that can be obtained by the first field are the at least two field values, and determining the occurrence probability of each field value in the at least two field values ​​based on the number of occurrences of each field value in the at least two field values ​​and the total number of occurrences of all field values ​​in the at least two field values;

[0114] In the case where the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and the distribution of the at least two field values ​​has a distribution boundary, a first field value interval is determined based on the at least two field values, and an occurrence probability corresponding to each field value in the first field value interval is determined based on a first occurrence number of the minimum field value and a second occurrence number of the maximum field value in the at least two field values; all field values ​​that can be obtained by the first field are represented as all field values ​​in the first field value interval;

[0115] When the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and there is no distribution boundary for the distribution of the at least two field values, the second field value interval is determined based on the first data type corresponding to the first field, and the occurrence probability corresponding to each field value in the second field value interval is determined based on the number of occurrences of each field value in the at least two field values; the field values ​​that can be obtained by the first field are represented as all field values ​​in the second field value interval; the first data type includes integer type or character type.

[0116] Here, when the first identifier represents that only one field value of the first field appears in the at least one historical log, the second data type corresponding to the field value that can be obtained by the first field is a fixed value. Therefore, the electronic device determines that all field values ​​that can be obtained by the first field are the fixed field value, and determines that the occurrence probability corresponding to the fixed field value is 1.

[0117] In the case where the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, and the number of field values ​​of the at least two field values ​​is less than or equal to the set number, the second data type corresponding to the field value that can be obtained by the first field is an enumeration value, and all the field values ​​that can be obtained by the first field are all the field values ​​of the first field that appear in the historical log. Among them, the set number can be set according to actual conditions. The probability of occurrence of each available field value is equal to the quotient between the number of occurrences of each field value and the total number of occurrences of all field values ​​corresponding to the first field.

[0118] In the case where the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and the distribution of the at least two field values ​​has a distribution boundary, the second data type corresponding to the field value that can be obtained by the first field is represented as a bounded random value. The electronic device can determine the minimum field value and the maximum field value from all field values ​​of the first field that appear in the acquired historical log, determine the first field value interval corresponding to the first field value based on the minimum field value and the maximum field value, and determine all field values ​​in the first field value interval as all field values ​​that can be obtained by the first field. The electronic device determines the first occurrence probability of the minimum field value based on the first occurrence number of the minimum field value and the total occurrence number of all field values, and determines the second occurrence probability of the maximum field value based on the second occurrence number of the maximum field value and the total occurrence number of all field values; based on the first occurrence probability and the second occurrence probability, determine the occurrence probability corresponding to each field value in the first field value interval corresponding to the first field value.

[0119] The method of determining the occurrence probability corresponding to each field value in the first field value interval corresponding to the first field value based on the first occurrence probability and the second occurrence probability includes one of the following:

[0120] The electronic device reduces the first occurrence probability and the second occurrence probability according to a set ratio to obtain a third probability, an adjusted first occurrence probability, and an adjusted second occurrence probability, and determines the occurrence probability of all field values ​​in the first field value interval except the maximum field value and the minimum field value based on the third probability and the first quantity. Among them, the sum of the third probability, the adjusted first occurrence probability, and the adjusted second occurrence probability is equal to 1; the occurrence probabilities of all field values ​​in the first field value interval except the maximum field value and the minimum field value are the same; the first quantity is the total number of all field values ​​in the first field value interval except the maximum field value and the minimum field value. In actual applications, the third probability is less than the determined first occurrence probability.

[0121] The electronic device determines the total occurrence probability corresponding to all field values ​​in the first field value interval except the maximum field value and the minimum field value based on the first occurrence probability, and the total occurrence probability is less than the first occurrence probability; determines the probability of each field value in the first field value interval except the maximum field value and the minimum field value by taking the quotient between the total occurrence probability and the first quantity; determines the new first occurrence probability corresponding to the minimum field value based on the calculated quotient and the first occurrence probability; determines the new second occurrence probability corresponding to the maximum field value based on the calculated quotient and the second occurrence probability. The calculation formula of the new occurrence probability is: P = (1-mp)P i P represents the new occurrence probability corresponding to the field value; p represents the quotient between the above total occurrence probability and the first quantity; m represents the first quantity; P i The initial probability of occurrence corresponding to the representation field value, that is, the probability of occurrence before adjustment. When calculating the new first probability of occurrence, P i Corresponding to the first occurrence probability determined above. When calculating the new second occurrence probability, P i Corresponding to the second occurrence probability determined above.

[0122] In actual applications, when the first occurrence probability is 0.2, the second occurrence probability is 0.8, and the first field value interval corresponding to the first field includes 12 field values, it is determined that the total occurrence probability of all field values ​​in the first field value interval except the maximum field value and the minimum field value is 0.1, then the occurrence probability corresponding to each field value in the first field value interval except the maximum field value and the minimum field value is 0.1 / 10=0.01; the new first occurrence probability corresponding to the minimum field value is (1-0.01×10)×0.2=0.18; the new second occurrence probability corresponding to the maximum field value is (1-0.01×10)×0.8=0.72.

[0123] When the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and the distribution of the at least two field values ​​does not have a distribution boundary, the second data type corresponding to the field value that can be obtained by the first field is represented as an unbounded random value. The electronic device can obtain the first data type corresponding to the first field value, the first data type includes an integer or a character type, and determine the second field value interval corresponding to the first field value based on the first data type corresponding to the first field value; determine the occurrence probability of each field value of the first field appearing in all the acquired historical logs based on the number of occurrences of each field value of the first field in all the acquired historical logs; determine the occurrence probability of each field value in the second field value interval based on the second field value interval corresponding to the first field value and based on the occurrence probability of each field value of the first field appearing in all the acquired historical logs.

[0124] Among them, based on the second field value interval corresponding to the first field value and based on the occurrence probability corresponding to each field value of the first field appearing in all acquired historical logs, the method for determining the occurrence probability corresponding to each field value in the second field value interval may include one of the following:

[0125] The electronic device reduces the occurrence probability of each field value according to a set ratio, obtains the adjusted occurrence probability corresponding to each field value and the total occurrence probability corresponding to the field values ​​that do not appear in the historical log within the second field value interval, and determines the occurrence probability corresponding to each field value that does not appear in the historical log within the second field value interval based on the determined total occurrence probability and the total number of field values ​​that do not appear in the historical log within the second field value interval. The occurrence probability corresponding to each field value that does not appear in the historical log within the second field value interval is the same.

[0126] The electronic device may also determine the minimum occurrence probability from the occurrence probability corresponding to each field value of the first field appearing in all acquired historical logs; determine the total occurrence probability of the field values ​​that do not appear in the historical logs within the second field value interval based on the minimum occurrence probability; determine the occurrence probability corresponding to each field value that does not appear in the historical log within the second field value interval based on the determined total occurrence probability and the total number of field values ​​that do not appear in the historical log within the second field value interval; and calculate the new occurrence probability corresponding to the above field value based on the calculation formula P=(1-mp)P i , determine the new occurrence probability corresponding to each field value that appears in the historical log within the second field value interval. For specific implementation methods, please refer to the relevant description of the method for determining the occurrence probability corresponding to each field value in the first field value interval corresponding to the first field value, which will not be repeated here.

[0127] In the solution provided in this embodiment, based on the distribution of all field values ​​of the first field appearing in all historical logs obtained, all field values ​​that can be obtained by the first field and the corresponding occurrence probabilities of the field values ​​can be determined. This can enrich all field values ​​that can be obtained by the first field and improve the accuracy of the determined occurrence probabilities.

[0128] As another embodiment of the present invention, based on Figure 3 In a corresponding embodiment, the determining, based on at least one historical log corresponding to the set operation scenario, all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log includes:

[0129] When the number of logs in the at least one historical log is greater than the set number, all field values ​​of each first field in all first fields that appear in the at least one historical log and the number of occurrences corresponding to the field values ​​are determined.

[0130] Here, because in Figure 3 In the corresponding embodiment, it is necessary to use the set number corresponding to the field value to determine whether the second data type corresponding to the field value of the first field is an enumeration value, a bounded random value or an unbounded random value. Therefore, before determining all field values ​​of the first field appearing in all historical logs obtained and the number of occurrences corresponding to the field value, first determine whether the number of log entries of all historical logs corresponding to the set operation scenario is greater than the set number. When the judgment result indicates that the number of log entries of all historical logs corresponding to the set operation scenario is greater than the set number, determine all field values ​​of each first field appearing in all historical logs obtained and the number of occurrences corresponding to each field value.

[0131] The above describes the generation process of the test data model corresponding to the set operation scenario. The following describes in detail the implementation process of constructing the field value of each first field when the set operation scenario is tested using the test data model.

[0132] Figure 4 A schematic diagram of an implementation flow of a method for generating test data provided by an embodiment of the present invention is shown. The execution subject of the method for generating test data in this embodiment is an electronic device, which may be a terminal or a server. It should be noted that the electronic device for determining the test data model may be the same as or different from the electronic device for generating the test data.

[0133] Reference Figure 4 , the methods for generating test data include:

[0134] S401: Determine a first field to be updated corresponding to each data table update operation in all data table update operations related to a set operation scenario.

[0135] Here, S401 and Figure 1 S101 in the corresponding embodiment is the same, please refer to the relevant description in S101 for details, which will not be repeated here.

[0136] S402: for each of all the determined first fields, determine all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​based on the test data model, and generate a field value for testing for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values; wherein,

[0137] The test data model is generated by any of the above methods for determining a test data model.

[0138] Here, when the electronic device determines the first field updated by each data table update operation in all data table update operations related to the set operation scenario, the electronic device can determine the priority corresponding to each data table update operation in all data table update operations related to the set operation scenario according to the sequence of the data table update operations corresponding to the set operation scenario; based on the priority corresponding to each data table update operation, generate field values ​​for testing for all first fields corresponding to the data table update operation in the manner in S402. The earlier the sequence of the data table update operation, the higher the priority of the corresponding data table update operation, and the higher the priority of generating the field value for testing corresponding to the first field corresponding to the data table update operation.

[0139] For each first field among all the determined first fields, a method for generating a field value for testing for the corresponding first field is as follows:

[0140] The electronic device randomly generates a probability value for the first field. In practical applications, a set random function can be called to randomly generate a probability value.

[0141] Since the test data model represents all the field values ​​that each first field can take and the corresponding occurrence probabilities of the field values, the electronic device can determine all the field values ​​that the first field can take and the corresponding occurrence probabilities of the field values ​​based on the test data model.

[0142] Based on the randomly generated probability value corresponding to the first field and based on all field values ​​that can be obtained from the first field and the occurrence probabilities corresponding to the field values, the field value corresponding to the randomly generated probability value is determined, and the field value corresponding to the randomly generated probability value is determined as the corresponding first field generated field value for testing. Here, based on the randomly generated probability value corresponding to the first field and the occurrence probability corresponding to each field value that can be obtained from the first field, the occurrence probability close to the randomly generated probability value can be determined, and the field value corresponding to the randomly generated probability value is determined from the field values ​​corresponding to the determined occurrence probabilities. For example, when the difference between the occurrence probability and the randomly generated probability value is less than or equal to the set threshold, the corresponding occurrence probability is determined as the occurrence probability close to the randomly generated probability value.

[0143] It should be noted that the range of the randomly generated probability value is the same as the range of the occurrence probability corresponding to the field value. In practical applications, the range of the randomly generated probability value is 0 to 1. When the occurrence probability corresponding to the field value is expressed as a numerical value between 0 and 100, the occurrence probability of the field value is converted to a numerical value between 0 and 1 before comparing the occurrence probability corresponding to the field value with the randomly generated probability value.

[0144] In the solution provided by this embodiment, when testing the set operation scenario, the field value for testing corresponding to each first field corresponding to the set operation scenario can be constructed based on all the field values ​​that can be obtained by the first field in the test data model and the corresponding probability of occurrence of each field value. Since the field value for testing is generated based on all the field values ​​corresponding to the first field and the corresponding probability of occurrence of the field value, the field values ​​for testing can be diversified, and the constructed field values ​​for testing can be made more in line with the actual situation; the diversification of the field values ​​for testing can reduce the probability of duplication of the field values ​​for testing corresponding to the first field, improve the reliability of the data, and thus improve the accuracy of the test results.

[0145] As another embodiment of the present invention, Figure 5 The following is a schematic diagram of a process for implementing the method of generating test data provided by an embodiment of the present invention, in which a field value for testing is generated for a corresponding first field. Figure 5 , for each of all the determined first fields, determining all the field values ​​that the first field can take and the corresponding occurrence probabilities of the field values ​​based on the test data model, and generating a field value for testing for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can take and the corresponding occurrence probabilities of the field values, the method includes:

[0146] S501: Based on the occurrence probability corresponding to each field value among all field values ​​that can be obtained by the first field, determine the probability interval corresponding to each field value that can be obtained by the first field; wherein the probability intervals corresponding to all field values ​​that can be obtained by the first field constitute a complete set probability range.

[0147] In actual applications, the probability range is set to 0 to 1, and the probability range corresponding to each field value of all field values ​​that can be obtained by the first field is spliced ​​into the set probability range of 0 to 1. Among them, the greater the probability of occurrence corresponding to the field value, the greater the value representing the probability interval corresponding to the field value.

[0148] For example, when all the field values ​​that can be obtained by the first field are the first field value and the second field value, and the occurrence probability corresponding to the first field value is 0.2 and the occurrence probability corresponding to the second field value is 0.8, the probability interval corresponding to the first field value that can be obtained by the first field is greater than or equal to zero and less than 0.2; the probability interval corresponding to the second field value that can be obtained by the first field is greater than or equal to 0.2 and less than or equal to 1. Alternatively, the probability interval corresponding to the first field value that can be obtained by the first field is greater than or equal to zero and less than or equal to 0.2; the probability interval corresponding to the second field value that can be obtained by the first field is greater than 0.2 and less than or equal to 1.

[0149] It should be noted that when the number of all field values ​​that can be obtained by the first field is greater than 2, the probability intervals corresponding to the three field values ​​are determined according to the above method.

[0150] S502: Based on the probability interval corresponding to each field value that can be obtained by the first field, determine the probability interval in which the randomly generated probability value is located.

[0151] S503: Determine the field value corresponding to the probability interval in which the randomly generated probability value is located as the field value of the first field for testing.

[0152] For example, when the randomly generated probability value is 0.1, the probability interval of the randomly generated probability value is the probability interval corresponding to the first field value that the first field can obtain, and the first field value that the first field can obtain is determined as the field value of the first field used for testing.

[0153] When the randomly generated probability value is 0.5, the probability interval of the randomly generated probability value is the probability interval corresponding to the second field value that the first field can obtain, and the second field value that the first field can obtain is determined as the field value of the first field for testing.

[0154] In the solution provided by this embodiment, the field value for testing corresponding to the first field is determined based on the randomly generated probability value corresponding to the first field and the probability interval corresponding to each field value that can be obtained by the first field. The occurrence probability that matches the randomly generated probability value can be determined more accurately, so that the constructed field value for testing is more in line with the actual situation.

[0155] In one embodiment, the method for generating test data further includes: writing a field value for testing corresponding to the first field into the software system being tested.

[0156] Here, the electronic device generates a corresponding database statement based on the field value for testing corresponding to the first field and based on the data table operation corresponding to the first field, and executes the generated database statement, thereby writing the field value for testing corresponding to the first field into the software system being tested.

[0157] In the solution provided in this embodiment, the field value for testing corresponding to the first field is written into the software system under test, rather than writing the field value for testing corresponding to the first field into the test script, and then writing the data into the software system under test by running the test script in the software system under test, which can save data writing time and improve testing efficiency.

[0158] In order to implement the method for determining a test data model according to an embodiment of the present invention, an embodiment of the present invention further provides a device for determining a test data model, which is arranged on an electronic device, such as Figure 6 As shown, the device for determining the test data model includes:

[0159] A first determining unit 61, configured to determine a first field corresponding to an update of each data table update operation in all data table update operations related to a set operation scenario;

[0160] A second determining unit 62 is used to determine, based on at least one historical log corresponding to the set operation scenario, all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log;

[0161] A construction unit 63 is used to generate a test data model corresponding to the set operation scenario based on all field values ​​of each first field in all the determined first fields that appear in the at least one historical log and the number of occurrences of the field values; wherein,

[0162] The test data model represents all field values ​​that can be obtained by each first field in all first fields and the corresponding occurrence probabilities of the field values; the test data model is used to generate a field value for testing for each first field in all first fields when testing the set operation scenario.

[0163] In one embodiment, the apparatus for determining the test data model further comprises:

[0164] The monitoring module is used to monitor the operation of all databases and obtain the log files of each database in all databases;

[0165] The third determining unit parses all the obtained log files to determine at least one historical log corresponding to the set operation scenario.

[0166] In one embodiment, the construction unit 63 is used to:

[0167] Determine a first identifier corresponding to the first field based on all field values ​​of the first field that appear in the at least one historical log and the number of occurrences of the field values; the first identifier represents the distribution of all field values ​​that appear in the at least one historical log;

[0168] A setting algorithm corresponding to the first identifier is used to determine all field values ​​that can be obtained by the first field and the corresponding occurrence probabilities of the field values.

[0169] In one embodiment, the third determining unit is configured to perform one of the following:

[0170] When the first identifier indicates that only one field value of the first field appears in the at least one historical log, determining that all field values ​​that the first field can take are the one field value, and determining that the occurrence probability corresponding to the one field value is 1;

[0171] When the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, and the number of field values ​​of the at least two field values ​​is less than or equal to the set number, determining that all field values ​​that can be obtained by the first field are the at least two field values, and determining the occurrence probability of each field value in the at least two field values ​​based on the number of occurrences of each field value in the at least two field values ​​and the total number of occurrences of all field values ​​in the at least two field values;

[0172] In the case where the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and the distribution of the at least two field values ​​has a distribution boundary, a first field value interval is determined based on the at least two field values, and an occurrence probability corresponding to each field value in the first field value interval is determined based on a first occurrence number of the minimum field value and a second occurrence number of the maximum field value in the at least two field values; all field values ​​that can be obtained by the first field are represented as all field values ​​in the first field value interval;

[0173] When the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and there is no distribution boundary for the distribution of the at least two field values, the second field value interval is determined based on the first data type corresponding to the first field, and the occurrence probability corresponding to each field value in the second field value interval is determined based on the number of occurrences of each field value in the at least two field values; the field values ​​that can be obtained by the first field are represented as all field values ​​in the second field value interval; the first data type includes integer type or character type.

[0174] In one embodiment, the construction unit 63 is used to: when the number of log entries in the at least one historical log is greater than the set number, determine all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log.

[0175] In actual application, each unit included in the device for determining the test data model can be implemented by a processor in the device for determining the test data model. Of course, the processor needs to run the program stored in the memory to implement the functions of the above program modules.

[0176] It should be noted that: the device for determining the test data model provided in the above embodiment only uses the division of the above program modules as an example when determining the test data model. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device for determining the test data model is divided into different program modules to complete all or part of the processing described above. In addition, the device for determining the test data model provided in the above embodiment and the method embodiment for determining the test data model belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0177] In order to implement the method for generating test data in the embodiment of the present invention, the embodiment of the present invention also provides a device for generating test data, which is arranged on an electronic device, such as Figure 7 As shown, the device for generating test data includes:

[0178] A determining unit 71, configured to determine a first field to be updated corresponding to each data table update operation in all data table update operations related to a set operation scenario;

[0179] The generating unit 72 is used to determine, for each of all the determined first fields, all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​based on the test data model, and generate a field value for testing for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values; wherein,

[0180] The test data model is generated based on any of the above methods for determining the test data model.

[0181] In one embodiment, the generating unit 72 is used to:

[0182] Determine a probability interval corresponding to each field value that can be obtained by the first field based on the occurrence probability corresponding to each field value among all field values ​​that can be obtained by the first field;

[0183] Determine the probability interval in which the randomly generated probability value lies based on the probability interval corresponding to each field value that can be obtained by the first field;

[0184] The field value corresponding to the probability interval of the randomly generated probability value is determined as the field value of the first field for testing; wherein the probability intervals corresponding to all the field values ​​that the first field can obtain constitute a complete set probability range.

[0185] In one embodiment, the device for generating test data further includes:

[0186] The writing unit is used to write the field value for testing corresponding to the first field into the software system under test.

[0187] In actual application, the determination unit 71, the generation unit 72 and the writing unit can be implemented by a processor in the device for generating test data. Of course, the processor needs to run the program stored in the memory to implement the functions of the above program modules.

[0188] It should be noted that: the device for generating test data provided in the above embodiment only uses the division of the above program modules as an example when generating test data. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device for generating test data is divided into different program modules to complete all or part of the processing described above. In addition, the device for generating test data provided in the above embodiment and the method embodiment for generating test data belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0189] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present invention, the embodiment of the present invention further provides an electronic device. Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention is shown in FIG. Figure 8 As shown, the electronic equipment includes:

[0190] Communication interface 1, capable of exchanging information with other devices such as servers;

[0191] The processor 2 is connected to the communication interface 1 to realize information exchange with other devices, and is used to execute the method for determining the test data model provided by one or more technical solutions, or the method for generating test data provided by one or more technical solutions when running the computer program. The computer program is stored in the memory 3.

[0192] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 8 Various buses are labeled as bus system 4 .

[0193] The memory 3 in the embodiment of the present invention is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0194] It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 3 described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable types of memories.

[0195] The method disclosed in the above embodiment of the present invention can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 2 or the instruction in the form of software. The above processor 2 can be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 3. The processor 2 reads the program in the memory 3 and completes the steps of the above method in combination with its hardware.

[0196] When the processor 2 executes the program, the processes corresponding to the multi-core processor in each method of the embodiment of the present invention are implemented, which will not be described in detail here for the sake of brevity.

[0197] In an exemplary embodiment, the present invention further provides a storage medium, namely a computer storage medium, specifically a computer readable storage medium, for example, including a memory 3 storing a computer program, and the computer program can be executed by a processor 2 to complete the above Figures 1 to 3 The steps in the corresponding embodiment, or completing the above Figures 4 to 5 The steps in the corresponding embodiments. The computer readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, FlashMemory, magnetic surface memory, optical disk, or CD-ROM.

[0198] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0199] The units described above 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 distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0200] In addition, all functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0201] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.

[0202] It should be noted that the technical solutions described in the embodiments of the present invention can be arbitrarily combined without conflict.

[0203] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for determining a test data model, characterized in that: include: Determine a first field to be updated for each data table update operation in all data table update operations related to the set operation scenario; Based on at least one historical log corresponding to the set operation scenario, determine all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log; Based on all the determined field values ​​of each of all the first fields that appear in the at least one historical log and the number of occurrences of the field values, a test data model corresponding to the set operation scenario is generated; wherein the test data model represents all the field values ​​that can be obtained by each of all the first fields and the probability of occurrence of the field values; the test data model is used to generate a field value for testing for each of all the first fields when testing the set operation scenario; Wherein, when generating the test data model corresponding to the set operation scenario based on all the field values ​​of each first field in all the determined first fields that appear in the at least one historical log and the number of occurrences corresponding to the field values, the method includes: determining a first identifier corresponding to the first field based on all the field values ​​of the first field that appear in the at least one historical log and the number of occurrences corresponding to the field values; the first identifier represents the distribution of all the field values ​​that appear in the at least one historical log; and using the set algorithm corresponding to the first identifier to determine all the field values ​​that can be obtained by the first field and the corresponding occurrence probabilities of the field values; The method adopts a setting algorithm corresponding to the first identifier to determine all field values ​​that can be obtained by the first field and the corresponding occurrence probabilities of the field values, including: when the first identifier represents that only one field value of the first field appears in the at least one historical log, determining that all field values ​​that can be obtained by the first field are the one field value, and determining that the corresponding occurrence probability of the one field value is 1; when the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, and the number of field values ​​of the at least two field values ​​is less than or equal to the set number, determining that all field values ​​that can be obtained by the first field are the at least two field values, and based on the number of occurrences of each field value in the at least two field values ​​and the total number of occurrences of all field values ​​in the at least two field values, determining the occurrence probability of each field value in the at least two field values; when the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and the distribution of the at least two field values ​​has a distribution boundary. In the case of a first field value interval being determined based on the at least two field values, and the occurrence probability corresponding to each field value in the first field value interval being determined based on the first occurrence probability of the minimum field value and the second occurrence probability of the maximum field value in the at least two field values; all field values ​​that can be obtained by the first field are represented as all field values ​​in the first field value interval; when the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than the set number, and there is no distribution boundary for the distribution of the at least two field values, the second field value interval corresponding to the first field value is determined based on the first data type corresponding to the first field value, and the occurrence probability corresponding to each field value in the second field value interval is determined based on the second field value interval corresponding to the first field value and based on the occurrence probability corresponding to each field value of the first field appearing in all the acquired historical logs; the field values ​​that can be obtained by the first field are represented as all field values ​​in the second field value interval; the first data type includes integer type or character type.

2. The method according to claim 1, characterized in that: The method further comprises: Monitor the operation of all databases and obtain the log files of each database in all databases; All obtained log files are parsed to determine at least one historical log corresponding to the set operation scenario.

3. The method according to claim 1, characterized in that The determining, based on at least one historical log corresponding to the set operation scenario, all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log includes: When the number of log entries in the at least one historical log is greater than the set number, all field values ​​of each first field in all first fields that appear in the at least one historical log and the number of occurrences corresponding to the field values ​​are determined.

4. A method for generating test data, characterized in that: include: Determine a first field to be updated for each data table update operation in all data table update operations related to the set operation scenario; For each of all the determined first fields, all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​are determined based on the test data model, and a field value for testing is generated for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values; wherein, The test data model is generated based on the method for determining a test data model according to any one of claims 1 to 3.

5. The method according to claim 4, characterized in that When, for each of all the determined first fields, all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​are determined based on the test data model, and a field value for testing is generated for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values, the method includes: Determine a probability interval corresponding to each field value that can be obtained by the first field based on the occurrence probability corresponding to each field value among all field values ​​that can be obtained by the first field; Determine the probability interval in which the randomly generated probability value lies based on the probability interval corresponding to each field value that can be obtained by the first field; The field value corresponding to the probability interval of the randomly generated probability value is determined as the field value of the first field for testing; wherein the probability intervals corresponding to all the field values ​​that the first field can obtain constitute a complete set probability range.

6. The method according to claim 4 or 5, characterized in that: The method further comprises: The field value for testing corresponding to the first field is written into the software system under test.

7. A device for determining a test data model, characterized in that: include: A first determining unit, used to determine a first field corresponding to an update of each data table update operation in all data table update operations related to a set operation scenario; A second determining unit, configured to determine, based on at least one historical log corresponding to the set operation scenario, all field values ​​and the number of occurrences corresponding to the field values ​​of each first field in all first fields that appear in the at least one historical log; A construction unit, configured to generate a test data model corresponding to the set operation scenario based on all field values ​​of each first field in all determined first fields that appear in the at least one historical log and the number of occurrences of the field values; wherein, The test data model represents all the field values ​​that can be obtained by each first field in all the first fields and the corresponding occurrence probabilities of the field values; the test data model is used to generate a field value for testing for each first field in all the first fields when testing the set operation scenario; The construction unit is further used to determine a first identifier corresponding to the first field based on all field values ​​of the first field that appear in the at least one historical log and the number of occurrences of the field values; the first identifier represents the distribution of all field values ​​that appear in the at least one historical log; and determine all field values ​​that can be obtained by the first field and the occurrence probabilities corresponding to the field values ​​using a set algorithm corresponding to the first identifier; A third determining unit is used to determine that all the field values ​​that can be obtained by the first field are the one field value, and determine that the occurrence probability corresponding to the one field value is 1 when only one field value appears in the at least one historical log represented by the first identifier of the first field; determine that all the field values ​​that can be obtained by the first field are the at least two field values ​​when at least two field values ​​appear in the at least one historical log represented by the first identifier, and the number of field values ​​of the at least two field values ​​is less than or equal to a set number, and determine the occurrence probability of each field value in the at least two field values ​​based on the number of occurrences of each field value in the at least two field values ​​and the total number of occurrences of all field values ​​in the at least two field values; determine based on the at least two field values ​​when at least two field values ​​appear in the at least one historical log represented by the first identifier of the first field, the number of field values ​​of the at least two field values ​​is greater than a set number, and there is a distribution boundary for the distribution of the at least two field values. Determine a first field value interval, and determine the occurrence probability corresponding to each field value in the first field value interval based on a first occurrence probability of the minimum field value and a second occurrence probability of the maximum field value in the at least two field values; all field values ​​that can be obtained by the first field are represented as all field values ​​in the first field value interval; when the first identifier represents that at least two field values ​​of the first field appear in the at least one historical log, the number of field values ​​of the at least two field values ​​is greater than a set number, and there is no distribution boundary for the distribution of the at least two field values, determine the second field value interval corresponding to the first field value based on the first data type corresponding to the first field value, and determine the occurrence probability corresponding to each field value in the second field value interval based on the second field value interval corresponding to the first field value and based on the occurrence probability corresponding to each field value of the first field appearing in all the acquired historical logs; the field values ​​that can be obtained by the first field are represented as all field values ​​in the second field value interval; the first data type includes integer type or character type.

8. A device for generating test data, characterized in that: include: A determination unit, configured to determine a first field to be updated corresponding to each data table update operation in all data table update operations related to a set operation scenario; A generating unit is used to determine, for each of all the determined first fields, all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values ​​based on the test data model, and generate a field value for testing for the corresponding first field based on the randomly generated probability value and all the field values ​​that the first field can obtain and the corresponding occurrence probabilities of the field values; wherein, The test data model is generated based on the method for determining a test data model according to any one of claims 1 to 3.

9. An electronic device, characterized in that: include: a processor and a memory for storing a computer program capable of being executed on the processor, Wherein, when the processor is used to run the computer program, at least one of the following is performed: The steps of the method according to any one of claims 1 to 3; The steps of the method according to any one of claims 4 to 6.

10. A storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, at least one of the following is achieved: The steps of the method according to any one of claims 1 to 3; The steps of the method according to any one of claims 4 to 6.

Citation Information

Patent Citations

  • Generating test data

    CN102460076A