Test data generation method and device, equipment and medium
By acquiring historical data sets and using pre-trained models to generate high-quality test data sets, the problems of low generation rate and efficiency in existing technologies are solved, and the efficiency of software testing is improved.
Patent Information
- Application Number
- CN202510792468.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-09-26
AI Technical Summary
Existing test data generation methods have the problem of low generation rate and efficiency, which leads to low efficiency of software testing work.
By obtaining historical data sets, the pre-trained brute force data generation model and test data generation model are used to process the historical data sets to generate high-quality test data sets.
The generation rate and efficiency of test data are improved, thereby improving the efficiency of software testing work.
Smart Images

Figure CN120705041A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a method, device, equipment and medium for generating test data. Background Art
[0002] In today's digital age, software has become deeply integrated into every aspect of social life, and its quality directly impacts user experience, business operations, and even social stability. Software testing, as a key component in ensuring software development quality, effectively identifies software defects and prevents a range of problems caused by software failures. Within the software testing ecosystem, system security and robustness testing are particularly important and complex. With the continued growth in the number and types of users, the increasing variety of terminal devices, and the emergence of various emerging technologies, the operating environment faced by systems is becoming increasingly complex and dynamic. This makes system security and robustness testing even more crucial in ensuring software reliability.
[0003] Currently, system security and robustness testing relies heavily on the experience of developers and testers, as well as tools. Input data is a key factor influencing system security and robustness. Appropriate test data can uncover hidden security vulnerabilities and robustness issues in the system. For example, the American FuzzyLop (AFL) tool uses a genetic algorithm, based on initial test case seed data. By selecting seeds and applying a mutation algorithm to mutate the seed data, it continuously generates and updates test case data.
[0004] However, the AFL tool still has many limitations. First, the method relies on a mutation algorithm to mutate seed data to generate test data. If the mutation method is not designed properly, it will be difficult to generate high-quality, targeted test data. Second, when monitoring program code coverage, AFL does not consider a comprehensive range of factors. Third, existing test data generation methods are suitable for simple systems with low computational requirements and lack self-adaptation and self-learning capabilities, making it impossible to dynamically adjust test strategies based on complex system changes.
[0005] In summary, existing test data generation methods have the problem of low test data generation rate and efficiency, which in turn leads to low efficiency of software testing work. Summary of the Invention
[0006] The present invention provides a method, apparatus, device and medium for generating test data, which can solve the problem of low test data generation rate and efficiency of generating data in existing test data generation methods, thereby leading to low efficiency of software testing work.
[0007] In a first aspect, an embodiment of the present invention provides a method for generating test data, the method comprising:
[0008] Get historical data sets;
[0009] Processing the historical dataset based on a pre-trained violence data generation model to obtain a violence dataset matching the historical dataset;
[0010] The historical data set and the violent data set are processed based on a pre-trained test data generation model to obtain a test data set.
[0011] In a second aspect, an embodiment of the present invention provides a device for generating test data, the device comprising:
[0012] Data acquisition module, used to obtain historical data sets;
[0013] a violence data generation module, configured to process the historical data set based on a pre-trained violence data generation model to obtain a violence data set matching the historical data set;
[0014] The test data generation module is used to process the historical data set and the violent data set based on a pre-trained test data generation model to obtain a test data set.
[0015] In a third aspect, an embodiment of the present invention provides an electronic device, comprising:
[0016] at least one processor; and
[0017] a memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor so that the at least one processor can execute a method for generating test data according to any embodiment of the present invention.
[0019] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a test data generation method described in any embodiment of the present invention when executed.
[0020] The technical solution of the embodiment of the present invention first obtains a historical data set, then processes the historical data set based on a pre-trained brute force data generation model to obtain a brute force data set that matches the historical data set, and finally processes the historical data set and the brute force data set based on a pre-trained test data generation model to obtain a test data set. This solves the problem of low test data generation rate and data generation efficiency in existing test data generation methods, which in turn leads to low efficiency of software testing work, realizes the generation of data for software testing, improves the test data generation rate and data generation efficiency, and thus improves the efficiency of software testing work.
[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 This is a flowchart of a method for generating test data according to the first embodiment of the present invention;
[0024] Figure 2 This is a flowchart of a method for generating test data according to a second embodiment of the present invention;
[0025] Figure 3 This is a schematic diagram of the structure of a test data generating device provided in accordance with a third embodiment of the present invention;
[0026] Figure 4 The present invention is a schematic structural diagram of an electronic device for implementing a method for generating test data according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "first," "second," and the like in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, any variations of the terms "including" and "having" are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to these processes, methods, products, or apparatus.
[0029] Example 1
[0030] Figure 1 This is a flowchart of a test data generation method provided in Example 1 of the present invention. This embodiment is applicable to the situation where test data for software testing is generated. The method can be executed by a test data generation device. The test data generation device can be implemented in the form of hardware and / or software. The test data generation device can be configured in a terminal or server with a test data generation function.
[0031] like Figure 1 As shown, the method includes:
[0032] S110: Obtain a historical data set.
[0033] Among them, the historical data includes: data content and historical result labels matching the data content; further, the historical result labels are the test results of the software to be tested after the data content is input into the software to be tested; specifically, the historical result labels include: 1 (normal), 0 (abnormal) and -1 (unable to provide service).
[0034] Furthermore, the data content of the historical data can be basic test data generated by regular expressions based on the input item characteristics of the software to be tested (such as certificate type, text input composition format, parameter type, length, etc., which can be pre-set by the developer).
[0035] S120 : Process the historical dataset based on a pre-trained violence data generation model to obtain a violence dataset that matches the historical dataset.
[0036] S130 : Processing the historical dataset and the violent dataset based on a pre-trained test data generation model to obtain a test dataset.
[0037] Specifically, the construction process of the test data generation model includes: obtaining a test data set, which includes: at least one sample data and at least one historical violence data; generating a test ratio value matching the test data set according to a preset random proportion generation rule; adjusting the number of sample test data and the number of historical violence data in the test data set according to the test ratio value to obtain an updated test data set; calculating the test residual of the test data set according to a preset formula, and determining whether the test residual is less than a preset test residual value; if less than, applying the test ratio value matching the test residual value to a pre-configured deep Q network model to obtain a test data generation model; if not less than, returning to execute the operation of generating a test ratio value matching the test data set according to the preset random proportion generation rule.
[0038] In a specific implementation scenario of this embodiment, the test data generation model is constructed as follows: First, a test dataset is obtained, which includes at least one sample data item and its corresponding historical result label, as well as at least one historical violence data item and its corresponding violence result label. Next, a test ratio value g is generated that matches the test dataset based on a pre-set random ratio generation rule (e.g., randomly generating a value between 0 and 1). This ratio value is used to determine the ratio of sample test data to historical violence data in the test data (e.g., \(g = 0.6\) indicates that the sample test data item accounts for 60% and the historical violence data item accounts for 40%). It should be noted that the random ratio generation rule can be configured by the developer based on actual scenarios and is not limited in this embodiment. Then, based on the test ratio value, the number of sample test data items and the number of historical violence data items in the test dataset are adjusted to obtain an updated test dataset. For example, if the original dataset contains 100 labeled data items (including sample data and violence data), when \(g = 0.6\), the updated number of sample test data items is 60 and the number of historical violence data items is 40. Afterwards, the updated test data set is processed according to the residual model to obtain the test residual of the test data set, which is used to measure the degree of difference between the model prediction value and the actual value. After calculation, it is determined whether the test residual is less than the preset test residual value. If it is less than, the test proportion value g that matches the test residual value is applied to the pre-configured deep Q network model. At this time, the model uses the "data content-label" pair in the historical data as the state input, optimizes the test data generation strategy through reinforcement learning, and finally obtains the test data generation model; if it is not less than, it returns to execute the operation of generating a test proportion value matching the test data set according to the pre-set random proportion generation rule, readjusts the proportion and calculates the residual until the conditions are met.
[0039] The technical solution of the embodiment of the present invention first obtains a historical data set, then processes the historical data set based on a pre-trained brute force data generation model to obtain a brute force data set that matches the historical data set, and finally processes the historical data set and the brute force data set based on a pre-trained test data generation model to obtain a test data set. This solves the problem of low test data generation rate and data generation efficiency in existing test data generation methods, which in turn leads to low efficiency of software testing work, realizes the generation of data for software testing, improves the test data generation rate and data generation efficiency, and thus improves the efficiency of software testing work.
[0040] Example 2
[0041] Figure 2 This is a flowchart of a method for constructing a violence data generation model provided in the second embodiment of the present invention. This embodiment is based on and supplements the above embodiment. In this embodiment, the method for constructing a violence data generation model is supplemented.
[0042] like Figure 2 As shown, the method includes:
[0043] S210: Acquire a sample data set, and generate status information of each sample according to the sample data set based on preset rules.
[0044] The sample data includes: sample test data and a test result tag that matches the sample test data; further, the test result tag is the test result of the software to be tested after the sample test data is input into the software to be tested; specifically, the test result tag includes: 1 (normal), 0 (abnormal) and -1 (unable to provide service).
[0045] Specifically, a sample data set is obtained, and each sample state information is generated based on the sample data set based on preset rules, including: obtaining the sample test data I and the test result label E of each sample data in the sample data set respectively; and calculating the sample state information s matching each sample data according to the formula s = (I, E). Furthermore, the process of obtaining the sample data set and generating the sample state information is as follows: first, the sample test data I (and the corresponding test result label E) of each sample data in the sample data set are extracted respectively; then, according to the preset rule formula s = (I, E), the input data and label of each sample are combined into a state vector, namely the sample state information s. For example, if a sample test data is "test_abc" and the label is "1", the generated state information is s = ("test_abc", 1). This state vector is used to characterize the operating state of the system when receiving compliant input, providing basic training data for the subsequent deep reinforcement learning model. This process transforms the abstract test scenario into a computable state space by structured integration of input and system feedback, facilitating model learning and optimizing test data generation strategies.
[0046] S220 : Generate random generation strategies that match the status information of each sample according to preset strategy generation rules.
[0047] Among them, according to the pre-set strategy generation rules, random generation strategies matching each sample state information are generated respectively, including: processing each sample state information respectively through the Fisher-Yates shuffling algorithm to obtain random position selection results matching each sample state information respectively; processing each sample state information respectively through the random value generation strategy to obtain random value generation results matching each sample state information respectively; aggregating the random position selection result and the random value generation result to obtain a random generation strategy matching the sample state information.
[0048] In this embodiment, the specific process of generating a random generation strategy that matches each sample state information is as follows: First, the input data I in each sample state information is processed by the Fisher-Yates shuffling algorithm to obtain a random position selection result. For example, the random position selection result of the user name "user_012" is confirmed to be {2, (2, 3)}, that is, there are two randomly selected positions for the above character, namely the second position (s) and the third position (e). Secondly, the sample state information is processed by the random value generation strategy. For example, the random value generation strategy of the compliant string "user_012" is processed to obtain a random value generation result of "changing the character at the random position to a". This result represents the irregular variation pattern of the input data content. Finally, the above two results are aggregated, that is, the character position and content variation are combined to form a complete random generation strategy. For example, for sample state information s = ("user_012", 1), the Fisher-Yates algorithm is first used to obtain the random position selection result of {2, (2, 3)}. Then, the random value generation strategy is used to generate the random value result of "changing the character at the random position to a", and finally generating the test data "s = ("uaar_012", 1)". This strategy can be used to explore the system's ability to handle unconventional input formats and verify its robustness and security. This process achieves diversified mutation of compliant input through algorithm combination, improving the randomness and coverage of test data, and compensating for the shortcomings of existing technologies that rely on fixed mutation methods.
[0049] S230: Process the sample state information using a random generation strategy to obtain random sample information matching the sample state information.
[0050] The random sample information includes random test data and random result labels matching the random test data.
[0051] S240: Calculate the sample residual of each random sample information according to a preset formula, and determine whether there is target sample information whose sample residual is less than a preset residual threshold.
[0052] Wherein, the sample residual of each random sample information is calculated according to a preset formula, including: obtaining the parameters of a pre-configured deep Q network model and the parameters of a pre-configured target deep Q network model, and respectively obtaining the code coverage C, the number of defects N and the discount factor of each random sample information; calculating the random reward value matching each random sample information according to the formula r=α*C+β*N, wherein α and β are linear parameters, and α+β=1; generating the residual calculation strategy matching each random sample information according to the preset strategy generation rule; processing the random sample information using the residual calculation strategy to obtain the residual sample information matching the residual sample information; calculating the sample residual of each random sample information based on the preset formula, the discount factor matching each random sample information, the random generation strategy, the random sample information, the residual calculation strategy and the residual sample information; wherein, the preset formula is: loss=G[(r+γ*max k′ (Q(w′, k′; θ - )-Q(w, k; θ)) 2 ]; where loss is the sample residual, G is the random result label of the random sample information, γ is the discount factor, Q() is the state-action value function, w is the random sample information, k is the random generation strategy, w' is the residual sample information, k' is the residual calculation strategy, θ is the parameter of the deep Q network model, θ - are the parameters of the target deep Q network model.
[0053] S250: Determine a target generation strategy in each random generation strategy according to the judgment result, and apply the target generation strategy to a pre-configured deep Q network model to obtain a brute force data generation model.
[0054] Among them, the target generation strategy is determined in each random generation strategy according to the judgment result, including: if there is at least one target sample information whose sample residual is less than a preset residual threshold, then the target sample information with the smallest sample residual is selected as the result sample information among each target sample information, and the random generation strategy matching the result sample information is determined as the target generation strategy; if there is no target sample information whose sample residual is less than the preset residual threshold, then returning to execute the operation of generating random generation strategies matching each sample status information according to the pre-set strategy generation rules.
[0055] Specifically, if there is at least one target sample whose sample residual is less than a preset residual threshold, it indicates that the corresponding random generation strategy can accurately predict the system state. At this time, the sample with the smallest sample residual (i.e., the smallest prediction error) is selected from these target sample information as the result sample information. For example, if the residual of a sample after being processed by the strategy is 0.005, which is below the threshold and the minimum value, then its corresponding random generation strategy is determined as the target generation strategy. Conversely, if all sample residuals are not less than the preset threshold, it means that the current generation strategy has failed to effectively approximate the actual system state and it is necessary to return to regenerate the random strategy. After determining the target generation strategy, it is applied to a deep Q-network model (DQN); the deep Q-network model is a model based on deep reinforcement learning. It uses a convolutional neural network to approximate the behavior-value function, uses an experience replay mechanism to break data correlation, and reduces training bias through the target network. For example, the mutation rules contained in the target generation strategy are used as model input parameters. The model aims to maximize the linear sum of the system code coverage C and the number of defects discovered N. Through iterative training, the strategy parameters are optimized, and ultimately outputs a brute force data generation model that can adaptively generate high-value brute force test data. This model can dynamically adjust the generation strategy to solve the problems of existing technologies such as lack of self-learning ability and difficulty in coping with complex systems, and improve the coverage efficiency of test data for system edge scenarios.
[0056] The technical solution of the embodiment of the present invention obtains a sample data set and generates random generation strategies that match each sample state information according to a preset strategy generation rule. The random generation strategy is then used to process the sample state information to obtain random sample information that matches the sample state information. The sample residual of each random sample information is then calculated according to a preset formula, and it is determined whether there is target sample information whose sample residual is less than a preset residual threshold. Finally, a target generation strategy is determined in each random generation strategy based on the judgment result, and the target generation strategy is applied to a pre-configured deep Q network model to obtain a brute force data generation model, thereby realizing the construction of a brute force data generation model, improving the generation rate of brute force test data and the efficiency of the generated brute force test data, and thereby improving the generation rate and efficiency of test data.
[0057] Example 3
[0058] Figure 3 This is a structural diagram of a test data generation device provided in Example 3 of the present invention.
[0059] like Figure 3 As shown, the device includes:
[0060] Data acquisition module 310, used to acquire historical data sets;
[0061] a violence data generation module 320 for processing the historical data set based on a pre-trained violence data generation model to obtain a violence data set that matches the historical data set;
[0062] The test data generation module 330 is configured to process the historical data set and the violent data set based on a pre-trained test data generation model to obtain a test data set.
[0063] The technical solution of the embodiment of the present invention first obtains a historical data set, then processes the historical data set based on a pre-trained brute force data generation model to obtain a brute force data set that matches the historical data set, and finally processes the historical data set and the brute force data set based on a pre-trained test data generation model to obtain a test data set. This solves the problem of low test data generation rate and data generation efficiency in existing test data generation methods, which in turn leads to low efficiency of software testing work, realizes the generation of data for software testing, improves the test data generation rate and data generation efficiency, and thus improves the efficiency of software testing work.
[0064] On the basis of the above steps, the test data generating device further includes: a violent data generating model building module, which is used to build a violent data generating model.
[0065] Based on the above steps, the brute force data generation model building module includes:
[0066] A sample data acquisition unit is configured to acquire a sample data set and generate status information of each sample based on the sample data set and preset rules, wherein the sample data includes: sample test data and a test result label matching the sample test data;
[0067] A random strategy generation unit, configured to generate a random generation strategy that matches each sample state information according to a preset strategy generation rule;
[0068] a random sample information acquisition unit, configured to process the sample state information using a random generation strategy to obtain random sample information matching the sample state information, wherein the random sample information includes random test data and a random result label matching the random test data;
[0069] A sample residual calculation unit is used to calculate the sample residual of each random sample information according to a preset formula, and determine whether there is target sample information whose sample residual is less than a preset residual threshold;
[0070] The strategy configuration unit is used to determine the target generation strategy in each random generation strategy according to the judgment result, and apply the target generation strategy to the pre-configured deep Q network model to obtain a brute force data generation model.
[0071] Based on the above embodiment, the sample data acquisition unit includes:
[0072] A specific data acquisition unit is used to respectively acquire sample test data I and test result labels E of each sample data in the sample data set;
[0073] The sample state information calculation unit is used to calculate the sample state information s matching each sample data according to the formula s=(I, E).
[0074] Based on the above embodiment, the random strategy generation unit includes:
[0075] A shuffling unit, configured to process each sample state information separately using a Fisher-Yates shuffling algorithm to obtain a random position selection result that matches each sample state information;
[0076] A random value unit is used to process each sample state information respectively through a random value generation strategy to obtain a random value generation result that matches each sample state information respectively;
[0077] The aggregation unit is used to aggregate the random position selection result and the random value generation result to obtain a random generation strategy that matches the sample state information.
[0078] Based on the above embodiment, the sample residual calculation unit includes:
[0079] a parameter acquisition unit, configured to acquire parameters of a pre-configured deep Q network model and parameters of a pre-configured target deep Q network model, and respectively acquire code coverage C, number of defects N, and discount factor of each random sample information;
[0080] A random reward value calculation unit, configured to calculate a random reward value that matches each random sample information according to the formula r=α*C+β*N, where α and β are linear parameters and α+β=1;
[0081] A residual calculation strategy generation unit, configured to generate a residual calculation strategy matching each random sample information according to a preset strategy generation rule;
[0082] a residual processing unit, configured to process the random sample information using a residual calculation strategy to obtain residual sample information matching the residual sample information;
[0083] A random sample residual calculation unit is used to calculate the sample residual of each random sample information based on a preset formula, a discount factor that matches each random sample information, a random generation strategy, random sample information, a residual calculation strategy, and residual sample information; wherein the preset formula is: loss = G[(r+γ*max k′ (Q(w′, k′; θ - )-Q(w, k; θ)) 2 ]; where loss is the sample residual, G is the random result label of the random sample information, γ is the discount factor, Q() is the state-action value function, w is the random sample information, k is the random generation strategy, w' is the residual sample information, k' is the residual calculation strategy, θ is the parameter of the deep Q network model, θ - are the parameters of the target deep Q network model.
[0084] Based on the above embodiment, the policy configuration unit includes:
[0085] a first judgment unit configured to, if there is at least one target sample information whose sample residual is less than a preset residual threshold, select the target sample information with the smallest sample residual from among the target sample information as the result sample information, and determine the random generation strategy matching the result sample information as the target generation strategy;
[0086] The second judgment unit is configured to return to executing the operation of generating random generation strategies matching each sample state information according to a preset strategy generation rule if there is no target sample information having at least one sample residual less than a preset residual threshold.
[0087] On the basis of the above steps, the test data generation device also includes: a test data generation model construction module, which is used to obtain a test data set, wherein the test data set includes: at least one sample data and at least one historical violence data; according to a preset random proportion generation rule, a test proportion value matching the test data set is generated; according to the test proportion value, the number of sample test data and the number of historical violence data in the test data set are adjusted to obtain an updated test data set; the test residual of the test data set is calculated according to a preset formula, and it is determined whether the test residual is less than a preset test residual value; if it is less, the test proportion value matching the test residual value is applied to a pre-configured deep Q network model to obtain a test data generation model; if it is not less than, the operation of generating a test proportion value matching the test data set according to the preset random proportion generation rule is returned.
[0088] A test data generation device provided by an embodiment of the present invention can execute a test data generation method provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0089] Example 4
[0090] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0091] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by the at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12 and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0092] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0093] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a method for generating test data.
[0094] Accordingly, the method includes:
[0095] Get historical data sets;
[0096] Processing the historical dataset based on a pre-trained violence data generation model to obtain a violence dataset matching the historical dataset;
[0097] The historical data set and the violent data set are processed based on a pre-trained test data generation model to obtain a test data set.
[0098] In some embodiments, a method for generating test data can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the method for generating test data described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform a method for generating test data in any other appropriate manner (e.g., by means of firmware).
[0099] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0100] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0101] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0102] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0103] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0104] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0105] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
Claims
1. A method for generating test data, characterized in that: include: Get historical data sets; Processing the historical dataset based on a pre-trained violence data generation model to obtain a violence dataset matching the historical dataset; The historical data set and the violent data set are processed based on a pre-trained test data generation model to obtain a test data set.
2. The method according to claim 1, characterized in that The construction process of the brute force data generation model includes: Acquire a sample data set, and generate status information of each sample based on the sample data set and preset rules, wherein the sample data includes: sample test data and a test result label matching the sample test data; Generate random generation strategies that match the status information of each sample according to the pre-set strategy generation rules; Processing the sample state information using a random generation strategy to obtain random sample information matching the sample state information, wherein the random sample information includes: random test data and a random result label matching the random test data; Calculate the sample residual of each random sample information according to a preset formula, and determine whether there is target sample information whose sample residual is less than a preset residual threshold; According to the judgment result, a target generation strategy is determined in each random generation strategy, and the target generation strategy is applied to a pre-configured deep Q network model to obtain a brute force data generation model.
3. The method according to claim 2, characterized in that Obtaining a sample data set, and generating status information of each sample based on the sample data set and preset rules, including: Obtain sample test data I and test result label E for each sample data in the sample data set respectively; The sample status information s matching each sample data is calculated according to the formula s=(I, E).
4. The method according to claim 2, characterized in that According to the pre-set strategy generation rules, a random generation strategy matching the status information of each sample is generated, including: The state information of each sample is processed respectively by the Fisher-Yates shuffling algorithm to obtain a random position selection result that matches the state information of each sample; The state information of each sample is processed respectively by a random value generation strategy to obtain a random value generation result that matches the state information of each sample; The random position selection result and the random value generation result are aggregated to obtain a random generation strategy that matches the sample state information.
5. The method according to claim 2, characterized in that The sample residual of each random sample information is calculated according to the preset formula, including: Obtain parameters of a pre-configured deep Q network model and parameters of a pre-configured target deep Q network model, and obtain code coverage C, defect count N, and discount factor of each random sample information respectively; The random reward value that matches each random sample information is calculated according to the formula r = α*C + β*N, where α and β are linear parameters and α + β = 1; According to the pre-set strategy generation rules, a residual calculation strategy matching each random sample information is generated respectively; Processing the random sample information using a residual calculation strategy to obtain residual sample information matching the residual sample information; The sample residual of each random sample information is obtained based on a preset formula, a discount factor respectively matched with each random sample information, a random generation strategy, random sample information, a residual calculation strategy and residual sample information; Wherein, the preset formula is: loss = G[(r+γ*max k′ (Q(w′, k′; θ - )-Q(w, k; θ)) 2 ]; Where loss is the sample residual, G is the random result label of the random sample information, γ is the discount factor, Q() is the state-action value function, w is the random sample information, k is the random generation strategy, w' is the residual sample information, k' is the residual calculation strategy, θ is the parameter of the deep Q network model, θ - are the parameters of the target deep Q network model.
6. The method according to claim 2, characterized in that According to the judgment results, the target generation strategy is determined in each random generation strategy, including: If there is at least one target sample information whose sample residual is less than a preset residual threshold, the target sample information with the smallest sample residual is selected from the target sample information as the result sample information, and the random generation strategy matching the result sample information is determined as the target generation strategy; If there is no target sample information with at least one sample residual less than the preset residual threshold, the process returns to executing the operation of generating random generation strategies matching each sample state information according to the preset strategy generation rules.
7. The method according to claim 1, characterized in that The construction process of the test data generation model includes: Acquire a test data set, wherein the test data set includes: at least one sample data and at least one historical violence data; Generate a test ratio value matching the test data set according to a preset random ratio generation rule; According to the test ratio value, the number of sample test data and the number of historical violence data in the test data set are adjusted to obtain an updated test data set; Calculate the test residual of the test data set according to a preset formula, and determine whether the test residual is less than a preset test residual value; If it is less than, applying the test ratio value matching the test residual value to the pre-configured deep Q network model to obtain a test data generation model; If it is not less than, the operation of generating a test ratio value that matches the test data set according to a preset random ratio generation rule is returned.
8. A device for generating test data, characterized in that: include: Data acquisition module, used to obtain historical data sets; a violence data generation module, configured to process the historical data set based on a pre-trained violence data generation model to obtain a violence data set matching the historical data set; The test data generation module is used to process the historical data set and the violent data set based on a pre-trained test data generation model to obtain a test data set.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform a test data generating method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a test data generation method according to any one of claims 1 to 7 when executed.