A test case generation method, system, device and storage medium

By using the test case generation method in the conditional combination scenario, the conditional combination matrix is ​​formed and the probability testing optimization is optimized, the problems of low efficiency and low quality of test case design in the prior art are solved, and more efficient test execution and lower design costs are achieved.

CN113886224BActive Publication Date: 2025-02-25XIAMEN LEELEN TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111105240.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-22
Publication Date
2025-02-25
Estimated Expiration
2041-09-22

AI Technical Summary

Technical Problem

The design methods and methods of test cases in existing conditional combination scenarios are inefficient or low in usage, resulting in low design efficiency and degradation of quality.

Method used

Through a test case generation method, it includes listing preset conditions according to the condition combination scenario, forming a condition combination matrix, selecting the condition combination terms on the diagonal line as a primary probability test case, and gradually optimizing through the secondary probability test case until there are no defects.

Benefits of technology

On the premise of ensuring the same quality level, the number of test cases is reduced, the test execution efficiency is improved, the design difficulty and cost are reduced, and the threshold for use is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113886224B_ABST
    Figure CN113886224B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention disclose a test case generation method, system, device and storage medium. The method uses a secondary probability method, that is, partial probabilities are calculated before testing an object under test, and the remaining partial probabilities are calculated based on the test situation when the object under test is tested. Since the secondary probability is calculated based on the premise of partial inevitable events, its probability range, that is, the probability denominator, is smaller, and the number of samples required to achieve the same expected goal is smaller, that is, the number of test cases is smaller, thereby ensuring the same quality level. Under the premise of obtaining a higher test execution efficiency, the design method adopts a primary probability fixed method and a secondary probability fixed method, and does not require any complex function calculations or logic designs, thereby greatly reducing its design difficulty and design cost, and lowering the threshold for use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of test case design, and in particular to a test case generation method, system, device and storage medium. Background Art

[0002] The design of scenario test cases for conditional combination testing generally requires the combination of orthogonal experimental design method, cause-and-effect diagram method and other methods in addition to the commonly used equivalence class division, boundary value and error inference method.

[0003] The orthogonal test design method, cause-and-effect diagram method and other methods needed in the design of scenario test cases for conditional combination tests are difficult to use and have low design efficiency, resulting in low utilization rate. For example, the application publication number is CN109902002A, and the invention name is a method and device for generating combined test cases, a storage medium, and a computer device. Similar to these methods, a large amount of business analysis and logic design are required. When encountering a system with complex business and tens of thousands of combined conditions, the disadvantages of difficulty in use and low design efficiency are more prominent. Therefore, some people even prefer to adopt the method of exhaustive testing. Exhaustive testing is to test all possibilities one by one, which is a practice abandoned by test theory. Although the design method of exhaustive testing is very simple, the workload of test execution is very huge. For example, the application publication number is CN112328493A, and the invention name is a matrix test case generation method, system, electronic device and storage medium. The method adopted is to exhaust all condition combinations, which leads to the low efficiency and quality of test case design of conditional combination test scenarios. Summary of the invention

[0004] To this end, embodiments of the present invention provide a test case generation method, system, device and storage medium to solve the problem that the current test case design mode and method in conditional combination scenarios are inefficient or have low utilization rate.

[0005] In order to achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0006] According to a first aspect of an embodiment of the present invention, a test case generation method is provided, the method comprising:

[0007] Step 1: List the preset conditions according to the condition combination scenario;

[0008] Step 2: Combine the preset conditions in pairs, select several condition combination items, and form a first condition combination item;

[0009] Step 3: Generate and execute a probabilistic test case;

[0010] Step 4: Determine whether there is a defect in the execution of a probability test case. If there is no defect, directly execute step 7. If there is a defect, mark the corresponding condition combination item as an exception;

[0011] Step 5: Generate and execute secondary probability test cases based on the current anomaly marker;

[0012] Step 6: Determine whether there are defects in the execution of the secondary probability test case; if there are defects, mark the corresponding condition combination item as an exception, and re-execute step 5 until all current secondary probability test cases are executed without defects;

[0013] Step 7: Obtain the final test case, which includes: all the generated primary probability test cases and all the secondary probability test cases.

[0014] Further, a first condition combination item is formed, including:

[0015] In the same order, arrange all conditions from left to right and from top to bottom to form matrix rows and matrix columns respectively, and generate a condition combination matrix;

[0016] From the condition combination matrix, take the condition combination items on the diagonal from the lower left corner to the upper right corner as the first condition combination items;

[0017] The unselected conditional combination items form the second conditional combination item.

[0018] Preferably, the method further comprises:

[0019] For each first condition combination item, determine whether there is an invalid combination item;

[0020] If there is a first condition combination item that is an invalid combination item, a third condition combination item and a fourth condition combination item are respectively selected from the second condition combination item to replace, and the invalid combination item is fine-tuned;

[0021] The fifth conditional combination item is formed by using the replaced first conditional combination item.

[0022] Further, a third condition combination item is selected from the second condition combination items, including:

[0023] In the condition combination matrix, take the condition combination items one grid above and one grid below the corresponding position of each invalid combination item to form a third condition combination item;

[0024] Determine whether there is at least one valid combination of the third conditional combination items;

[0025] If all the third conditional combination items are invalid combination items, take the conditional combination items two squares above and two squares below the corresponding position of each invalid combination item, and update the third conditional combination item, and so on, until there is at least one valid combination item in the third conditional combination item;

[0026] If no valid combination item can be obtained after exhaustion, then the acquisition of valid combination items from the third condition combination item is stopped.

[0027] Preferably, a fourth condition combination item is selected from the second condition combination items, comprising:

[0028] In the condition combination matrix, take the condition combination item one grid to the left and right of the corresponding position of each invalid combination item to form a fourth condition combination item;

[0029] Determine whether there is at least one valid combination of the fourth conditional combination items;

[0030] If all the fourth conditional combination items are invalid combination items, take the conditional combination items two squares above and two squares below the corresponding position of each invalid combination item, and update the fourth conditional combination item, and so on, until there is at least one valid combination item among the fourth conditional combination items;

[0031] If no valid combination item can be obtained after all the items are exhausted, the process stops obtaining valid combination items from the fourth condition combination item.

[0032] Furthermore, according to the current abnormal mark, a secondary probability test case is generated and executed, including:

[0033] For each condition combination item currently marked as abnormal, all condition combination items having any condition of the condition combination item are obtained as the sixth condition combination item;

[0034] Eliminate the condition combination item that has previously generated the secondary probability test case from the sixth condition combination item to obtain a seventh condition combination item;

[0035] Using the seventh condition combination item, a secondary probability test case is generated and executed.

[0036] According to a second aspect of an embodiment of the present invention, a test case generation system is provided, the system comprising:

[0037] A condition generation module is used to list preset conditions according to condition combination scenarios;

[0038] A first condition combination item generating module, used for combining the preset conditions in pairs, selecting a number of condition combination items, and forming a first condition combination item;

[0039] A probability test case generation and execution module, used to generate and execute a probability test case;

[0040] A probabilistic test case execution detection module is used to determine whether there is a defect in the execution of a probabilistic test case; if there is no defect, the final test case is obtained; if there is a defect, the corresponding condition combination item is marked as abnormal;

[0041] A secondary probability test case generation and execution module is used to generate and execute secondary probability test cases according to the current anomaly mark;

[0042] The secondary probability test case execution detection module is used to determine whether there are defects in the execution of secondary probability test cases; if there are defects, the corresponding condition combination items are marked as abnormal, and the secondary probability test cases are regenerated and executed according to the current abnormal mark, until all current secondary probability test cases are executed without defects;

[0043] The final test case generation module is used to obtain the final test case.

[0044] Preferably, the system further comprises: a condition combination item fine-tuning module, configured to perform the following steps:

[0045] For each first condition combination item, determine whether there is an invalid combination item;

[0046] If there is a first condition combination item that is an invalid combination item, a third condition combination item and a fourth condition combination item are respectively selected from the second condition combination item to replace, and the invalid combination item is fine-tuned;

[0047] The fifth conditional combination item is formed by using the replaced first conditional combination item.

[0048] According to a third aspect of an embodiment of the present invention, a test case generation device is provided, the device comprising: a processor and a memory;

[0049] The memory is used to store one or more program instructions;

[0050] The processor is used to run one or more program instructions to execute the steps of a test case generation method as described in any one of the above items.

[0051] According to a fourth aspect of an embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of a test case generation method as described in any one of the above items are implemented.

[0052] The embodiments of the present invention have the following advantages:

[0053] The embodiment of the present invention adopts a quadratic probability method, that is, partial probabilities are calculated before testing the object under test, and the remaining partial probabilities are calculated based on the test conditions when testing the object under test. Since the quadratic probability is calculated based on the premise of partial inevitable events, its probability range, that is, the probability denominator, is smaller, and the number of samples required to achieve the same expected goal is smaller, that is, the number of test cases is smaller, thereby ensuring the same quality level. Under the premise of obtaining a higher test execution efficiency, the design method adopts a primary probability fixed method and a secondary probability fixed method, without the need for any complex function calculations or logic design, thereby greatly reducing its design difficulty and design cost, and lowering the threshold for use. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.

[0055] The structures, proportions, sizes, etc. illustrated in this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with the technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantial technical significance. Any structural modification, change in proportion or adjustment of size shall still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.

[0056] Figure 1 A schematic diagram of the logical architecture of a test case generation system provided by one embodiment of the present invention;

[0057] Figure 2 A schematic diagram of the logical architecture of a test case generation system provided by another embodiment of the present invention;

[0058] Figure 3 A flow chart of a test case generation method provided by one embodiment of the present invention;

[0059] Figure 4 A flow chart of a test case generation method provided by another embodiment of the present invention;

[0060] Figure 5 A schematic diagram of determining that a first condition combination item is an invalid combination item and fine-tuning the invalid combination item provided by an embodiment of the present invention, wherein the gray bottom portion is divided into all the third condition combination items that are finally determined. DETAILED DESCRIPTION

[0061] The following is a description of the implementation of the present invention by specific embodiments. People familiar with the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.

[0062] In today's testing field, where the general design methods and theories of test cases are basically mature, there are still some special scenarios where the use case design methods and approaches are inefficient or have low usage rates, among which the testing of conditional combination scenarios is particularly prominent.

[0063] The principles of traditional test case design methods are all based on probability, that is, if the coverage of the object under test reaches a certain level and the probability of quality defects is kept within a sufficiently small range, then the coverage is sufficient and can meet the quality requirements of the object under test. The probabilities considered in traditional test case design methods are basically one-time probabilities, that is, all probabilities are calculated before the object under test is tested.

[0064] In order to overcome the above technical problems, firstly, the functional entities involved in the embodiments of the present invention are introduced as follows, these functional entities can be physical functional entities or logical functional entities, a single functional entity can be used as an independent device, or multiple functional entities can be used as a unified device. This technical solution does not limit this.

[0065] refer to Figure 1 A test case generation system disclosed in an embodiment of the present invention includes: a condition generation module 1, a first condition combination item generation module 2, a primary probability test case generation and execution module 3, a primary probability test case execution detection module 4, a secondary probability test case generation and execution module 5, a secondary probability test case execution detection module 6, and a final test case generation module 7.

[0066] Among them, the condition generation module 1 is used to list the preset conditions according to the condition combination scenario; the first condition combination item generation module 2 is used to combine the preset conditions in pairs, select several condition combination items, and form a first condition combination item; the primary probability test case generation and execution module 3 is used to generate and execute the primary probability test case; the primary probability test case execution detection module 4 is used to determine whether there is a defect in the execution of the primary probability test case; if there is no defect, the final test case is obtained, and if there is a defect, the corresponding condition combination item is marked as abnormal; the secondary probability test case generation and execution module 5 is used to generate and execute the secondary probability test case according to the current abnormal mark; the secondary probability test case execution detection module 6 is used to determine whether there is a defect in the execution of the secondary probability test case; if there is a defect, the corresponding condition combination item is marked as abnormal and reused to execute step five: generate and execute the secondary probability test case according to the current abnormal mark until all current secondary probability test cases are executed without defects; the final test case generation module 7 is used to obtain the final test case, and the final test case includes: all the generated primary probability test cases and all the secondary probability test cases.

[0067] refer to Figure 2 Preferably, a test case generation system disclosed in an embodiment of the present invention also includes: a condition combination item fine-tuning module 8, which is used to perform the following steps: for each first condition combination item, determine whether there is an invalid combination item; if there is a first condition combination item that is an invalid combination item, select a third condition combination item and a fourth condition combination item from the second condition combination item to replace, and fine-tune the invalid combination item; use the replaced first condition combination item to form a fifth condition combination item. In this way, specifically, the one-time probability test case generation and execution module 3 generates and executes a one-time probability test case according to the fifth condition combination item.

[0068] The embodiment of the present invention adopts a quadratic probability method, that is, partial probabilities are calculated before testing the object under test, and the remaining partial probabilities are calculated based on the test conditions when testing the object under test. Since the quadratic probability is calculated based on the premise of partial inevitable events, its probability range, that is, the probability denominator, is smaller, and the number of samples required to achieve the same expected goal is smaller, that is, the number of test cases is smaller, thereby ensuring the same quality level. Under the premise of obtaining a higher test execution efficiency, the design method adopts a primary probability fixed method and a secondary probability fixed method, without the need for any complex function calculations or logic design, thereby greatly reducing its design difficulty and design cost, and lowering the threshold for use.

[0069] Corresponding to the test case generation system disclosed above, the embodiment of the present invention further discloses a test case generation method. The following describes in detail a test case generation method disclosed in the embodiment of the present invention in combination with the test case generation system described above.

[0070] refer to Figure 3 , a test case generation method disclosed in an embodiment of the present invention includes:

[0071] Step 1: List the preset conditions according to the condition combination scenario;

[0072] Step 2: Combine the preset conditions in pairs, select several condition combination items, and form a first condition combination item;

[0073] Step 3: Generate and execute a probabilistic test case;

[0074] Step 4: Determine whether there is a defect in the execution of a probability test case; if there is no defect, directly execute step 7; if there is a defect, mark the corresponding condition combination item as an exception;

[0075] Step 5: Generate and execute secondary probability test cases based on the current anomaly marker;

[0076] Step 6: Determine whether there are defects in the execution of the secondary probability test case; if there are defects, mark the corresponding condition combination item as an exception, and re-execute step 5 until all current secondary probability test cases are executed without defects;

[0077] Step 7: Obtain the final test case, which includes: all the generated primary probability test cases and all the secondary probability test cases.

[0078] In the embodiment of the present invention, the first condition combination item generation module 2 is a self-developed generation tool. After the condition generation module 1 lists the preset conditions according to the condition combination scenario, the preset conditions are separated by commas and input into the self-developed generation tool. The generation tool arranges the preset conditions from left to right in sequence to form matrix rows, and arranges the preset conditions from top to bottom in the same order as the matrix rows to form matrix columns, generates a condition combination matrix, and automatically generates a matrix diagram from the condition combination matrix. Reference Figure 5 If the preset conditions are listed as: condition A, condition B, condition C, condition D, condition E, condition F, conditions A, condition B, condition C, condition D, condition E, condition F are arranged in sequence from left to right to form matrix rows, and conditions A, condition B, condition C, condition D, condition E, condition F are arranged in sequence from top to bottom in the same order as the matrix rows to form matrix columns, generating a condition combination matrix, and automatically generating a matrix diagram from the condition combination matrix.

