CN112363928A - Test case processing method and device, processor and electronic device - Google Patents
Test case processing method and device, processor and electronic device Download PDFInfo
- Publication number
- CN112363928A CN112363928A CN202011247876.8A CN202011247876A CN112363928A CN 112363928 A CN112363928 A CN 112363928A CN 202011247876 A CN202011247876 A CN 202011247876A CN 112363928 A CN112363928 A CN 112363928A
- Authority
- CN
- China
- Prior art keywords
- test
- test case
- probability
- cases
- type
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a test case processing method, a test case processing device, a test case processor and an electronic device. The method comprises the following steps: acquiring currently acquired test data, wherein the test data comprises: the test result corresponding to each first test case in the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process; calculating the actual measurement probability of each first test case based on the test data; constructing a second test case, and acquiring the prediction probability of the second test case based on the actual measurement probability; and determining whether to add the second test case into the test data or not by using the comparison result of the predicted probability and the actually measured probability. The invention solves the technical problem that the test case generated by only depending on manual test experience in the related technology needs to consume high labor cost, so that the agile development requirement is difficult to meet.
Description
Technical Field
The invention relates to the field of computers, in particular to a method and a device for processing a test case, a processor and an electronic device.
Background
Currently, in the context of fast iterative, agile development, whether the white-box test is relied upon excessively or the black-box test is relied upon excessively, the test results are adversely affected. Each successful test activity relies on a priori understanding of the object under test and generates test cases based thereon. However, the test case generated by relying solely on the experience of manual testing requires high labor cost, and thus it is difficult to meet the requirement of agile development. When new characteristic iteration is performed, how to design a brand-new and effective test case for testing, and how to select a divergence standard in the existing test case when divergence testing is performed, have become technical problems to be solved urgently.
In developing a debugging program, a debugger can be used to record the executed part of the code of the software to be tested during the software execution process. However, a corresponding solution is lacking for the testing procedure.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
At least some embodiments of the present invention provide a method, an apparatus, a processor, and an electronic apparatus for processing a test case, so as to at least solve the technical problem that a test case generated by simply relying on manual testing experience in related technologies needs to consume high labor cost, and thus is difficult to meet agile development requirements.
According to an embodiment of the present invention, a method for processing a test case is provided, including:
acquiring currently acquired test data, wherein the test data comprises: the test result corresponding to each first test case in the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process; calculating the actual measurement probability of each first test case based on the test data; constructing a second test case, and acquiring the prediction probability of the second test case based on the actual measurement probability; and determining whether to add the second test case into the test data or not by using the comparison result of the predicted probability and the actually measured probability.
Optionally, the method further includes: and carrying out blocking processing on the codes in the software to be tested to obtain a plurality of code blocks.
Optionally, the calculating the measured probability of each first test case based on the test data includes: acquiring a first hit frequency of each code block in a plurality of first test cases; acquiring the occurrence frequency of each code block in a plurality of code blocks in a first test case for detecting each type of vulnerability in at least one type of vulnerability; acquiring the number ratio of a first test case of each type of vulnerability in at least one type of vulnerability relative to a plurality of first test cases; and calculating the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block based on the first hit frequency, the occurrence frequency and the number ratio to obtain the actual measurement probability of each first test case.
Optionally, the obtaining a first hit frequency of each of the plurality of code blocks in the plurality of first test cases includes: acquiring the first hit times of each code block in the plurality of code blocks in a plurality of first test cases; acquiring second hit times of the plurality of code blocks in the plurality of first test cases; and calculating the ratio of the first hit frequency to the second hit frequency to obtain a first hit frequency.
Optionally, the obtaining of the frequency of occurrence of each of the plurality of code blocks in the first test case in which each of the at least one type of bug is detected includes: screening out a first test case for detecting each type of bug from the plurality of first test cases respectively; and counting the occurrence frequency of each code block in the first test case obtained by screening.
Optionally, the obtaining a ratio of the number of the first test cases of each type of vulnerability to the number of the plurality of first test cases includes: acquiring the number of first cases of a first test case of each type of vulnerability in at least one type of vulnerability; acquiring the number of second cases of the plurality of first test cases; and calculating the ratio of the number of the first examples to the number of the second examples to obtain the number ratio.
Optionally, the obtaining the predicted probability of the second test case based on the measured probability includes: acquiring a second hit frequency of each code block in the plurality of code blocks in a second test case; acquiring the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block; and calculating the prediction probability of the second test case to each type of vulnerability based on the second hit frequency and the conditional probability.
Optionally, the determining whether to add the second test case to the test data by using the comparison result of the predicted probability and the measured probability includes: setting a judgment condition based on the number of the current cases of the plurality of first test cases; when the comparison result meets the judgment condition, determining to add the second test case into the test data; and when the comparison result does not meet the judgment condition, performing iterative processing on the second test case until the comparison result meets the judgment condition.
According to an embodiment of the present invention, there is further provided a device for processing a test case, including:
the acquisition module is used for acquiring currently acquired test data, wherein the test data comprises: the test result corresponding to each first test case in the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process; the calculation module is used for calculating and obtaining the actual measurement probability of each first test case based on the test data; the processing module is used for constructing a second test case and acquiring the prediction probability of the second test case based on the actual measurement probability; and the comparison module is used for determining whether to add the second test case into the test data or not by using the comparison result of the prediction probability and the actual measurement probability.
Optionally, the apparatus further comprises: and the dividing module is used for carrying out block processing on the codes in the software to be tested to obtain a plurality of code blocks.
Optionally, the computing module is configured to obtain a first hit frequency of each code block in the plurality of first test cases; acquiring the occurrence frequency of each code block in a plurality of code blocks in a first test case for detecting each type of vulnerability in at least one type of vulnerability; acquiring the number ratio of a first test case of each type of vulnerability in at least one type of vulnerability relative to a plurality of first test cases; and calculating the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block based on the first hit frequency, the occurrence frequency and the number ratio to obtain the actual measurement probability of each first test case.
Optionally, the computing module is configured to obtain a first hit frequency of each code block in the plurality of first test cases; acquiring second hit times of the plurality of code blocks in the plurality of first test cases; and calculating the ratio of the first hit frequency to the second hit frequency to obtain a first hit frequency.
Optionally, the calculation module is configured to screen out the first test cases in which each type of bug is detected from the plurality of first test cases, respectively; and counting the occurrence frequency of each code block in the first test case obtained by screening.
Optionally, the calculation module is configured to obtain a first number of cases of a first test case in which at least one type of bug occurs; acquiring the number of second cases of the plurality of first test cases; and calculating the ratio of the number of the first examples to the number of the second examples to obtain the number ratio.
Optionally, the processing module is configured to obtain a second hit frequency of each code block in the plurality of code blocks in the second test case; acquiring the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block; and calculating the prediction probability of the second test case to each type of vulnerability based on the second hit frequency and the conditional probability.
Optionally, the comparison module is configured to set a determination condition based on the current number of the multiple first test cases; when the comparison result meets the judgment condition, determining to add the second test case into the test data; and when the comparison result does not meet the judgment condition, performing iterative processing on the second test case until the comparison result meets the judgment condition.
According to an embodiment of the present invention, there is further provided a nonvolatile storage medium, in which a computer program is stored, where the computer program is configured to execute the processing method of the test case in any one of the above embodiments when running.
According to an embodiment of the present invention, there is further provided a processor, configured to execute a program, where the program is configured to execute the processing method of the test case in any one of the above embodiments when running.
According to an embodiment of the present invention, there is further provided an electronic apparatus, including a memory and a processor, where the memory stores a computer program, and the processor is configured to execute the computer program to perform the method for processing the test case in any one of the above embodiments.
In at least some embodiments of the present invention, a method for obtaining currently collected test data, where the test data includes a plurality of first test cases and a test result corresponding to each of the plurality of first test cases, the test result includes a code block of software to be tested hit by each of the first test cases during execution and at least one type of bug detected by each of the first test cases during execution, an actual measurement probability of each of the first test cases is obtained through test data calculation, a second test case is constructed, a prediction probability of the second test case is obtained based on the actual measurement probability, and a comparison result between the prediction probability and the actual measurement probability is used to determine whether to add the second test case to the test data, so as to obtain a prediction probability of the new test case for detecting different types of bugs by using the collected test data, whether the new test case can be added into the test data or not is judged so as to achieve the purpose of continuously updating the test case contained in the test data, so that the dependence of the new test case on manual test experience is reduced, the technical effect of continuously updating the test case to ensure the sustainable execution of the test process is achieved when the software iterates new characteristics, and the technical problem that high labor cost is consumed for the test case generated by only depending on the manual test experience in the related technology and the agile development requirement is difficultly met is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a flow diagram of a method for processing test cases according to one embodiment of the invention;
FIG. 2 is a diagram illustrating statistics of mapping relationships between multiple test cases and different types of vulnerabilities according to an alternative embodiment of the present invention;
FIG. 3 is a schematic diagram of predicting the probability of a specific type of vulnerability occurring according to an alternative embodiment of the present invention;
FIG. 4 is a block diagram of a device for processing test cases according to an embodiment of the present invention;
FIG. 5 is a block diagram of a device for processing test cases according to an alternative embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In accordance with one embodiment of the present invention, there is provided an embodiment of a method for processing test cases, where the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer-executable instructions, and where a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than that illustrated or described herein.
The method embodiments may be performed in a mobile terminal, a computer terminal or a similar computing device. Taking the example of the Mobile terminal running on the Mobile terminal, the Mobile terminal may be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet device (MID for short), a PAD, and the like. The mobile terminal may include one or more processors (which may include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a Digital Signal Processing (DSP) chip, a Microprocessor (MCU), a programmable logic device (FPGA), a neural Network Processor (NPU), a Tensor Processor (TPU), an Artificial Intelligence (AI) type processor, etc.) and a memory for storing data. Optionally, the mobile terminal may further include a transmission device, an input/output device, and a display device for a communication function. It will be understood by those skilled in the art that the foregoing structural description is only illustrative and not restrictive of the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than described above, or have a different configuration than described above.
The memory may be configured to store a computer program, for example, a software program and a module of application software, such as a computer program corresponding to the test case processing method in the embodiment of the present invention, and the processor executes various functional applications and data processing by running the computer program stored in the memory, that is, implements the test case processing method described above. The memory may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory may further include memory located remotely from the processor, and these remote memories may be connected to the mobile terminal through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device is used to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
The display device may be, for example, a touch screen type Liquid Crystal Display (LCD) and a touch display (also referred to as a "touch screen" or "touch display screen"). The liquid crystal display may enable a user to interact with a user interface of the mobile terminal. In some embodiments, the mobile terminal has a Graphical User Interface (GUI) with which a user can interact by touching finger contacts and/or gestures on a touch-sensitive surface, where the human-machine interaction function optionally includes the following interactions: executable instructions for creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, emailing, call interfacing, playing digital video, playing digital music, and/or web browsing, etc., for performing the above-described human-computer interaction functions, are configured/stored in one or more processor-executable computer program products or readable storage media.
In this embodiment, a method for processing a test case running on the mobile terminal is provided, and fig. 1 is a flowchart of a method for processing a test case according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S12, acquiring currently acquired test data, where the test data includes: the test result corresponding to each first test case in the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process;
in software engineering, the characteristics of software need to be continuously increased, and the final software application is gradually iterated. For example, a software needs to go through 10 development iterations in the development process, and then the software also needs to go through 10 tests. And the test difficulty is gradually increased along with the increase of the iteration number. Taking the 10 th development iteration test as an example, the test process herein needs to ensure that the 10 th development iteration itself does not have quality problems, and also needs to ensure that after the 10 th development iteration is combined with the previous 9 development iterations, the code of the previous 9 development iterations does not have quality problems. For the 10 th test, the test data is the test data of the first test cases used in the previous 9 tests and the test result corresponding to each of the first test cases (including the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process).
Step S14, calculating the actual measurement probability of each first test case based on the test data;
step S16, constructing a second test case, and acquiring the prediction probability of the second test case based on the actual measurement probability;
in each development iteration process, the existing first test case can be used completely to complete the test process, and part of the test cases can be selected from the test case database and added to complete the test process together.
And step S18, determining whether to add the second test case into the test data by using the comparison result of the prediction probability and the actual measurement probability.
Through the steps, the currently collected test data can be obtained, the test data comprises a plurality of first test cases and a test result corresponding to each first test case in the plurality of first test cases, the test result comprises a code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process, the actual measurement probability of each first test case is obtained through test data calculation, the second test case is constructed, the prediction probability of the second test case is obtained based on the actual measurement probability, and the comparison result of the prediction probability and the actual measurement probability is used for determining whether to add the second test case into the test data, so that the prediction probability of the new test case for detecting different types of bugs is obtained by using the collected test data, and whether the new test case can be added into the test data is judged, the method and the device have the advantages that the purpose of continuously updating the test cases contained in the test data is facilitated, so that the dependence of generating new test cases on manual test experience is reduced, the technical effect that the test process can be continuously carried out is ensured through the continuous updating of the test cases when software iterates new characteristics, and the technical problem that high labor cost is consumed for the test cases generated by only depending on the manual test experience in the related technology, and the agile development requirement is difficultly met is solved.
Optionally, the method may further include the following steps:
and step S10, performing blocking processing on the codes in the software to be tested to obtain a plurality of code blocks.
In an alternative embodiment, the code in the software under test may be partitioned. For example: and carrying out blocking processing according to the function level of the submodule of the software to be tested. Specifically, the software A to be tested is subjected to blocking processing according to the function level of the sub-modules of the software to be tested to obtain a code block A1, a code block A2, a code block A3 and a code block A4 … …. In the process of executing a plurality of test cases in the software test, the hit conditions of the plurality of test cases on each code block can be recorded in real time. For example: the hit code block a1 totals 10 times, the hit code block a2 totals 0 times, the hit code block A3 totals 2 times … …, and so on, thereby counting hits of each of the plurality of test cases on the respective code blocks.
Optionally, in step S14, the calculating the measured probability of each first test case based on the test data may include the following steps:
step S141, acquiring a first hit frequency of each code block in a plurality of first test cases;
step S142, obtaining the occurrence frequency of each code block in the plurality of code blocks in a first test case for detecting each type of bug in at least one type of bug;
step S143, obtaining the number ratio of the first test case of each type of bug in at least one type of bug relative to a plurality of first test cases;
step S144, based on the first hit frequency, the occurrence frequency and the number ratio, calculating the conditional probability of each type of bug occurring under the condition that each code block is hit by each first test case, and obtaining the actual measurement probability of each first test case.
In the process of calculating the actual measurement probability of each first test case based on the test data, first, the first hit frequency of each code block in the plurality of code blocks in the plurality of first test cases can be obtained; secondly, the occurrence frequency of each code block in the plurality of code blocks in a first test case for detecting each type of vulnerability in at least one type of vulnerability can be obtained; then, the number ratio of the first test case of each type of vulnerability in at least one type of vulnerability can be obtained relative to the number of the plurality of first test cases; and finally, calculating the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block based on the first hit frequency, the occurrence frequency and the number ratio to obtain the actual measurement probability of each first test case.
Optionally, in step S141, obtaining a first hit frequency of each of the plurality of code blocks in the plurality of first test cases may include the following steps:
step 1411, acquiring a first hit frequency of each code block in a plurality of first test cases;
step 1412, acquiring second hit times of the plurality of code blocks in the plurality of first test cases;
in step S1413, a ratio of the first hit frequency to the second hit frequency is calculated to obtain a first hit frequency.
And counting the first hit frequency of each code block Ai in a plurality of test cases, and recording as P (Ai). Firstly, acquiring the first hit times of each code block in a plurality of first test cases; secondly, acquiring second hit times (namely the total times of hitting each code block by all the test cases) of the plurality of code blocks in the plurality of first test cases; then, the ratio of the first hit frequency to the second hit frequency is calculated to obtain the first hit frequency.
Assume that there are currently 2 test cases, which are test case 1 and test case 2, respectively, and there are currently 3 code blocks, which are code block a1, code block a2, and code block A3, respectively. Test case 1 hit code block a1 for a total of 2 times, hit code block a2 for a total of 0 times and hit code block A3 for a total of 1 time; and the test case 2 hits the code block a 11 time in total, hits the code block a 22 times in total and hits the code block A3 3 times in total, whereby the first hit frequency of each code block Ai in a plurality of test cases can be counted:
P(A1)=(2+1)/(2+1+1+2+3)=3/9;
P(A2)=2/(2+1+1+2+3)=2/9;
P(A3)=(1+3)/(2+1+1+2+3)=4/9。
optionally, in step S142, obtaining the frequency of occurrence of each of the plurality of code blocks in the first test case in which each of the at least one type of bug is detected may include the following steps:
step S1421, screening out the first test cases with each type of bug detected from the plurality of first test cases respectively;
step S1422, counting the occurrence frequency of each code block in the first test case obtained by screening.
After detecting a vulnerability (bug), the bug needs to be classified, for example: a logical type bug, a render type bug, a User Interface (UI) element type bug, and the like. Fig. 2 is a schematic diagram of statistics of mapping relationships between multiple test cases and different types of vulnerabilities according to an optional embodiment of the present invention, and as shown in fig. 2, a logic vulnerability may include: character deduction errors, gold coin calculation errors, etc., rendering vulnerabilities may include: character border errors, article material errors, and the like. The method comprises the steps of detecting a character blood-deducting error through a test case 1, detecting an article material error through a test case 2, detecting a gold coin calculation error through a test case 3, and detecting a character frame error and an article material error through a test case 5, so that the bug types (marked as bug X, bug Y and bug Z … …) generated in a plurality of test cases can be counted, and mapping relations between different bug types and a plurality of test cases can be established. Then, screening out the test cases with the bugX from the plurality of test cases, and counting the occurrence frequency of the code blocks Ai in at least one test case with the bugX detected, wherein the occurrence frequency is marked as P (Ai | X); screening out the test cases in which the bugY occurs from the plurality of test cases, and counting the occurrence frequency of the code blocks Ai in at least one test case in which the bugY is detected, wherein the occurrence frequency is marked as P (Ai | Y); and screening out the test cases in which the bugZ occurs from the plurality of test cases, thereby counting the occurrence frequency of the code blocks Ai in at least one test case in which the bugZ is detected, and marking the occurrence frequency as P (Ai | Z) … and the like until the occurrence frequency of each code block in the first test case obtained by screening is completely counted.
Optionally, in step S143, obtaining a ratio of the number of the first test cases to the number of the plurality of first test cases for each of at least one type of bug may include the following steps:
step S1431, acquiring the number of first cases of the first test case of each type of vulnerability in at least one type of vulnerability;
step S1432, acquiring the number of second cases of the plurality of first test cases;
step S1433, a ratio of the number of the first instances to the number of the second instances is calculated to obtain a number ratio.
In order to obtain the number ratio of the first test case of each type of vulnerability in at least one type of vulnerability relative to the plurality of first test cases, firstly, the number of the first test cases of each type of vulnerability in at least one type of vulnerability can be obtained; secondly, the number of second cases of a plurality of first test cases can be obtained; then, the ratio of the number of the first instances to the number of the second instances is calculated to obtain the number ratio.
In an alternative embodiment, the ratio of at least one test case in which bugX occurs to a plurality of test cases may be denoted as P (X), the ratio of at least one test case in which bugY occurs to a plurality of test cases may be denoted as P (Y), the ratio of at least one test case in which bugZ occurs to a plurality of test cases may be denoted as P (Z) …, and so on. Finally, a conditional probability P (X | Ai) ═ P (Ai | X) × P (X)/P (Ai) that bugX occurs under the condition that a plurality of test cases hit the Ai code block is calculated according to bayesian theorem. Similarly, conditional probabilities P (Y | Ai) and P (Z | Ai) of the occurrence of bugs of other types such as bugY and bugZ when hitting other code blocks Ai can be calculated. The conditional probability obtained through the calculation not only can provide conditions for the subsequent calculation of the bug prediction probability of the test case, but also can improve the processing speed of the subsequent real-time settlement probability through the pre-calculation mode.
Optionally, in step S16, the obtaining the predicted probability of the second test case based on the measured probability may include the following steps:
step S161, obtaining a second hit frequency of each code block in the plurality of code blocks in the second test case;
step S162, obtaining the conditional probability of each type of bug occurring under the condition that each code block is hit by each first test case;
and step S163, calculating to obtain the prediction probability of the second test case for each type of vulnerability based on the second hit frequency and the conditional probability.
After constructing a new second test case, first, a second hit frequency of each code block in the plurality of code blocks in the second test case may be obtained; secondly, the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block can be obtained; and then, calculating to obtain the prediction probability of the second test case to each type of vulnerability based on the second hit frequency and the conditional probability.
Fig. 3 is a schematic diagram of predicting the probability of occurrence of a bug of a specific type according to An alternative embodiment of the present invention, and as shown in fig. 3, the probability that the second test case (i.e., the temporary test case) hits each of the code blocks a1 and a2 … … An may be obtained in real time, and the probability of occurrence of a bug of a specific type is determined according to the conditional probability obtained by the above calculation. For example: for a new test case, the predicted probability of bugX occurrence can be calculated as P (a1) × P (X | a1) + P (a2) × P (X | a2) + … … + P (An) × P (X | An) according to the frequency of Ai appearing in the test case. Similarly, the prediction probability of bugs of other types such as bugY and bugZ can be calculated.
Optionally, in step S18, determining whether to add the second test case to the test data using the comparison result between the predicted probability and the measured probability may include the following steps:
step S181, setting a judgment condition based on the current number of cases of the plurality of first test cases;
step S182, when the comparison result meets the judgment condition, determining to add a second test case into the test data;
and step S183, when the comparison result does not meet the judgment condition, performing iterative processing on the second test case until the comparison result meets the judgment condition.
In the process of determining whether to add a second test case into the test data by using the comparison result of the prediction probability and the actual measurement probability, firstly, setting a judgment condition based on the number of the current cases of a plurality of first test cases; then, when the comparison result meets the judgment condition, determining to add a second test case into the test data; and when the comparison result does not meet the judgment condition, performing iterative processing on the second test case until the comparison result meets the judgment condition.
Specifically, when the number of first test cases existing in the test case database is large, in order to prevent redundancy of the test cases, the following determination conditions may be set: and if the second test case finds that the prediction probability of all bug types is higher than the actual measurement probability of the existing first test case, the second test case can be subjected to warehousing operation. If the second test case finds that the prediction probability of part of the bug types is lower than the actual measurement probability of the existing first test case, the second test case needs to be subjected to iteration operation to improve the prediction occurrence probability, and the warehousing operation can be performed on the second test case until the prediction probabilities of all the bug types are higher than the actual measurement probability of the existing first test case. During the iterative operation of the second test case, the partial operation executed by the second test case may be modified. For example: the second test case originally comprises an operation a, an operation b and an operation c, and comprises the operation a, the operation b, the operation d and the operation e after modification, so that the prediction probability of the second test case is improved until the prediction probabilities of all bug types are higher than the actual measurement probability of the existing first test case.
Therefore, when a new second test case is detected, the prediction probability of a bug of a specific type can be obtained for judging the prediction value of the second test case, and a foundation is laid for the simplification and the effectiveness of the test cases in a subsequent test case database.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
In this embodiment, a device for processing a test case is further provided, where the device is used to implement the foregoing embodiments and preferred embodiments, and details of the description already made are omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 4 is a block diagram of a device for processing a test case according to an embodiment of the present invention, and as shown in fig. 4, the device includes: an obtaining module 10, configured to obtain currently acquired test data, where the test data includes: the test result corresponding to each first test case in the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process; the calculation module 20 is configured to calculate an actual measurement probability of each first test case based on the test data; the processing module 30 is configured to construct a second test case, and obtain a prediction probability of the second test case based on the actual measurement probability; and the comparison module 40 is configured to determine whether to add the second test case to the test data according to a comparison result between the predicted probability and the actual measurement probability.
Optionally, fig. 5 is a block diagram of a device for processing a test case according to an alternative embodiment of the present invention, and as shown in fig. 5, the device includes, in addition to all modules shown in fig. 4: and the dividing module 50 is used for performing block processing on the codes in the software to be tested to obtain a plurality of code blocks.
Optionally, the calculating module 20 is configured to obtain a first hit frequency of each code block in the plurality of first test cases; acquiring the occurrence frequency of each code block in a plurality of code blocks in a first test case for detecting each type of vulnerability in at least one type of vulnerability; acquiring the number ratio of a first test case of each type of vulnerability in at least one type of vulnerability relative to a plurality of first test cases; and calculating the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block based on the first hit frequency, the occurrence frequency and the number ratio to obtain the actual measurement probability of each first test case.
Optionally, the calculating module 20 is configured to obtain a first hit number of each code block in the plurality of first test cases; acquiring second hit times of the plurality of code blocks in the plurality of first test cases; and calculating the ratio of the first hit frequency to the second hit frequency to obtain a first hit frequency.
Optionally, the computing module 20 is configured to respectively screen out the first test cases in which each type of bug is detected from the plurality of first test cases; and counting the occurrence frequency of each code block in the first test case obtained by screening.
Optionally, the calculation module 20 is configured to obtain a first number of first test cases of each type of vulnerability in at least one type of vulnerability; acquiring the number of second cases of the plurality of first test cases; and calculating the ratio of the number of the first examples to the number of the second examples to obtain the number ratio.
Optionally, the processing module 30 is configured to obtain a second hit frequency of each code block in the plurality of code blocks in the second test case; acquiring the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block; and calculating the prediction probability of the second test case to each type of vulnerability based on the second hit frequency and the conditional probability.
Optionally, the comparing module 40 is configured to set a determination condition based on the current number of the multiple first test cases; when the comparison result meets the judgment condition, determining to add the second test case into the test data; and when the comparison result does not meet the judgment condition, performing iterative processing on the second test case until the comparison result meets the judgment condition.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Embodiments of the present invention also provide a non-volatile storage medium having a computer program stored therein, wherein the computer program is configured to perform the steps of any of the above method embodiments when executed.
Alternatively, in the present embodiment, the above-mentioned nonvolatile storage medium may be configured to store a computer program for executing the steps of:
s1, acquiring currently acquired test data, wherein the test data includes: the test result corresponding to each first test case in the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process;
s2, calculating the actual measurement probability of each first test case based on the test data;
s3, constructing a second test case, and acquiring the prediction probability of the second test case based on the actual measurement probability;
and S4, determining whether to add the second test case into the test data by using the comparison result of the predicted probability and the actually measured probability.
Optionally, in this embodiment, the nonvolatile storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, acquiring currently acquired test data, wherein the test data includes: the test result corresponding to each first test case in the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process;
s2, calculating the actual measurement probability of each first test case based on the test data;
s3, constructing a second test case, and acquiring the prediction probability of the second test case based on the actual measurement probability;
and S4, determining whether to add the second test case into the test data by using the comparison result of the predicted probability and the actually measured probability.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.
Claims (12)
1. A method for processing a test case is characterized by comprising the following steps:
acquiring currently acquired test data, wherein the test data comprises: the test result corresponding to each of the plurality of first test cases and the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process;
calculating actual measurement probability of each first test case based on the test data;
constructing a second test case, and acquiring the prediction probability of the second test case based on the actual measurement probability;
and determining whether to add the second test case into the test data or not by using a comparison result of the predicted probability and the actually measured probability.
2. The processing method according to claim 1, characterized in that the method further comprises:
and carrying out blocking processing on the codes in the software to be tested to obtain a plurality of code blocks.
3. The processing method according to claim 1 or 2, wherein calculating the measured probability for each first test case based on the test data comprises:
acquiring a first hit frequency of each code block in a plurality of code blocks in the plurality of first test cases;
acquiring the occurrence frequency of each code block in the plurality of code blocks in a first test case for detecting each type of vulnerability in the at least one type of vulnerability;
acquiring the number ratio of the first test case of each type of vulnerability in the at least one type of vulnerability relative to the plurality of first test cases;
and calculating the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block based on the first hit frequency, the occurrence frequency and the number ratio to obtain the actual measurement probability of each first test case.
4. The processing method according to claim 3, wherein obtaining the first hit frequency of each of the plurality of code blocks in the plurality of first test cases comprises:
acquiring the first hit times of each code block in the plurality of first test cases;
acquiring second hit times of the plurality of code blocks in the plurality of first test cases;
and calculating the ratio of the first hit frequency to the second hit frequency to obtain the first hit frequency.
5. The processing method according to claim 3, wherein obtaining the frequency of occurrence of each of the plurality of code blocks in a first test case in which each of the at least one type of vulnerability is detected comprises:
screening out a first test case for detecting each type of bug from the plurality of first test cases respectively;
and counting the occurrence frequency of each code block in the first test case obtained by screening.
6. The processing method according to claim 3, wherein obtaining the ratio of the number of first test cases in which each of the at least one type of vulnerability occurs to the number of the plurality of first test cases comprises:
acquiring the number of first cases of first test cases of each type of vulnerability in the at least one type of vulnerability;
acquiring the number of second cases of the plurality of first test cases;
and calculating the ratio of the number of the first instances to the number of the second instances to obtain the number ratio.
7. The processing method of claim 1, wherein obtaining the predicted probability of the second test case based on the measured probability comprises:
acquiring a second hit frequency of each code block in the plurality of code blocks in the second test case;
acquiring the conditional probability of each type of vulnerability of each first test case under the condition of hitting each code block;
and calculating the prediction probability of the second test case for each type of vulnerability based on the second hit frequency and the conditional probability.
8. The processing method of claim 1, wherein determining whether to add the second test case to the test data using the comparison of the predicted probability and the measured probability comprises:
setting a judgment condition based on the number of the current cases of the plurality of first test cases;
when the comparison result meets the judgment condition, determining to add the second test case into the test data; and when the comparison result does not meet the judgment condition, performing iterative processing on the second test case until the comparison result meets the judgment condition.
9. An apparatus for processing a test case, comprising:
an obtaining module, configured to obtain currently acquired test data, where the test data includes: the test result corresponding to each of the plurality of first test cases and the plurality of first test cases comprises: the code block of the software to be tested hit by each first test case in the execution process and at least one type of bug detected by each first test case in the execution process;
the calculation module is used for calculating and obtaining the actual measurement probability of each first test case based on the test data;
the processing module is used for constructing a second test case and acquiring the prediction probability of the second test case based on the actual measurement probability;
and the comparison module is used for determining whether to add the second test case into the test data or not by using the comparison result of the prediction probability and the actual measurement probability.
10. A non-volatile storage medium, wherein a computer program is stored in the storage medium, and wherein the computer program is configured to execute the method for processing a test case according to any one of claims 1 to 8 when running.
11. A processor, configured to execute a program, wherein the program is configured to execute the method for processing the test case according to any one of claims 1 to 8 when executed.
12. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to perform the method for processing the test case according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011247876.8A CN112363928B (en) | 2020-11-10 | 2020-11-10 | Processing method and device of test case, processor and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011247876.8A CN112363928B (en) | 2020-11-10 | 2020-11-10 | Processing method and device of test case, processor and electronic device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112363928A true CN112363928A (en) | 2021-02-12 |
CN112363928B CN112363928B (en) | 2023-08-22 |
Family
ID=74508671
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011247876.8A Active CN112363928B (en) | 2020-11-10 | 2020-11-10 | Processing method and device of test case, processor and electronic device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112363928B (en) |
Citations (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103208039A (en) * | 2012-01-13 | 2013-07-17 | 株式会社日立制作所 | Method and device for evaluating software project risks |
US20140033174A1 (en) * | 2012-07-29 | 2014-01-30 | International Business Machines Corporation | Software bug predicting |
CN105243014A (en) * | 2015-09-18 | 2016-01-13 | 北京金山安全软件有限公司 | Method and device for testing application program |
CN106021115A (en) * | 2016-06-06 | 2016-10-12 | 重庆大学 | Non-supervision defect prediction method based on probabilities |
JP2017224185A (en) * | 2016-06-16 | 2017-12-21 | 日本電信電話株式会社 | Bug contamination probability calculation program and bug contamination probability calculation method |
CN108268373A (en) * | 2017-09-21 | 2018-07-10 | 平安科技(深圳)有限公司 | Automatic test cases management method, device, equipment and storage medium |
US20180285186A1 (en) * | 2017-03-31 | 2018-10-04 | Microsoft Technology Licensing, Llc | Machine learning for input fuzzing |
CN109062794A (en) * | 2018-07-24 | 2018-12-21 | 北京奇艺世纪科技有限公司 | A kind of the determination method, apparatus and electronic equipment of software evaluating result |
US20190146755A1 (en) * | 2017-11-15 | 2019-05-16 | Accenture Global Solutions Limited | Test case and data selection using a sampling methodology |
US20190243743A1 (en) * | 2018-02-07 | 2019-08-08 | Apple Inc. | Unsupervised anomaly detection |
CN110297764A (en) * | 2019-05-30 | 2019-10-01 | 北京百度网讯科技有限公司 | Loophole test model training method and device |
CN110826071A (en) * | 2019-09-24 | 2020-02-21 | 平安科技(深圳)有限公司 | Software vulnerability risk prediction method, device, equipment and storage medium |
CN111274126A (en) * | 2020-01-14 | 2020-06-12 | 华为技术有限公司 | Test case screening method, device and medium |
WO2020151344A1 (en) * | 2019-01-22 | 2020-07-30 | 平安科技(深圳)有限公司 | Software development and testing method for sub-iterations and related devices |
-
2020
- 2020-11-10 CN CN202011247876.8A patent/CN112363928B/en active Active
Patent Citations (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103208039A (en) * | 2012-01-13 | 2013-07-17 | 株式会社日立制作所 | Method and device for evaluating software project risks |
US20140033174A1 (en) * | 2012-07-29 | 2014-01-30 | International Business Machines Corporation | Software bug predicting |
CN105243014A (en) * | 2015-09-18 | 2016-01-13 | 北京金山安全软件有限公司 | Method and device for testing application program |
CN106021115A (en) * | 2016-06-06 | 2016-10-12 | 重庆大学 | Non-supervision defect prediction method based on probabilities |
JP2017224185A (en) * | 2016-06-16 | 2017-12-21 | 日本電信電話株式会社 | Bug contamination probability calculation program and bug contamination probability calculation method |
US20180285186A1 (en) * | 2017-03-31 | 2018-10-04 | Microsoft Technology Licensing, Llc | Machine learning for input fuzzing |
CN108268373A (en) * | 2017-09-21 | 2018-07-10 | 平安科技(深圳)有限公司 | Automatic test cases management method, device, equipment and storage medium |
US20190146755A1 (en) * | 2017-11-15 | 2019-05-16 | Accenture Global Solutions Limited | Test case and data selection using a sampling methodology |
US20190243743A1 (en) * | 2018-02-07 | 2019-08-08 | Apple Inc. | Unsupervised anomaly detection |
CN109062794A (en) * | 2018-07-24 | 2018-12-21 | 北京奇艺世纪科技有限公司 | A kind of the determination method, apparatus and electronic equipment of software evaluating result |
WO2020151344A1 (en) * | 2019-01-22 | 2020-07-30 | 平安科技(深圳)有限公司 | Software development and testing method for sub-iterations and related devices |
CN110297764A (en) * | 2019-05-30 | 2019-10-01 | 北京百度网讯科技有限公司 | Loophole test model training method and device |
CN110826071A (en) * | 2019-09-24 | 2020-02-21 | 平安科技(深圳)有限公司 | Software vulnerability risk prediction method, device, equipment and storage medium |
CN111274126A (en) * | 2020-01-14 | 2020-06-12 | 华为技术有限公司 | Test case screening method, device and medium |
Also Published As
Publication number | Publication date |
---|---|
CN112363928B (en) | 2023-08-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI688917B (en) | Risk identification model construction and risk identification method, device and equipment | |
EP3874372B1 (en) | Automatically performing and evaluating pilot testing of software | |
Liang et al. | Caiipa: Automated large-scale mobile app testing through contextual fuzzing | |
Oliner et al. | Carat: Collaborative energy diagnosis for mobile devices | |
CN109062809B (en) | Online test case generation method and device and electronic equipment | |
US9703681B2 (en) | Performance optimization tip presentation during debugging | |
TW201939379A (en) | Information conversion rate prediction method and apparatus, and information recommendation method and apparatus | |
US20160070633A1 (en) | Memory leak analysis by usage trends correlation | |
WO2019019628A1 (en) | Test method, apparatus, test device and medium for mobile application | |
Oliner et al. | Collaborative energy debugging for mobile devices | |
CN107402855A (en) | A kind of detection method of hard disk, device and server | |
CN103984626A (en) | Method and device for generating test-case script | |
CN111639470B (en) | Simulation test method and system for processor cooperative chip and related components | |
CN111078579A (en) | Monkey testing method and device and terminal equipment | |
CN113268243A (en) | Memory prediction method and device, storage medium and electronic equipment | |
CN114676040A (en) | Test coverage verification method and device and storage medium | |
CN108920353A (en) | A kind of test method, device and electronic equipment | |
CN110825303A (en) | Interaction method, device, terminal and computer readable medium | |
US20240086310A1 (en) | What-if analysis for notebooks | |
CN109086198A (en) | Test method, device and the storage medium of database | |
CN112363928B (en) | Processing method and device of test case, processor and electronic device | |
CN106034150B (en) | Application program dynamic pushing method, device and system | |
CN111949510A (en) | Test processing method and device, electronic equipment and readable storage medium | |
CN108984386A (en) | Test method, device and the storage medium of application program search | |
CN107168776A (en) | Event statistical method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |