Software testing method, device, equipment and medium
By recording and randomly mutating the initial reproduction data in software testing, the problem of difficult-to-reproduce problems in automated testing in complex systems is solved, and efficient problem location and improvement of development progress are achieved.
Patent Information
- Application Number
- CN202211378854.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-04
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-11-04
AI Technical Summary
In software testing of complex systems, automated testing is difficult to reproduce problems 100%, which leads to difficulties in R&D progress and problem location.
By recording each step and the interval time between adjacent steps in the software execution script, the random mutation method is used to generate test samples, and the loop iteration is stopped when certain conditions are met, and the target test samples that meet the requirements are screened out to reproduce the problem.
It increases the probability of problem recurrence, helps R&D personnel quickly locate problems, and improves development efficiency.
Smart Images

Figure CN115543851B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software development, and in particular to a software testing method, device, equipment and medium. Background Art
[0002] Automated software testing can effectively improve testing efficiency and is crucial for quickly discovering software issues and ensuring their correctness, integrity, security, and quality. However, in complex systems, the conditions for reproducing many issues are often very demanding. During automated testing, the steps that occasionally trigger an issue often fail to fully replicate the problem, and often contain numerous irrelevant operations unrelated to the issue itself. This significantly increases the difficulty for R&D personnel in analyzing, locating, and resolving the issue, impacting software development progress and delivery cycles.
[0003] As can be seen from the above, in the process of software testing, how to provide an effective problem reproduction method is a problem to be solved in this field. Summary of the Invention
[0004] In view of this, the present invention aims to provide a software testing method, apparatus, device, and medium that can re-screen initial recurrence data from test samples, perform random mutations, stop loop iterations after certain conditions are met, and output target test samples that meet the requirements, thereby reproducing the problem with a high probability in a targeted manner. The specific scheme is as follows:
[0005] In a first aspect, the present application discloses a software testing method, comprising:
[0006] Record the time interval between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and determine the initial reproduction data based on the time interval between each step and adjacent steps;
[0007] Randomly modifying the initial recurrence data using a preset random mutation method to determine modified data, and determining a test sample using the initial recurrence data and the modified data;
[0008] Determine the probability of reproducing the problem for each test sample, and determine whether there is a target test sample among all samples whose probability of reproducing the problem is greater than or equal to a preset probability threshold;
[0009] If the probability that there is no recurrence problem in all samples is greater than or equal to the target test sample of the preset probability threshold, the preset sample evaluation method is used to determine the evaluation score of each test sample, and the preset number of samples with the highest evaluation scores are used as the initial recurrence data, and the process jumps to the step of randomly modifying the initial recurrence data using the preset random mutation method until the probability that there is a recurrence problem in all samples is greater than or equal to the target test sample of the preset probability threshold, so as to determine the recurrence problem using the current test sample.
[0010] Optionally, recording the time interval between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and determining the initial recurrence data based on the time interval between each step and adjacent steps, includes:
[0011] Record each step before the problem is discovered during the execution of the preset software execution script and generate a first vector;
[0012] Recording the interval time between adjacent steps before the problem is discovered, and generating a second vector;
[0013] The first vector and the second vector are used as initial reproduction data.
[0014] Optionally, the process of recording each step before the problem is discovered during the execution of the preset software script and generating the first vector includes:
[0015] Determine the problem step in which the problem is discovered, and determine the previous step of the problem step as the target step;
[0016] If the number of actual operation steps during the execution of the preset software execution script is less than the number of steps of the target steps, the element value corresponding to the actual operation step to the target step in the first vector is determined as the element value representing the empty operation.
[0017] Optionally, randomly modifying the initial recurrence data using a preset random mutation method to determine modified data includes:
[0018] generating a first mutation vector based on a preset mutation probability, and modifying the first vector based on the first mutation vector to determine a modified first vector;
[0019] A second variation vector is generated based on a preset variation vector generation method based on normal distribution, and the second vector is modified based on the second variation vector to determine a modified second vector.
[0020] Optionally, determining a test sample using the initial recurrence data and the modified data includes:
[0021] The first vector, the modified first vector and the second vector, the modified second vector are randomly combined to determine a test sample.
[0022] Optionally, determining the evaluation score of each test sample by using a preset sample evaluation method includes:
[0023] Determine the number of steps in each sample whose element values in the first vector represent non-empty operations, and determine an evaluation score for each sample based on the probability of each sample reproducing the problem and the number of steps in which the element values in the first vector represent non-empty operations.
[0024] Optionally, determining the probability of each test sample reproducing the problem includes:
[0025] The preset software execution script is tested according to a preset number of tests and based on each test sample to determine the probability of each test sample reproducing the problem.
[0026] In a second aspect, the present application discloses a software testing device, comprising:
[0027] An initial recurrence data determination module is used to record the time interval between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and to determine the initial recurrence data based on the time interval between each step and adjacent steps;
[0028] A data random mutation module, configured to randomly modify the initial recurring data using a preset random mutation method to determine modified data, and to determine a test sample using the initial recurring data and the modified data;
[0029] A judgment module is used to determine the probability of recurring the problem for each test sample and to determine whether there is a target test sample among all samples whose probability of recurring the problem is greater than or equal to a preset probability threshold;
[0030] The sample evaluation and screening module is used to determine the evaluation score of each test sample using a preset sample evaluation method if the probability of the absence of a recurrence problem in all samples is greater than or equal to a preset probability threshold of the target test sample, and use the preset number of samples with the highest evaluation scores as the initial recurrence data, and jump to the step of randomly modifying the initial recurrence data using a preset random mutation method, until the probability of the presence of a recurrence problem in all samples is greater than or equal to the preset probability threshold of the target test sample, so as to determine the recurrence problem using the target test sample.
[0031] In a third aspect, the present application discloses an electronic device, comprising:
[0032] Memory, used to store computer programs;
[0033] The processor is used to execute the computer program to implement the aforementioned software testing method.
[0034] In a fourth aspect, the present application discloses a computer storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the software testing method disclosed above are implemented.
[0035] The present application first records the interval time between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and determines the initial recurrence data based on the interval time between each step and adjacent steps; uses a preset random mutation method to randomly modify the initial recurrence data to determine the modified data, and uses the initial recurrence data and the modified data to determine the test sample; determines the probability of recurrence of the problem for each test sample, and determines whether there is a target test sample with a probability of recurrence greater than or equal to a preset probability threshold among all samples; if there is no target test sample with a probability of recurrence greater than or equal to the preset probability threshold among all samples, then uses a preset sample evaluation method to determine the evaluation score of each test sample, and uses the preset number of samples with the highest evaluation score as the initial recurrence data, and jumps to the step of randomly modifying the initial recurrence data using the preset random mutation method until there is a target test sample with a probability of recurrence greater than or equal to the preset probability threshold among all samples, so as to determine the recurrence problem using the current test sample. The present invention re-screens the initial recurrence data from the test sample for random mutation, stops the loop iteration after a certain condition is met, and outputs the target test sample that meets the requirements for debugging by R&D personnel. This method of using evaluation screening rules and random mutation can increase the probability of problem reproduction, help R&D personnel quickly locate problems, and improve development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0037] Figure 1 A flowchart of a software testing method provided for this application;
[0038] Figure 2 A flowchart of a specific software testing method provided for this application;
[0039] Figure 3 A schematic diagram of the structure of a software testing device provided in this application;
[0040] Figure 4 This is a structural diagram of an electronic device provided in this application. DETAILED DESCRIPTION
[0041] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments 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 are within the scope of protection of the present invention.
[0042] In the prior art, in some complex systems, the conditions for reproducing many problems are often very demanding. In automated testing, the operation steps that accidentally trigger a problem usually cannot reproduce the problem 100%, which in turn affects the progress of research and development. In this application, an effective problem reproduction method is provided, which can re-screen the initial reproduction data from the test sample and perform random mutations. After meeting certain conditions, the loop iteration is stopped and the target test sample that meets the requirements is output, which can reproduce the problem in a targeted manner with a high probability.
[0043] The embodiment of the present invention discloses a software testing method, see Figure 1 Said method comprises:
[0044] Step S11: Record the interval time between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and determine the initial recurrence data based on the interval time between each step and adjacent steps.
[0045] In this embodiment, recording each step and the interval time between adjacent steps before the problem is discovered during the execution of the preset software execution script, and determining the initial reproduction data based on each step and the interval time between adjacent steps, can include: recording each step before the problem is discovered during the execution of the preset software execution script, and generating a first vector; recording the interval time between adjacent steps before the problem is discovered, and generating a second vector; and using the first vector and the second vector as the initial reproduction data.
[0046] In a specific embodiment of the present application, the time interval between each step and adjacent steps before the problem is found during the execution of the preset software execution script can be recorded by a first vector X and a second vector T respectively. Assuming that N steps are required to reproduce the problem, the operation steps are recorded as an N-dimensional vector X = (x1, x2, x3, ..., x N ), where x i Indicates the operation performed for the i-th time, x i =0 means no operation, x i =1 indicates the first possible operation, and so on. The time interval is recorded as an N-1 dimensional vector T = (t1, t2, t3, ..., tN-1 ), where t i Indicates operation step x i and x i+1 When a problem is discovered, record the N operations before the problem occurs and their time interval as X and T.
[0047] In this embodiment, the process of recording each step before the problem is discovered during the execution of the preset software execution script and generating the first vector may include: determining the problem step where the problem is discovered, and determining the step before the problem step as the target step; if the number of actual operation steps during the execution of the preset software execution script is less than the number of steps of the target step, then determining the element value corresponding to the actual operation step to the target step in the first vector as the element value representing the empty operation. That is, if the actual number of operation steps M is less than N, then let x M+1 to x N Equal to 0.
[0048] Step S12: randomly modifying the initial recurrence data using a preset random mutation method to determine modified data, and determining a test sample using the initial recurrence data and the modified data.
[0049] In this embodiment, the initial recurrence data is randomly modified using a preset random mutation method. In a specific embodiment, the random modification includes modification of the first vector and modification of the second vector, namely, random modification of X to determine X' and random modification of T to determine T'. X, X', T, and T' are then combined to obtain a test sample. This method of randomly modifying the initial recurrence data using a preset random mutation method and determining a test sample using the initial recurrence data and the modified data can expand the search sample space.
[0050] Step S13: Determine the probability of each test sample reproducing the problem, and determine whether there is a target test sample among all samples whose probability of reproducing the problem is greater than or equal to a preset probability threshold.
[0051] In this embodiment, determining the probability of each test sample reproducing the problem may include: testing the preset software execution script based on each test sample according to a preset number of tests to determine the probability of each test sample reproducing the problem.
[0052] In this embodiment, all samples can be tested multiple times, and the probability P of each sample reproducing the problem is recorded. q The specific implementation method is preferably to test the preset software execution script according to a preset number of tests and based on each test sample to determine the probability of reproducing the problem in each test sample.
[0053] Step S14: If the probability that there is no recurrence problem among all samples is greater than or equal to the target test sample of the preset probability threshold, the preset sample evaluation method is used to determine the evaluation score of each test sample, and the preset number of samples with the highest evaluation scores are used as the initial recurrence data, and the process jumps to the step of randomly modifying the initial recurrence data using the preset random mutation method, until the probability that there is a recurrence problem among all samples is greater than or equal to the target test sample of the preset probability threshold, so as to determine the recurrence problem using the target test sample.
[0054] In this embodiment, if there is a recurrence probability greater than or equal to the preset probability threshold P in the sample e The target test sample will directly output a probability of recurrence greater than or equal to the preset probability P e All samples are sent to R&D personnel for analysis and debugging; if there is no recurrence probability greater than or equal to the preset probability threshold P in the sample e , the preset number of samples with the highest evaluation scores will be used as the initial reproduction data, that is, the step of randomly modifying the initial reproduction data using the preset random mutation method will be re-executed by re-screening the initial reproduction data, until the probability of the existence of the reproduction problem in all samples is greater than or equal to the preset probability threshold of the target test sample.
[0055] In this embodiment, the use of a preset sample evaluation method to determine the evaluation score of each test sample may include: determining the number of steps in each sample whose element values in the first vector represent non-empty operations, and determining the evaluation score of each sample based on the probability of each sample reproducing the problem and the number of steps in the first vector whose element values represent non-empty operations.
[0056] In this embodiment, in the process of calculating the evaluation score Q of each sample, the number of non-zero elements L (ie, the number of non-empty operations) in each sample can be calculated, and then based on Q=P q *f(L), get the evaluation score Q of each sample, where P q is the probability of reproducing the problem for each sample, and f(L) is a monotonically decreasing function of L. Therefore, it can be seen that the greater the probability of recurrence or the fewer non-zero elements in the sample, the higher the evaluation score.
[0057] In this embodiment, the interval time between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script is first recorded, and the initial recurrence data is determined based on the interval time between each step and adjacent steps; the initial recurrence data is randomly modified using a preset random mutation method to determine the modified data, and the test sample is determined using the initial recurrence data and the modified data; the probability of recurrence of the problem in each test sample is determined, and it is determined whether there is a target test sample with a probability of recurrence greater than or equal to a preset probability threshold among all samples; if the probability of no recurrence of the problem in all samples is greater than or equal to the preset probability threshold, the evaluation score of each test sample is determined using a preset sample evaluation method, and the preset number of samples with the highest evaluation score are used as the initial recurrence data, and the process is skipped to the step of randomly modifying the initial recurrence data using the preset random mutation method until the target test sample with a probability of recurrence greater than or equal to the preset probability threshold among all samples is found, so as to determine the recurrence problem using the current test sample. The present invention re-screens the initial recurrence data from the test sample for random mutation, and stops the loop iteration after a certain condition is met, outputting the target test sample that meets the requirements for debugging by R&D personnel. This method of using evaluation screening rules and random mutation can increase the probability of problem reproduction, help R&D personnel quickly locate problems, and improve development efficiency.
[0058] Figure 2 This is a flowchart of a specific software testing method provided in the embodiment of this application. Figure 2 As shown, the method includes:
[0059] Step S21: Record each step before the problem is discovered during the execution of the preset software execution script and generate a first vector; record the interval time between adjacent steps before the problem is discovered and generate a second vector; use the first vector and the second vector as initial reproduction data.
[0060] For a more specific processing procedure of step S21 , reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0061] Step S22: Generate a first mutation vector based on a preset mutation probability, and modify the first vector based on the first mutation vector to determine the modified first vector; generate a second mutation vector based on a preset mutation vector generation method based on normal distribution, and modify the second vector based on the second mutation vector to determine the modified second vector.
[0062] In this embodiment, when modifying vector X, you can first calculate the mutation probability P y Generate a set of mutation vectors Y=(y1,y2,y3,…,y N ), yi =-1 means no modification, y i =0 means changing step i to no operation, y i =1 means that the i-th step is modified to the first possible operation, and so on. It should be noted that in this step, the mutation vector Y should satisfy y i The probability of ≠-1 is equal to P y (where i = 1, 2, 3, ..., N), and then modify vector X according to vector Y to obtain X'. In a preferred embodiment, the following method can be selected to determine X':
[0063] X'=(x1',x'2,...,x' N ),in,
[0064] In this embodiment, when modifying the vector T, it is possible to first modify the vector T according to the normal distribution N(0,σ 2 ) generates a set of mutation vectors U=(u1,u2,u3,…,u N-1 ),u i Indicates the modification increment of the i-th element in T, u in this set of vectors i The value should satisfy the normal distribution N(0,σ 2 ) (where i = 1, 2, 3, ..., N-1). Then, T and U can be added together to obtain T'. As follows:
[0065] T'=(t1',t'2,...,t' N ),in,
[0066] Step S23: Randomly combine the first vector, the modified first vector, the second vector, and the modified second vector to determine a test sample.
[0067] In this embodiment, after X' is determined based on X and T' is determined based on T, the original X and T, and the newly obtained X' and T' can be combined to obtain a test sample.
[0068] Step S24: Determine the probability of each test sample reproducing the problem, and determine whether there is a target test sample among all samples whose probability of reproducing the problem is greater than or equal to a preset probability threshold.
[0069] For a more specific processing procedure of step S24, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be elaborated here.
[0070] Step S25: If the probability that there is no recurrence problem among all samples is greater than or equal to the target test sample with a preset probability threshold, the preset sample evaluation method is used to determine the evaluation score of each test sample, and the preset number of samples with the highest evaluation scores are used as the initial recurrence data, and the process jumps to the step of randomly modifying the initial recurrence data using the preset random mutation method, until the probability that there is a recurrence problem among all samples is greater than or equal to the target test sample with a preset probability threshold, so as to determine the recurrence problem using the target test sample.
[0071] For a more specific processing procedure of step S25 , reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be elaborated here.
[0072] Thus, this embodiment proposes a specific implementation process for random mutation, namely, generating a first mutation vector based on a preset mutation probability, modifying the first vector based on the first mutation vector, generating a second mutation vector based on a preset mutation vector generation method based on a normal distribution, and modifying the second vector based on the second mutation vector. Furthermore, this embodiment determines initial recurrence data by recording the time intervals between each step and adjacent steps before the problem is discovered during the execution of a preset software script. Test samples are then determined using the initial recurrence data and the modified data obtained by randomly mutating the initial recurrence data. If a target test sample with a probability of recurring the problem greater than or equal to a preset probability threshold is present in the sample, the target test sample is output for debugging by R&D personnel. If a target test sample with a probability of recurring the problem greater than or equal to the preset probability threshold is not present in the sample, the initial recurrence data is re-determined and random mutation is performed again until a target test sample with a probability of recurring the problem greater than or equal to the preset probability threshold is present. The method proposed in this invention, which utilizes evaluation and screening rules and random mutation, can improve the probability of problem recurrence, helping R&D personnel quickly locate problems and enhance development efficiency.
[0073] See also Figure 3 As shown, the embodiment of the present application discloses a software testing device, which may specifically include:
[0074] The initial recurrence data determination module 11 is used to record the interval time between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and determine the initial recurrence data based on the interval time between each step and adjacent steps;
[0075] The data random mutation module 12 is used to randomly modify the initial recurring data using a preset random mutation method to determine modified data, and to determine a test sample using the initial recurring data and the modified data;
[0076] The judgment module 13 is used to determine the probability of recurrence of the problem for each test sample and to determine whether there is a target test sample among all samples whose probability of recurrence of the problem is greater than or equal to a preset probability threshold;
[0077] The sample evaluation and screening module 14 is used to determine the evaluation score of each test sample using a preset sample evaluation method if the probability of the absence of a recurrence problem in all samples is greater than or equal to a preset probability threshold of the target test sample, and use the preset number of samples with the highest evaluation scores as the initial recurrence data, and jump to the step of randomly modifying the initial recurrence data using the preset random mutation method, until the probability of the presence of a recurrence problem in all samples is greater than or equal to the preset probability threshold of the target test sample, so as to determine the recurrence problem using the target test sample.
[0078] In this embodiment, the interval time between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script is first recorded, and the initial recurrence data is determined based on the interval time between each step and adjacent steps; the initial recurrence data is randomly modified using a preset random mutation method to determine the modified data, and the test sample is determined using the initial recurrence data and the modified data; the probability of recurrence of the problem in each test sample is determined, and it is determined whether there is a target test sample with a probability of recurrence greater than or equal to a preset probability threshold among all samples; if the probability of no recurrence of the problem in all samples is greater than or equal to the preset probability threshold, the evaluation score of each test sample is determined using a preset sample evaluation method, and the preset number of samples with the highest evaluation score are used as the initial recurrence data, and the process is skipped to the step of randomly modifying the initial recurrence data using the preset random mutation method until the probability of recurrence of the problem in all samples is greater than or equal to the preset probability threshold, so as to determine the recurrence problem using the current test sample. In the present invention, the initial recurrence data is re-screened from the test sample for random mutation, and the loop iteration is stopped after a certain condition is met, and the target test sample that meets the requirements is output for debugging by R&D personnel. This method of using evaluation screening rules and random mutation can increase the probability of problem reproduction, help R&D personnel quickly locate problems, and improve development efficiency.
[0079] In some specific embodiments, the initial recurrence data determination module 11 may specifically include:
[0080] A first vector generating unit is used to record each step before the problem is found in the process of executing the preset software execution script, and generate a first vector;
[0081] A second vector generating unit, configured to record the interval time between adjacent steps before the problem is discovered, and generate a second vector;
[0082] The first initial recurring data determining unit is configured to use the first vector and the second vector as initial recurring data.
[0083] In some specific embodiments, the first vector generating unit specifically includes:
[0084] A target step determining unit, configured to determine a problem step in which a problem is discovered, and determine the step preceding the problem step as a target step;
[0085] An element value determination unit is used to determine the element value corresponding to the actual operation step to the target step in the first vector as the element value representing the empty operation if the number of actual operation steps during the execution of the preset software execution script is less than the number of steps of the target step.
[0086] In some specific embodiments, the data random mutation module 12 may specifically include:
[0087] a modified first vector determining unit, configured to generate a first mutation vector based on a preset mutation probability, and modify the first vector based on the first mutation vector to determine a modified first vector;
[0088] The modified second vector determining unit is configured to generate a second variation vector based on a preset variation vector generating method based on normal distribution, and modify the second vector based on the second variation vector to determine a modified second vector.
[0089] In some specific embodiments, the data random mutation module 12 may specifically include:
[0090] The vector combining unit is configured to randomly combine the first vector, the modified first vector and the second vector, the modified second vector to determine a test sample.
[0091] In some specific embodiments, the sample evaluation and screening module 14 may specifically include:
[0092] An evaluation score determination unit is used to determine the number of steps in each sample whose element values in the first vector represent non-empty operations, and determine the evaluation score of each sample based on the probability of each sample reproducing the problem and the number of steps in the first vector whose element values represent non-empty operations.
[0093] In some specific embodiments, the judgment module 13 may specifically include:
[0094] The sample testing unit is used to test the preset software execution script according to a preset number of tests and based on each test sample to determine the probability of each test sample reproducing the problem.
[0095] Furthermore, the embodiment of the present application also discloses an electronic device, Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.
[0096] Figure 4 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a display 24, an input / output interface 25, a communication interface 26, and a communication bus 27. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the following:
[0097] Record the time interval between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and determine the initial reproduction data based on the time interval between each step and adjacent steps;
[0098] Randomly modifying the initial recurrence data using a preset random mutation method to determine modified data, and determining a test sample using the initial recurrence data and the modified data;
[0099] Determine the probability of reproducing the problem for each test sample, and determine whether there is a target test sample among all samples whose probability of reproducing the problem is greater than or equal to a preset probability threshold;
[0100] If the probability that there is no recurrence problem in all samples is greater than or equal to the target test sample of the preset probability threshold, the preset sample evaluation method is used to determine the evaluation score of each test sample, and the preset number of samples with the highest evaluation scores are used as the initial recurrence data, and the process jumps to the step of randomly modifying the initial recurrence data using the preset random mutation method until the probability that there is a recurrence problem in all samples is greater than or equal to the target test sample of the preset probability threshold, so as to determine the recurrence problem using the current test sample.
[0101] In some specific embodiments, the processor may further include the following steps by executing the computer program stored in the memory:
[0102] Record each step before the problem is discovered during the execution of the preset software execution script and generate a first vector;
[0103] Recording the interval time between adjacent steps before the problem is discovered, and generating a second vector;
[0104] The first vector and the second vector are used as initial reproduction data.
[0105] In some specific embodiments, the processor may further include the following steps by executing the computer program stored in the memory:
[0106] Determine the problem step in which the problem is discovered, and determine the previous step of the problem step as the target step;
[0107] If the number of actual operation steps during the execution of the preset software execution script is less than the number of steps of the target steps, the element value corresponding to the actual operation step to the target step in the first vector is determined as the element value representing the empty operation.
[0108] In some specific embodiments, the processor may further include the following steps by executing the computer program stored in the memory:
[0109] generating a first mutation vector based on a preset mutation probability, and modifying the first vector based on the first mutation vector to determine a modified first vector;
[0110] A second variation vector is generated based on a preset variation vector generation method based on normal distribution, and the second vector is modified based on the second variation vector to determine a modified second vector.
[0111] In some specific embodiments, the processor may further include the following steps by executing the computer program stored in the memory:
[0112] The first vector, the modified first vector and the second vector, the modified second vector are randomly combined to determine a test sample.
[0113] In some specific embodiments, the processor may further include the following steps by executing the computer program stored in the memory:
[0114] Determine the number of steps in each sample whose element values in the first vector represent non-empty operations, and determine an evaluation score for each sample based on the probability of each sample reproducing the problem and the number of steps in which the element values in the first vector represent non-empty operations.
[0115] In some specific embodiments, the processor may further include the following steps by executing the computer program stored in the memory:
[0116] The preset software execution script is tested according to a preset number of tests and based on each test sample to determine the probability of each test sample reproducing the problem.
[0117] In addition, the electronic device 20 in this embodiment can specifically be an electronic computer. Furthermore, in this embodiment, the power supply 23 is used to provide operating voltage for the hardware devices on the electronic device 20. The communication interface 26 can establish a data transmission channel between the electronic device 20 and external devices. The communication protocol it follows can be any communication protocol applicable to the technical solution of this application and is not specifically limited here. The input and output interface 25 is used to obtain external input data or output data to the outside world. The specific interface type can be selected according to the specific application needs and is not specifically limited here.
[0118] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, a magnetic disk, or an optical disk. The resources stored thereon may include an operating system 221, a computer program 222, and virtual machine data 223. The virtual machine data 223 may include various data. The storage method may be temporary storage or permanent storage.
[0119] The operating system 221 is used to manage and control the hardware devices on the electronic device 20 and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs that can be used to implement the software testing method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs that can be used to perform other specific tasks.
[0120] Furthermore, the present application also discloses a computer-readable storage medium, where the computer-readable storage medium includes a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a magnetic disk, or an optical disk, or any other form of storage medium known in the technical field. When the computer program is executed by a processor, the software testing method disclosed above is implemented. For the specific steps of the method, reference can be made to the corresponding contents disclosed in the aforementioned embodiments, and no further description will be given here.
[0121] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. Professionals can also further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0122] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0123] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0124] The software testing method, apparatus, equipment, and storage medium provided by the present invention are introduced in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.
Claims
1. A software testing method, characterized in that: include: Record the time interval between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and determine the initial reproduction data based on the time interval between each step and adjacent steps; Randomly modifying the initial recurrence data using a preset random mutation method to determine modified data, and determining a test sample using the initial recurrence data and the modified data; Determine the probability of reproducing the problem for each test sample, and determine whether there is a target test sample among all samples whose probability of reproducing the problem is greater than or equal to a preset probability threshold; If the probability that there is no recurrence problem in all samples is greater than or equal to the target test sample of the preset probability threshold, the preset sample evaluation method is used to determine the evaluation score of each test sample, and the preset number of samples with the highest evaluation scores are used as the initial recurrence data, and the process jumps to the step of randomly modifying the initial recurrence data using the preset random mutation method until the probability that there is a recurrence problem in all samples is greater than or equal to the target test sample of the preset probability threshold, so as to determine the recurrence problem using the current test sample.
2. The software testing method according to claim 1, wherein: The recording of each step and the interval between adjacent steps before the problem is discovered during the execution of the preset software execution script, and determining the initial recurrence data based on the interval between each step and the interval between adjacent steps, includes: Record each step before the problem is discovered during the execution of the preset software execution script and generate a first vector; Recording the interval time between adjacent steps before the problem is discovered, and generating a second vector; The first vector and the second vector are used as initial reproduction data.
3. The software testing method according to claim 2, characterized in that: The process of recording each step before the problem is discovered during the execution of the preset software script and generating the first vector includes: Determine the problem step in which the problem is discovered, and determine the previous step of the problem step as the target step; If the number of actual operation steps during the execution of the preset software execution script is less than the number of steps of the target steps, the element value corresponding to the actual operation step to the target step in the first vector is determined as the element value representing the empty operation.
4. The software testing method according to claim 3, wherein: The randomly modifying the initial recurring data using a preset random mutation method to determine modified data includes: generating a first mutation vector based on a preset mutation probability, and modifying the first vector based on the first mutation vector to determine a modified first vector; A second variation vector is generated based on a preset variation vector generation method based on normal distribution, and the second vector is modified based on the second variation vector to determine a modified second vector.
5. The software testing method according to claim 4, characterized in that: The determining of a test sample using the initial recurrence data and the modified data includes: The first vector, the modified first vector and the second vector, the modified second vector are randomly combined to determine a test sample.
6. The software testing method according to any one of claims 2 to 5, characterized in that: Determining the evaluation score of each test sample by using a preset sample evaluation method includes: Determine the number of steps in each sample whose element values in the first vector represent non-empty operations, and determine an evaluation score for each sample based on the probability of each sample reproducing the problem and the number of steps in which the element values in the first vector represent non-empty operations.
7. The software testing method according to claim 1, wherein: Determining the probability of each test sample reproducing the problem includes: The preset software execution script is tested according to a preset number of tests and based on each test sample to determine the probability of each test sample reproducing the problem.
8. A software testing device, characterized in that: include: An initial recurrence data determination module is used to record the time interval between each step and adjacent steps before the problem is discovered during the execution of the preset software execution script, and to determine the initial recurrence data based on the time interval between each step and adjacent steps; A data random mutation module, configured to randomly modify the initial recurring data using a preset random mutation method to determine modified data, and to determine a test sample using the initial recurring data and the modified data; A judgment module is used to determine the probability of recurring the problem for each test sample and to determine whether there is a target test sample among all samples whose probability of recurring the problem is greater than or equal to a preset probability threshold; The sample evaluation and screening module is used to determine the evaluation score of each test sample using a preset sample evaluation method if the probability of the absence of a recurrence problem in all samples is greater than or equal to a preset probability threshold of the target test sample, and use the preset number of samples with the highest evaluation scores as the initial recurrence data, and jump to the step of randomly modifying the initial recurrence data using a preset random mutation method, until the probability of the presence of a recurrence problem in all samples is greater than or equal to the preset probability threshold of the target test sample, so as to determine the recurrence problem using the target test sample.
9. An electronic device, characterized in that: The method comprises a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the software testing method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that Used to store a computer program; wherein, when the computer program is executed by a processor, the software testing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Small probability event reproduction method and device, storage medium and electronic equipment
CN110990842A
Random test method and device based on multi-dimensional vectors and rule scripts
CN111949555A