[0079] Furthermore, in the step 2 executed by the first condition combination item generating module 2, the first condition combination item is formed, including: arranging the preset conditions from left to right and from top to bottom in the same order to form matrix rows and matrix columns respectively, and generating a condition combination matrix; taking the condition combination items on the diagonal from the lower left corner to the upper right corner from the condition combination matrix as the first condition combination item; the unselected condition combination items form the second condition combination item. Figure 5 As shown, according to the above method, the first condition combination items are: condition combination item AF, condition combination item BE, condition combination item CD, condition combination item DC, condition combination item EB, and condition combination item FA. The above method of obtaining the first condition combination item can use the minimum number of condition combination items to cover the conditions of all rows and columns of the condition combination matrix / matrix diagram.

[0080] refer to Figure 4 Preferably, a test case generation method disclosed in an embodiment of the present invention further includes: performing the following steps through the condition combination item fine-tuning module 8: for each first condition combination item, determining whether there is an invalid combination item; if there is a first condition combination item that is an invalid combination item, selecting a third condition combination item and a fourth condition combination item from the second condition combination item to replace them, and fine-tuning the invalid combination item; using the replaced first condition combination item to form a fifth condition combination item. Figure 5 As shown, the conditional combination CD is an invalid combination.

[0081] Furthermore, selecting a third conditional combination item from the second conditional combination item includes: in the conditional combination matrix, taking the conditional combination item one grid up and one grid down corresponding to each invalid combination item to form a third conditional combination item; judging whether there is at least one valid combination item in the third conditional combination item; if the third conditional combination items are all invalid combination items, taking the conditional combination item two grids up and two grids down corresponding to each invalid combination item to update the third conditional combination item, and so on, until there is at least one valid combination item in the third conditional combination item, selecting a valid combination item; if no valid combination item can be obtained after all the items are taken, then stop obtaining valid combination items from the third conditional combination item. Similarly, Figure 5 As shown, if conditional combination item CD is an invalid combination item, the conditional combination item one square above the position corresponding to the invalid combination item CD is taken as conditional combination item CC, and the conditional combination item one square below the position corresponding to the invalid combination item CD is taken as conditional combination item CE, that is, conditional combination item CC and conditional combination item CE are both the third conditional combination item. After judgment, conditional combination item CC is an invalid combination item, and conditional combination item CE is a valid combination item, so the valid combination item CE is taken to replace the invalid combination item CD.

[0082] Preferably, selecting a fourth conditional combination item from the second conditional combination items also includes: in the conditional combination matrix, taking the conditional combination items one grid to the left and right of each invalid combination item to form a fourth conditional combination item; judging whether there is at least one valid combination item in the fourth conditional combination item; if the fourth conditional combination items are all invalid combination items, taking the conditional combination items two grids to the left and two grids to the right of each invalid combination item to update the fourth conditional combination item, and so on, until there is at least one valid combination item in the fourth conditional combination item, then selecting a valid combination item; if no valid combination item can be obtained after all the combinations are exhausted, then stopping obtaining valid combination items from the fourth conditional combination item. Similarly, Figure 5 As shown, if the conditional combination item CD is an invalid combination item, the conditional combination item one grid to the left of the invalid combination item CD is taken as the conditional combination item BD, and the conditional combination item one grid to the right of the invalid combination item CD is taken as the conditional combination item DD, that is, the conditional combination item BD and the conditional combination item DD are both the fourth conditional combination item. After judgment, the conditional combination item BD is a valid combination item, so the valid combination item BD can be taken to replace the invalid combination item CD.

[0083] In the embodiment of the present invention, during the above-mentioned invalid combination item identification and fine-tuning process, the invalid combination item identification condition is: the conditional implementation of the conditional combination item is mutually exclusive. If an invalid combination item is identified, it is marked as invalid on the conditional combination matrix / matrix diagram. If a valid combination item, that is, a newly taken conditional combination item, is identified, it is marked as taken on the conditional combination matrix / matrix diagram. The "marking" function is a self-developed generation tool, which is a function of the generated conditional combination matrix and matrix diagram. The minimum number of conditional combination items is used here to cover the conditions of all rows and columns of the conditional combination matrix / matrix diagram.

[0084] In an embodiment of the present invention, in the above step three, after marking the invalid combination items and the newly obtained conditional combination items according to the above invalid combination item identification and fine-tuning process, click the Generate a Probabilistic Test Case function button on the self-developed generation tool to automatically generate a probability test case. The principle of generating a probability test case is: set the condition of the conditional combination item as the operation of the test case, and set "consistent with the requirements, no other exceptions occur" as the expectation of the test case. "Consistent with the requirements, no other exceptions occur" specifically means: the operation result has no exceptions and meets the requirements.

[0085] Furthermore, in the above steps 3 and 4, the generated one-time probability test cases are executed according to the test cases. When a one-time probability test case detects a defect in the object under test, the condition combination item in the condition combination matrix / matrix diagram corresponding to the current one-time probability test case is marked as an exception, and the next one-time probability test case is executed for defect detection. If all the one-time probability test cases are executed and no new exception marks are added, the one-time probability test case is executed.

[0086] Furthermore, in the above step five, when all primary probability test cases are executed, there are abnormal marks in the condition combination matrix / matrix diagram and the marking is completed, click the Generate Secondary Probability Test Case function button of the generation tool, and the secondary probability test case will be automatically generated according to the current abnormal mark.

[0087] Specifically, according to the current abnormal mark, a secondary probability test case is generated and executed, including: for each condition combination item currently marked as abnormal, all condition combination items with any condition of the condition combination item are obtained as the sixth condition combination item; the condition combination item that has previously generated the secondary probability test case is eliminated from the sixth condition combination item to obtain the seventh condition combination item; the seventh condition combination item is used to generate and execute the secondary probability test case. The principle here is: for example, when the condition combination item including two conditions, condition A and condition B, triggers a necessary event, then the probability of the combination of condition A and the remaining conditions, and condition B and the remaining conditions having the maximum probability of the occurrence of the necessary event, that is, when A&B=true, then the probability of A&C=true, A&D=true, B&C=true, and B&D=true is equal and greater than the probability of C&D=true. At the same time, the above condition combination item is also the one with the highest probability of triggering the necessary event among all the remaining combinations, which is the secondary probability calculation here.

[0088] If there are defects in the execution of the secondary probability test case, the corresponding condition combination item will be marked as abnormal, and step five will be re-executed. When step five is re-executed, a secondary probability test case is generated and executed according to the current newly added abnormal mark. Specifically, according to the current newly added abnormal mark, a secondary probability test case is generated and executed, including: for each newly added condition combination item marked as abnormal, all condition combination items with any condition of the condition combination item are obtained, and the sixth condition combination item is updated; the condition combination item for which the secondary probability test case has been generated before is removed from the updated sixth condition combination item, and the seventh condition combination item is updated; the secondary probability test case is regenerated and executed using the updated seventh condition combination item. Until all the current secondary probability test cases are executed without defects, a final test case is obtained, and the final test case includes: all the generated primary probability test cases and all the secondary probability test cases.

[0089] In the above step 6, multiple secondary probability related operations are continued, that is, if there are defects in the execution of the secondary probability test case, the corresponding condition combination item is marked as abnormal, and further from all the condition combination items in the horizontal and vertical directions of the condition combination matrix / matrix diagram where all newly marked abnormal combinations are located, the condition combination items that have previously generated the secondary probability test case are eliminated, and step 5 is re-executed. When the above step 6 is executed, if there is no new abnormal mark, the secondary probability test case is executed. Otherwise, continue to follow the operations of steps 5 and 6 until there is no new abnormal mark, and the secondary probability test case is executed.

[0090] The present invention realizes simple and efficient conditional combination scenario test case design through simple quadratic probability theory, which greatly reduces the difficulty and cost of case design. At the same time, since the designed case has fewer case studies while maintaining the same quality level, the test execution cost is further reduced.

[0091] The embodiment of the present invention adopts a quadratic probability method, that is, partial probabilities are calculated before testing the object under test, and the remaining partial probabilities are calculated based on the test conditions when testing the object under test. Since the quadratic probability is calculated based on the premise of partial inevitable events, its probability range, that is, the probability denominator, is smaller, and the number of samples required to achieve the same expected goal is smaller, that is, the number of test cases is smaller, thereby ensuring the same quality level. Under the premise of obtaining a higher test execution efficiency, the design method adopts a primary probability fixed method and a secondary probability fixed method, without the need for any complex function calculations or logic design, thereby greatly reducing its design difficulty and design cost, and lowering the threshold for use.

[0092] In addition, an embodiment of the present invention also provides a test case generation device, which includes: a processor and a memory; the memory is used to store one or more program instructions; the processor is used to run one or more program instructions to execute the steps of a test case generation method as described in any of the above items.

[0093] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of a test case generation method as described in any one of the above items are implemented.

[0094] In the embodiment of the present invention, the processor may be an integrated circuit chip having the signal processing capability. The processor may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0095] The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The processor reads the information in the storage medium and completes the steps of the above method in combination with its hardware.

[0096] The storage medium may be a memory, which may be, for example, a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memory.

[0097] Among them, the non-volatile memory can be a read-only memory (ROM), a programmable ROM (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory.

[0098] The volatile memory may be a random access memory (RAM) which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDRSDRAM), enhanced synchronous DRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus DRAM (DRRAM).

[0099] The storage media described in the embodiments of the present invention are intended to include, but are not limited to, these and any other suitable types of memory.

[0100] Those skilled in the art will appreciate that in one or more of the above examples, the functions described in the present invention can be implemented using a combination of hardware and software. When software is used, the corresponding functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any media that facilitates the transmission of computer programs from one place to another. Storage media can be any available media that can be accessed by general or special-purpose computers.

[0101] Although the present invention has been described in detail above by general description and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all belong to the scope of protection claimed by the present invention.

Claims

1. A test case generation method, characterized in that: The method comprises: Step 1: List the preset conditions according to the condition combination scenario; Step 2: Combine the preset conditions in pairs, select several condition combination items, and form a first condition combination item; Step 3: Generate and execute a probabilistic test case; Step 4: Determine whether there is a defect in the execution of a probability test case. If there is no defect, directly execute step 7; if there is a defect, mark the corresponding condition combination item as an exception; Step 5: Generate and execute secondary probability test cases based on the current anomaly marker; Step 6: Determine whether there are defects in the execution of the secondary probability test case; if there are defects, mark the corresponding condition combination item as an exception, and re-execute step 5 until all current secondary probability test cases are executed without defects; Step 7: Get the final test case; Generate and execute secondary probability test cases based on the current anomaly markers, including: For each condition combination item currently marked as abnormal, all condition combination items having any condition of the condition combination item are obtained as the sixth condition combination item; Eliminate the condition combination item that has previously generated the secondary probability test case from the sixth condition combination item to obtain a seventh condition combination item; Using the seventh condition combination item, a secondary probability test case is generated and executed.

2. A test case generation method as claimed in claim 1, characterized in that: The first condition combination is formed, including: In the same order, arrange all conditions from left to right and from top to bottom to form matrix rows and matrix columns respectively, and generate a condition combination matrix; From the condition combination matrix, take the condition combination items on the diagonal from the lower left corner to the upper right corner as the first condition combination items; The unselected conditional combination items form the second conditional combination item.

3. A test case generation method as claimed in claim 2, characterized in that: The method further comprises: For each first condition combination item, determine whether there is an invalid combination item; If there is a first condition combination item that is an invalid combination item, a third condition combination item and a fourth condition combination item are respectively selected from the second condition combination item to replace, and the invalid combination item is fine-tuned; The fifth conditional combination item is formed by using the replaced first conditional combination item.

4. A test case generation method as claimed in claim 3, characterized in that: Selecting a third condition combination item from the second condition combination item includes: In the condition combination matrix, take the condition combination items one grid above and one grid below the corresponding position of each invalid combination item to form a third condition combination item; Determine whether there is at least one valid combination of the third conditional combination items; If all the third conditional combination items are invalid combination items, take the conditional combination items two squares above and two squares below the corresponding position of each invalid combination item, and update the third conditional combination item, and so on, until there is at least one valid combination item in the third conditional combination item; If no valid combination item can be obtained after exhaustion, then the acquisition of valid combination items from the third condition combination item is stopped.

5. A test case generation method as claimed in claim 4, characterized in that: Selecting a fourth condition combination item from the second condition combination items includes: In the condition combination matrix, take the condition combination item one grid to the left and right of the corresponding position of each invalid combination item to form a fourth condition combination item; Determine whether there is at least one valid combination of the fourth conditional combination items; If all the fourth conditional combination items are invalid combination items, take the conditional combination items two squares above and two squares below the corresponding position of each invalid combination item, and update the fourth conditional combination item, and so on, until there is at least one valid combination item among the fourth conditional combination items; If no valid combination item can be obtained after all the items are exhausted, the process stops obtaining valid combination items from the fourth condition combination item.

6. A test case generation system, characterized in that: The system comprises: A condition generation module is used to list preset conditions according to condition combination scenarios; A first condition combination item generating module, used for combining the preset conditions in pairs, selecting a number of condition combination items, and forming a first condition combination item; A probability test case generation and execution module, used to generate and execute a probability test case; A probabilistic test case execution detection module is used to determine whether there is a defect in the execution of a probabilistic test case; if there is no defect, the final test case is obtained; if there is a defect, the corresponding condition combination item is marked as abnormal; A secondary probability test case generation and execution module is used to generate and execute secondary probability test cases according to the current anomaly mark; The secondary probability test case execution detection module is used to determine whether there are defects in the execution of the secondary probability test case; if there are defects, the corresponding condition combination item is marked as an exception and reused to execute step 5: according to the current exception mark, the secondary probability test case is generated and executed until all the current secondary probability test cases are executed without defects; The final test case generation module is used to obtain the final test case; Generate and execute secondary probability test cases based on the current anomaly markers, including: For each condition combination item currently marked as abnormal, all condition combination items having any condition of the condition combination item are obtained as the sixth condition combination item; Eliminate the condition combination item that has previously generated the secondary probability test case from the sixth condition combination item to obtain a seventh condition combination item; Using the seventh condition combination item, a secondary probability test case is generated and executed.

7. A test case generation system as claimed in claim 6, characterized in that: The system further comprises: a condition combination item fine-tuning module, which is used to perform the following steps: For each first condition combination item, determine whether there is an invalid combination item; If there is a first condition combination item that is an invalid combination item, a third condition combination item and a fourth condition combination item are respectively selected from the second condition combination item to replace, and the invalid combination item is fine-tuned; The fifth conditional combination item is formed by using the replaced first conditional combination item.

8. A test case generating device, characterized in that: The device comprises: a processor and a memory; The memory is used to store one or more program instructions; The processor is used to run one or more program instructions to execute the steps of a test case generation method as described in any one of claims 1 to 5.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a test case generation method as described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Method and device for generating a combined test case, storage medium and computer equipment

    CN109902002A

  • Test case design method and device, computer equipment and storage medium

    CN110008132A

  • Matrix type test case generation method and system, electronic equipment and storage medium

    CN112328493A