Test case processing method and device, electronic equipment and storage medium
By determining the target directory based on the function and selecting initial and supplementary test cases based on the number of test factors, the problem of excessive amount of test case set data in regression tests is solved, and the effect of reducing the number of test cases and shortening the execution time of regression tests is achieved.
Patent Information
- Application Number
- CN202510480772.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-05-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
With the enrichment of software functions, the amount of data in the test case set in the regression test is too large, resulting in the continuous increase in the execution time of the regression test. How to reduce the amount of data in the test case set has become an urgent problem.
By determining the target directory according to the corresponding functions of the test requirements, the target directory includes multiple test cases to be selected, and each test case to be selected covers one or more test factors. Then, the initial test case is determined based on the number of test factors covered by the target directory and the number of test cases to be selected, and the supplementary test cases are determined based on the number of remaining test factors until all test factors are covered, and the minimum set of test cases is obtained.
It realizes that on the basis of ensuring full coverage of test factors, the number of test cases is reduced and the amount of data in the minimum test case set is reduced, thereby shortening the execution time of regression tests.
Smart Images

Figure CN119988241A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a test case processing method, device, electronic equipment and storage medium. Background Art
[0002] Regression testing refers to the act of retesting old code after it has been modified to confirm that the modification has not introduced new errors or caused errors in other codes.
[0003] As software functions are continuously enriched and improved, the number of regression test cases based on products continues to accumulate, making the data volume of regression test case sets larger and larger, resulting in the regression test execution time of product version iterations being continuously extended. How to reduce the data volume of test case sets has become an urgent problem to be solved. Summary of the invention
[0004] The present invention provides a test case processing method, device, electronic device and storage medium to solve the problem of excessive data volume of test case sets in current regression testing.
[0005] According to one aspect of the present invention, a method for processing a test case is provided, comprising:
[0006] Determine a target directory according to the function corresponding to the test requirement, wherein the target directory includes a plurality of test cases to be selected, and each test case to be selected covers one or more test factors;
[0007] Determine the initial test cases based on the target catalog and the number of test factors covered by the candidate test cases;
[0008] According to the number of remaining test factors covered by the test cases to be selected in the target directory, supplementary test cases are determined until all test factors included in the target directory are covered, thereby obtaining a minimum test case set.
[0009] According to another aspect of the present invention, there is provided a test case processing device, comprising:
[0010] A target catalog determination module is used to determine a target catalog according to the function corresponding to the test requirement, wherein the target catalog includes a plurality of test cases to be selected, each of which covers one or more test factors;
[0011] A minimum test case set generation module is used to determine the initial test cases according to the target directory and the number of test factors covered by the candidate test cases;
[0012] According to the number of remaining test factors covered by the test cases to be selected in the target directory, supplementary test cases are determined until all test factors included in the target directory are covered, thereby obtaining a minimum test case set.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the test case processing method described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the test case processing method described in any embodiment of the present invention when executed.
[0018] The technical solution of the embodiment of the present invention determines the target directory according to the function corresponding to the test requirements, the target directory includes multiple test cases to be selected, each test case to be selected covers one or more test factors; determines the initial test case according to the target directory and the number of test factors covered by the test cases to be selected; determines the supplementary test case according to the number of remaining test factors covered by the test cases to be selected in the target directory, until all the test factors contained in the target directory are covered, and a minimum test case set is obtained. The technical solution provided by the embodiment of the present invention classifies the directory according to the function, selects test cases from the matching target directory according to the test requirements, can reduce the scope of test case selection, and improve the speed of test case selection. In the target directory, the initial test case and the supplementary test case are determined according to the number of test factors covered by the test case, and the test case selection based on the test factor can be realized. On the basis of ensuring full coverage of the test factors, the number of test cases is reduced, and then the number of test cases in the minimum test case set is reduced, so as to achieve the effect of reducing the amount of data in the minimum test case set.
[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 It is a flowchart of a method for processing a test case provided by an embodiment of the present invention;
[0022] Figure 2 It is a flowchart of another method for processing a test case provided by an embodiment of the present invention;
[0023] Figure 3 is a schematic diagram of an example process provided by an embodiment of the present invention;
[0024] Figure 4 It is a structural schematic diagram of a test case processing device provided by an embodiment of the present invention;
[0025] Figure 5 is a structural schematic diagram of another test case processing device provided by an embodiment of the present invention;
[0026] Figure 6 It is a structural schematic diagram of an electronic device for implementing the test case processing method of an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or apparatuses.
[0029] Regression testing refers to the act of retesting the old code after it has been modified to confirm that the modification has not introduced new errors or caused errors in other codes. With the continuous enrichment and improvement of software functions, the number of regression test cases based on products continues to accumulate, making the data volume of regression test case sets larger and larger, resulting in the continuous extension of the regression test execution time of product version iterations.
[0030] However, the current situation in the software industry is that the time for project product release or launch is continuously accelerating, and the test cycle or test time will be severely compressed, resulting in the problem of not being able to perform test execution for all regression cases. When the test time cannot meet the execution time of all regression cases, the above problem can be solved by reducing the set of test cases that need to be executed. How to reduce the amount of data in the test case set while ensuring that the regression test can be completed within the specified test time and ensuring the coverage of the regression test to ensure product quality has become an urgent problem to be solved.
[0031] Figure 1 This is a flow chart of a test case processing method provided by an embodiment of the present invention. This embodiment can be applied to the situation where the regression test is completed within the specified time and the quality of the regression test can be guaranteed by reducing the number of minimum test case sets when performing software regression testing. The method can be executed by a test case processing device, which can be implemented in the form of hardware and / or software, and can be configured in electronic devices such as personal computers and servers. Figure 1 As shown, the method includes:
[0032] Step S101: determine the target directory according to the function corresponding to the test requirement.
[0033] The target directory includes a plurality of test cases to be selected, and each test case to be selected covers one or more test factors.
[0034] In response to the triggering of regression testing, the test requirements are obtained. The test requirements may be regression testing of a certain function after being updated. The function that needs to be regression tested may be determined according to the test requirements. According to the pre-established mapping relationship between the directory and the function, the target directory corresponding to the function may be determined, and the target directory may store a plurality of candidate test cases for testing the function.
[0035] Furthermore, before step S101, determining the target directory according to the function corresponding to the test requirement, it also includes:
[0036] The test cases to be selected are classified according to the functions they match to obtain multiple directories, each directory containing multiple test cases to be selected for one function, and the multiple test cases to be selected cover all test factors required to test the function.
[0037] Accordingly, step S101, determining the target directory according to the function corresponding to the test requirement, can be implemented as follows:
[0038] A target directory is determined according to the multiple directories and the test requirements, and the function of the target directory matches the test requirements.
[0039] Optionally, multiple directories may be pre-created through the following steps 1 and 2 and the test factors covered by the test cases in the directories may be marked.
[0040] Step 1: Divide the action directory horizontally.
[0041] The candidate test cases used in the regression test are divided horizontally according to the functions. The functions to which the candidate test cases belong can be determined according to the identifiers of the function keywords possessed by the candidate test cases, and then the directories to which the candidate test cases belong can be determined.
[0042] If the test cases to be selected are already stored in the directory of the function to which they belong, this step can be omitted. For example, the test cases of the same functional class are marked with the identifier of the functional keyword or stored in the directory of the same functional keyword. If the test cases to be selected are not assigned to the directory of the function to which they belong, then according to the description of the test cases to be selected or the test function corresponding to the test cases to be selected, the functions to which the test cases to be selected belong are obtained, and the test cases to be selected are horizontally divided according to the functions, using the division method of the functional keyword identifier.
[0043] Step 2: In the directory corresponding to each function, mark the test factors covered by the test cases.
[0044] In each directory, the use cases under each function are analyzed vertically to obtain the test factors covered by each candidate test case. If the candidate test case has a detailed description of the test point, the test factor keyword information is extracted. If the candidate test case does not have a detailed description of the test point, the candidate test case needs to be traced back.
[0045] The candidate test cases can be manually traced, for example, by investigating the test design documents or communicating with the case designer to obtain the test factor information involved in the candidate test cases. The candidate test cases and all the corresponding test factor information are recorded, and the number of test factors covered by the candidate test cases is recorded. The multiple test factors corresponding to each candidate test case can be recorded according to the same rules, such as ascending or descending order of the first letter. After the analysis of all the cases under each function is completed, the test factors involved in the candidate test cases of this function class are obtained.
[0046] The above implementation method can realize the establishment of multiple directories according to functions, and isolate test cases applicable to different functions in the form of directories. When the regression test is triggered, the target directory can be quickly determined according to the function corresponding to the test requirement, effectively narrowing the scope of test cases to be selected, thereby improving the generation speed of the minimum test case set.
[0047] Step S102: Determine the initial test case according to the target directory and the number of test factors covered by the test case to be selected.
[0048] From the perspective of black box testing, based on the principle of ensuring test coverage, target test cases are selected from the candidate test cases in the target directory. The target test cases include initial test cases and supplementary test cases.
[0049] The functions to be tested can be determined according to the test requirements, and target test cases covering all test factors of the functions to be tested can be selected according to the functions to be tested. The functions to be tested can be all functions or functions matching the test requirements.
[0050] Optionally, under each function, the candidate test cases are arranged in descending order according to the number of test factors covered. The candidate test cases covering the largest number of test factors are preferentially selected as the initial test cases. The test factors covered by the initial test cases are marked in the corresponding full set of test factors.
[0051] Optionally, the initial test cases are determined according to the target directory and the number of test factors covered by the candidate test cases, which can be implemented as follows:
[0052] Find the candidate test cases with the largest number of coverage test factors from the target directory as the initial test cases.
[0053] Optionally, if there are multiple to-be-selected initial test cases in the target directory, the initial test case is determined according to the execution time of the multiple to-be-selected initial test cases; each to-be-selected initial test case covers the largest and identical number of test factors.
[0054] If there are N candidate initial test cases that cover the largest number of remaining test factors, then the candidate initial test case with the shortest execution time is selected from the N candidate initial test cases as the initial test case.
[0055] The above implementation can determine the initial test case that covers the most test factors in the target directory based on the number of test factors covered. Since the number of all test factors covered by the target directory is fixed, the more test factors a test case covers, the fewer test cases are needed to complete the test requirements, thereby reducing the number of test cases in the minimum test case set.
[0056] Step S103: Determine supplementary test cases according to the number of remaining test factors covered by the test cases to be selected in the target directory, until all test factors included in the target directory are covered, thereby obtaining a minimum test case set.
[0057] The number of remaining test factors is the number of test factors not covered by the initial test case and the supplementary test case.
[0058] After determining the initial test case, search the remaining candidate test cases in the target directory according to the unmarked test factors, and record the number of unmarked test factors covered by the candidate test cases. Prioritize the candidate test cases that cover the largest number of unmarked test factors and are ranked highest as supplementary test cases. Mark the test factors covered by the supplementary test cases. Repeat the above content and continue to select supplementary test cases until all test factors in the target directory are marked.
[0059] Exemplarily, a coverage mark is configured for each test factor, and the coverage mark is used to indicate whether the test factor is covered by the initial test case or the supplementary test case. The initial state of the coverage mark of the test factor is uncovered. After the initial test case is determined in step S102, the coverage mark of the test factor covered by the initial test case is configured as covered.
[0060] In step S103, a supplementary test case is determined according to the number of test factors covered by the candidate test case and marked as uncovered. After the supplementary test case is determined, the coverage mark of the test factor covered by the supplementary test case is configured as covered.
[0061] If there are still test factors with coverage marks as uncovered in the target directory, then the supplementary test cases are determined according to the number of test factors with coverage marks as uncovered covered by the candidate test cases. The coverage marks of the test factors covered by the supplementary test cases are configured as covered. This is done until the coverage marks of all test factors in the target directory are covered. At this time, the initial test cases and supplementary test cases determined constitute the minimum test case set.
[0062] In one implementation, a minimum test case set is selected for each function according to the above method. After the selection is completed, the use cases under all functions are summarized as a minimum test case set.
[0063] Optionally, determining the supplementary test cases according to the number of remaining test factors covered by the test cases to be selected in the target directory may be implemented as follows:
[0064] Find the candidate test cases covering the largest number of remaining test factors from the target directory as supplementary test cases.
[0065] Furthermore, if there are multiple supplementary test cases to be selected in the target directory, the supplementary test case is determined according to the execution time of the multiple supplementary test cases to be selected; each of the multiple supplementary test cases to be selected covers the largest and equal number of remaining test factors.
[0066] Optionally, if there are M candidate supplementary test cases that cover the largest number of remaining test factors, then the candidate supplementary test case with the shortest execution time is selected from the M candidate supplementary test cases as the supplementary test case.
[0067] The above implementation method can select the candidate test case that covers the largest number of remaining test factors in the target directory as a supplementary test case, and so on, taking the candidate test case that covers the largest number of remaining test factors as a priority condition, select multiple supplementary test cases so that the initial test case and multiple supplementary test cases can cover all test factors, and complete the selection of the minimum test case set. Since the number of all test factors covered by the target directory is fixed, the more test factors covered by the test case, the fewer test cases are required to complete the test requirements, thereby reducing the number of test cases in the minimum test case set.
[0068] The test case processing method of the embodiment of the present invention determines the target directory according to the function corresponding to the test requirements, the target directory includes multiple test cases to be selected, and each test case to be selected covers one or more test factors; determines the initial test case according to the target directory and the number of test factors covered by the test cases to be selected; determines the supplementary test case according to the number of remaining test factors covered by the test cases to be selected in the target directory, until all the test factors contained in the target directory are covered, and a minimum test case set is obtained. The test case processing method provided by the embodiment of the present invention classifies the directory according to the function, selects the test case from the matching target directory according to the test requirements, can reduce the test case selection range, and improve the test case selection speed. In the target directory, the initial test case and the supplementary test case are determined according to the number of test factors covered by the test case, and the test case selection based on the test factor can be realized. On the basis of ensuring full coverage of the test factors, the number of test cases is reduced, and then the number of test cases in the minimum test case set is reduced, so as to achieve the effect of reducing the data volume of the minimum test case set.
[0069] Figure 2A schematic diagram of another test case processing method provided in an embodiment of the present invention is provided as a further explanation of the above-mentioned embodiment. Specifically, after determining the initial test case according to the execution time of the multiple initial test cases to be selected, it also includes: using the selected initial test cases other than the initial test cases in the multiple initial test cases to be selected as alternative test cases. Correspondingly, after determining the supplementary test case according to the execution time of the multiple supplementary test cases to be selected, it also includes: using the selected supplementary test cases other than the supplementary test cases in the multiple supplementary test cases to be selected as alternative test cases. Correspondingly, after obtaining the minimum test case set, it also includes: determining whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set; if expanded, the minimum test case set is expanded according to the number of test factors or the test factor content covered by the alternative test case. The method can be implemented in the following way:
[0070] Step S201: determine the target directory according to the function corresponding to the test requirement.
[0071] Optionally, relevant directories, irrelevant directories, and directories with unknown relationships are determined based on the target function and commonly used functions corresponding to the test requirements; the relevant directories are directories that match the target function and correspond to the user's commonly used functions, the irrelevant directories are directories corresponding to functions that are irrelevant to the target function, and the directories with unknown relationships are directories that cannot be determined whether they have an association with the target function.
[0072] When creating a directory, add an association mark to the directory to indicate whether it is related. You can perform manual analysis based on information such as the change description when the product is released or the usage scenario characteristics of the released user. For the changed parts of the product released this time or the functions commonly used by users, the association mark of the directory is associated, and the directory with the association mark is associated is called a related directory. For functions that have no impact on the changed parts of the product released this time or the functions commonly used by users, the association mark of the directory is not associated, and the directory with the association mark is not associated is called an irrelevant directory. For other functions that cannot be clearly associated, the association mark of the directory is unknown, and the directory with the association mark is unknown is called a directory with unknown relationship.
[0073] The association between the functions of the above implementation method is to mark the directory based on the test requirements so that the subsequent steps can determine the method of supplementing the directory based on different tags.
[0074] Step S202: If there are multiple to-be-selected initial test cases in the target directory, determine the initial test case according to the execution time of the multiple to-be-selected initial test cases.
[0075] Among them, each of the initial test cases to be selected covers the largest number and the same number of test factors.
[0076] Step S203: taking the initial test cases to be selected, except the initial test case, from the multiple initial test cases to be selected as candidate test cases.
[0077] Step S204: If there are multiple supplementary test cases to be selected in the target directory, determine the supplementary test cases according to the execution time of the multiple supplementary test cases to be selected; until all test factors included in the target directory are covered to obtain a minimum test case set.
[0078] Among them, each of the multiple candidate supplementary tests covers the largest and equal number of remaining test factors.
[0079] Step S205: taking the supplementary test cases to be selected, except the supplementary test case, from the multiple supplementary test cases to be selected as candidate test cases.
[0080] Step S206: Determine whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set.
[0081] After generating the minimum test case set, the shortest execution time of the regression test can be evaluated based on the minimum test case set. The execution time can in turn provide a basis for estimating the test cycle in the project evaluation phase.
[0082] It should be noted that within the product release cycle, the test cycle can be analyzed and estimated based on user needs, project testing experience, regression testing time and other aspects. When user needs are urgent and the project complexity is high, there will be a need to compress the test time to meet project requirements. However, the test time cannot be compressed indefinitely, and the test time has a minimum time requirement (such as it must be greater than the sum of the shortest regression execution time and the test time of the forward function of the test function) to ensure the quality of the test. The execution time of the minimum test case set is an important basis for evaluating the test time. It can be seen that the test time is estimated based on multi-faceted analysis. The test time is based on the inability to meet the execution of all regression cases, and it must be greater than the time it takes to complete the execution of the minimum test case set.
[0083] Optionally, if the test time used for the regression execution is similar to the execution time of the minimum test case set, such as the difference is no more than 5%, the minimum test case set can be selected as the test case set selected for the final regression test. If the test time used for the regression execution is much greater than the execution time of the minimum test case set, such as the difference is more than 5%, the test case set needs to be expanded.
[0084] Optionally, determining whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set may be implemented as follows:
[0085] If the target directory is a directory with unknown relationship or a related directory, determine whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set. If the target directory is an irrelevant directory, cancel the expansion of the minimum test case set.
[0086] Optionally, the minimum test case set can be expanded by reselecting the candidate test cases from the candidate test cases. The candidate test cases with more test factors are selected first. During the selection, the execution time is accumulated and recorded, and the selection is stopped when the accumulated execution time is within the range of 5% of the test time.
[0087] The above implementation method can determine the directory supplement strategy according to the directory mark, and then expand the minimum test case set in a more targeted manner, thereby improving the test efficiency of regression testing.
[0088] Step S207: If expansion is performed, the minimum test case set is expanded according to the number of test factors or the content of test factors covered by the alternative test cases.
[0089] It should be noted that if the set of candidate test cases for regression testing does not change, after the minimum test case set is selected once, it does not need to be selected again for each product iteration test and can be used directly. The minimum test case set can be expanded according to the project cycle of product release (changes in testing time).
[0090] If the set of candidate test cases for regression testing increases, the minimum test case set of the newly added test cases can be selected according to the above steps S202 to S204, and then added to the existing minimum test case set for daily maintenance. Each time it is used, it is expanded according to the current latest minimum test case set, so as to select the test case set suitable for each product release.
[0091] Optionally, the minimum test case set is expanded according to the number of test factors or the content of test factors covered by the alternative test cases, which can be implemented as follows:
[0092] If the target directory is a related directory, then the candidate test cases with different test factors are determined according to the contents of the test factors covered by the candidate test cases, and the minimum test case set is expanded according to the candidate test cases with different test factors.
[0093] If the target directory is an unknown directory, the minimum test case set is expanded according to the number of test factors covered by the alternative test cases.
[0094] The above implementation method can effectively expand the minimum test case set according to the specific supplement strategy of the catalog, thereby improving the efficiency of regression testing.
[0095] The above implementation method can expand the minimum test case set based on the relationship between the test time and the execution time of the minimum test case set after obtaining the minimum test case set, so as to expand the minimum test case set under the premise of meeting the test time requirement to improve the reliability of regression testing. It can not only ensure that the regression test is completed within the specified test time, but also effectively ensure the coverage of the regression test, thereby improving the efficiency of regression testing.
[0096] Figure 3 A schematic diagram of another test case processing method provided by an embodiment of the present invention. As an example of an embodiment of the present invention, the test requirement includes a test requirement for at least one database query statement function, and the regression test is used to test the function involving the database query statement. The method includes:
[0097] Step S301: classify the test cases to be selected according to the functions they match, obtain multiple directories, and determine the target directory according to the multiple directories and test requirements.
[0098] Each directory contains multiple test cases for a function, and the multiple test cases cover all test factors required to test the function. In the database query statement scenario, the correspondence between functions and test factors is shown in Table 1. A test case can correspond to one test factor or multiple test factors, and there may be repeated factors.
[0099] Table 1
[0100]
[0101] Step S302: determine a target directory according to the multiple directories and test requirements.
[0102] A target directory is determined according to the multiple directories and the test requirements, and the function of the target directory matches the test requirements.
[0103] Optionally, relevant directories, irrelevant directories, and directories with unknown relationships are determined based on the target function and commonly used functions corresponding to the test requirements; the relevant directories are directories that match the target function and correspond to the user's commonly used functions, the irrelevant directories are directories corresponding to functions that are irrelevant to the target function, and the directories with unknown relationships are directories that cannot be determined whether they have an association with the target function.
[0104] Step S303: Search the target directory for a candidate test case that covers the largest number of test factors as the initial test case.
[0105] Optionally, if there are multiple to-be-selected initial test cases in the target directory, the initial test case is determined according to the execution time of the multiple to-be-selected initial test cases; each to-be-selected initial test case covers the largest number of test factors of the same number. The to-be-selected initial test cases other than the initial test case in the multiple to-be-selected initial test cases are used as candidate test cases.
[0106] Step S304: Search the target directory for the candidate test cases that cover the largest number of remaining test factors as supplementary test cases, until all test factors included in the target directory are covered to obtain a minimum test case set.
[0107] Optionally, if there are multiple supplementary test cases to be selected in the target directory, the supplementary test cases are determined according to the execution time of the multiple supplementary test cases to be selected; each of the multiple supplementary test cases to be selected covers the largest and identical number of remaining test factors. Until all the test factors contained in the target directory are covered, a minimum test case set is obtained. The supplementary test cases other than the supplementary test cases in the multiple supplementary test cases to be selected are used as candidate test cases.
[0108] Step S305: Determine whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set.
[0109] Optionally, if the target directory is a directory with unknown relationship or a related directory, it is determined whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set. If the target directory is an irrelevant directory, the expansion of the minimum test case set is cancelled.
[0110] Step S306: If expansion is performed, the minimum test case set is expanded according to the number of test factors or the content of test factors covered by the alternative test cases.
[0111] Optionally, when it is determined to expand, if the target directory is a related directory, the candidate test cases with different test factors are determined according to the contents of the test factors covered by the candidate test cases, and the minimum test case set is expanded according to the candidate test cases with different test factors. If the target directory is an unknown directory, the minimum test case set is expanded according to the number of test factors covered by the candidate test cases.
[0112] Step S307: Perform regression testing according to the minimum test case set.
[0113] The above implementation can quickly generate a minimum test case set based on the number of test factors covered by the candidate test cases, thereby reducing the size of the minimum test case set. On this basis, regression testing is completed, so that regression testing can meet the test time requirements and improve the reliability and effectiveness of regression testing.
[0114] Figure 4 This is a schematic diagram of the structure of a test case processing device provided by an embodiment of the present invention. This embodiment can be applied to the situation where the regression test is completed within the specified time and the quality of the regression test can be guaranteed by reducing the number of minimum test case sets during software regression testing. The test case processing device can be implemented in the form of hardware and / or software, and the test case processing device can be configured in electronic devices such as personal computers and servers. Figure 4 As shown, the device includes: a target directory determination module 41 and a minimum test case set generation module 42.
[0115] A target catalog determination module 41 is used to determine a target catalog according to the function corresponding to the test requirement, wherein the target catalog includes a plurality of test cases to be selected, and each test case to be selected covers one or more test factors;
[0116] A minimum test case set generation module 42 is used to determine the initial test cases according to the target directory and the number of test factors covered by the test cases to be selected;
[0117] According to the number of remaining test factors covered by the test cases to be selected in the target directory, supplementary test cases are determined until all test factors included in the target directory are covered, thereby obtaining a minimum test case set.
[0118] Based on the above embodiment, optionally, Figure 5 As shown, it also includes a catalog classification module 43, which is used to classify the test cases to be selected according to the functions matched by the test cases to obtain multiple catalogs, each catalog containing multiple test cases to be selected for one function, and the multiple test cases to be selected cover all test factors required to test the function before the target catalog determination module 41 determines the target catalog according to the functions corresponding to the test requirements;
[0119] Accordingly, the target directory determination module 41 is used to determine the target directory according to the function corresponding to the test requirement, including:
[0120] A target directory is determined according to the multiple directories and the test requirements, and the function of the target directory matches the test requirements.
[0121] Based on the above embodiment, optionally, the minimum test case set generation module 42 is used to determine the initial test cases according to the target directory and the number of test factors covered by the test cases to be selected, including:
[0122] Find the candidate test cases with the largest number of coverage test factors from the target directory as the initial test cases;
[0123] Accordingly, the minimum test case set generation module 42 is used to determine the supplementary test cases according to the number of remaining test factors covered by the test cases to be selected in the target directory, including:
[0124] Find the candidate test cases covering the largest number of remaining test factors from the target directory as supplementary test cases.
[0125] Based on the above embodiment, optionally, the minimum test case set generation module 42 is used to search the target directory for the candidate test case with the largest number of coverage test factors as the initial test case, including:
[0126] If there are multiple to-be-selected initial test cases in the target directory, the initial test case is determined according to the execution time of the multiple to-be-selected initial test cases; each to-be-selected initial test case covers the largest number of test factors with the same number;
[0127] Accordingly, the minimum test case set generation module 42 is used to search the target directory for the candidate test cases that cover the largest number of remaining test factors as supplementary test cases, including:
[0128] If there are multiple supplementary test cases to be selected in the target directory, the supplementary test case is determined according to the execution time of the multiple supplementary test cases to be selected; each of the multiple supplementary test cases to be selected covers the largest and equal number of remaining test factors.
[0129] On the basis of the above embodiment, optionally, it further includes an alternative test case selection module 44, which is used to select the initial test cases other than the initial test cases in the multiple initial test cases to be selected as the alternative test cases after the minimum test case set generation module 42 determines the initial test cases according to the execution time of the multiple initial test cases to be selected;
[0130] The candidate test case selection module 44 is further configured to use, after the minimum test case set generation module 42 determines the supplementary test case according to the execution time of the plurality of supplementary test cases to be selected, the supplementary test cases to be selected other than the supplementary test case in the plurality of supplementary test cases to be selected as candidate test cases;
[0131] Accordingly, it also includes a test case expansion module 45, which is used to determine whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set after the minimum test case set generation module 42 obtains the minimum test case set;
[0132] If expansion is performed, the minimum test case set is expanded according to the number of test factors or the content of test factors covered by the alternative test cases determined by the alternative test case selection module 44 .
[0133] Based on the above embodiment, optionally, the target directory determining module 41 is used to determine the target directory according to the function corresponding to the test requirement, including:
[0134] Determine relevant directories, irrelevant directories, and directories with unknown relationships according to the target function and commonly used functions corresponding to the test requirements; the relevant directories are directories that match the target function and correspond to the user's commonly used functions, the irrelevant directories are directories corresponding to functions that are irrelevant to the target function, and the directories with unknown relationships are directories that cannot be determined whether they have a correlation with the target function;
[0135] Correspondingly, the test case expansion module 45 is used to determine whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set, including:
[0136] If the target directory is a directory with unknown relationship or a related directory, determining whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set;
[0137] If the target directory is an irrelevant directory, cancel the expansion of the minimum test case set.
[0138] Based on the above embodiment, optionally, the test case expansion module 45 is used to expand the minimum test case set according to the number of test factors or the content of test factors covered by the candidate test cases, including:
[0139] If the target directory is a related directory, determining the candidate test cases with different test factors according to the contents of the test factors covered by the candidate test cases, and expanding the minimum test case set according to the candidate test cases with different test factors;
[0140] If the target directory is an unknown directory, the minimum test case set is expanded according to the number of test factors covered by the alternative test cases.
[0141] Based on the above embodiment, optionally, the test requirement includes a test requirement of at least one database query statement function. The device also includes a testing module 46 for performing regression testing according to the minimum test case set after the minimum test case set generation module 42 obtains the minimum test case set.
[0142] The test case processing device of the embodiment of the present invention, the target directory determination module 41, is used to determine the target directory according to the function corresponding to the test requirement, the target directory includes multiple test cases to be selected, and each test case to be selected covers one or more test factors. The minimum test case set generation module 42 is used to determine the initial test case according to the target directory and the number of test factors covered by the test cases to be selected; according to the number of remaining test factors covered by the test cases to be selected in the target directory, determine the supplementary test case until all the test factors contained in the target directory are covered, and obtain the minimum test case set. The test case processing device provided by the embodiment of the present invention classifies the directory according to the function, selects the test case from the matching target directory according to the test requirement, can reduce the test case selection range, and improve the test case selection speed. In the target directory, the initial test case and the supplementary test case are determined according to the number of test factors covered by the test case, and the test case selection based on the test factor can be realized. On the basis of ensuring full coverage of the test factors, the number of test cases is reduced, and then the number of test cases in the minimum test case set is reduced, so as to achieve the effect of reducing the data volume of the minimum test case set.
[0143] The test case processing device provided in the embodiment of the present invention can execute the test case processing method provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0144] Figure 6 1 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0145] like Figure 6As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0146] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0147] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the processing method of the test case.
[0148] In some embodiments, the test case processing method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the test case processing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the test case processing method in any other appropriate manner (e.g., by means of firmware).
[0149] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0150] The computer program for implementing the test case processing method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program can be executed completely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or completely on a remote machine or server.
[0151] The embodiment of the invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a processor to execute a test case processing method, the method comprising:
[0152] Determine a target directory according to the function corresponding to the test requirement, wherein the target directory includes a plurality of test cases to be selected, and each test case to be selected covers one or more test factors;
[0153] Determine the initial test cases based on the target catalog and the number of test factors covered by the candidate test cases;
[0154] According to the number of remaining test factors covered by the test cases to be selected in the target directory, supplementary test cases are determined until all test factors included in the target directory are covered, thereby obtaining a minimum test case set.
[0155] Based on the above embodiment, optionally, before determining the target directory according to the function corresponding to the test requirement, the method further includes:
[0156] Classify the test cases to be selected according to the functions they match, and obtain multiple directories, each directory containing multiple test cases to be selected for one function, and the multiple test cases to be selected cover all test factors required to test the function;
[0157] Accordingly, the target directory is determined according to the functions corresponding to the test requirements, including:
[0158] A target directory is determined according to the multiple directories and the test requirements, and the function of the target directory matches the test requirements.
[0159] Based on the above embodiment, optionally, determining the initial test case according to the target directory and the number of test factors covered by the test case to be selected includes:
[0160] Find the candidate test cases with the largest number of coverage test factors from the target directory as the initial test cases;
[0161] Accordingly, according to the number of remaining test factors covered by the test cases to be selected in the target directory, the supplementary test cases are determined, including:
[0162] Find the candidate test cases covering the largest number of remaining test factors from the target directory as supplementary test cases.
[0163] Based on the above embodiment, optionally, searching the target directory for a candidate test case with the largest number of coverage test factors as the initial test case includes:
[0164] If there are multiple to-be-selected initial test cases in the target directory, the initial test case is determined according to the execution time of the multiple to-be-selected initial test cases; each to-be-selected initial test case covers the largest number of test factors with the same number;
[0165] Accordingly, the candidate test cases that cover the largest number of remaining test factors are searched from the target directory as supplementary test cases, including:
[0166] If there are multiple supplementary test cases to be selected in the target directory, the supplementary test case is determined according to the execution time of the multiple supplementary test cases to be selected; each of the multiple supplementary test cases to be selected covers the largest and equal number of remaining test factors.
[0167] Based on the above embodiment, optionally, after determining the initial test case according to the execution time of the multiple initial test cases to be selected, the method further includes: taking the initial test cases to be selected other than the initial test case among the multiple initial test cases to be selected as candidate test cases;
[0168] Accordingly, after determining the supplementary test case according to the execution time of the plurality of supplementary test cases to be selected, the method further includes: taking the supplementary test cases other than the supplementary test case in the plurality of supplementary test cases to be selected as candidate test cases;
[0169] Accordingly, after obtaining the minimum test case set, it also includes:
[0170] Determine whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set;
[0171] If expansion is performed, the minimum test case set is expanded according to the number of test factors or the content of test factors covered by the alternative test cases.
[0172] Based on the above embodiment, optionally, determining the target directory according to the function corresponding to the test requirement includes:
[0173] Determine relevant directories, irrelevant directories, and directories with unknown relationships according to the target function and commonly used functions corresponding to the test requirements; the relevant directories are directories that match the target function and correspond to the user's commonly used functions, the irrelevant directories are directories corresponding to functions that are irrelevant to the target function, and the directories with unknown relationships are directories that cannot be determined whether they have a correlation with the target function;
[0174] Accordingly, determining whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set includes:
[0175] If the target directory is a directory with unknown relationship or a related directory, determining whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set;
[0176] If the target directory is an irrelevant directory, cancel the expansion of the minimum test case set.
[0177] On the basis of the above embodiment, optionally, the minimum test case set is expanded according to the number of test factors or the content of test factors covered by the alternative test cases, including:
[0178] If the target directory is a related directory, determining the candidate test cases with different test factors according to the contents of the test factors covered by the candidate test cases, and expanding the minimum test case set according to the candidate test cases with different test factors;
[0179] If the target directory is an unknown directory, the minimum test case set is expanded according to the number of test factors covered by the alternative test cases.
[0180] Based on the above embodiment, optionally, the test requirement includes a test requirement for at least one database query statement function; after obtaining the minimum test case set, it also includes: performing regression testing according to the minimum test case set.
[0181] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0182] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0183] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0184] A computing system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0185] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0186] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for processing a test case, characterized in that: include: Determine a target directory according to the function corresponding to the test requirement, wherein the target directory includes a plurality of test cases to be selected, and each test case to be selected covers one or more test factors; Determine the initial test cases based on the target catalog and the number of test factors covered by the candidate test cases; According to the number of remaining test factors covered by the test cases to be selected in the target directory, supplementary test cases are determined until all test factors included in the target directory are covered, thereby obtaining a minimum test case set.
2. The method according to claim 1, characterized in that: Before determining the target directory based on the functions corresponding to the test requirements, it also includes: Classify the test cases to be selected according to the functions they match, and obtain multiple directories, each directory containing multiple test cases to be selected for one function, and the multiple test cases to be selected cover all test factors required to test the function; Accordingly, the target directory is determined according to the functions corresponding to the test requirements, including: A target directory is determined according to the multiple directories and the test requirements, and the function of the target directory matches the test requirements.
3. The method according to claim 1, characterized in that Determine the initial test cases based on the target catalog and the number of test factors covered by the candidate test cases, including: Find the candidate test cases with the largest number of coverage test factors from the target directory as the initial test cases; Accordingly, according to the number of remaining test factors covered by the test cases to be selected in the target directory, the supplementary test cases are determined, including: Find the candidate test cases covering the largest number of remaining test factors from the target directory as supplementary test cases.
4. The method according to claim 3, characterized in that Find the candidate test cases with the largest number of coverage test factors from the target directory as the initial test cases, including: If there are multiple to-be-selected initial test cases in the target directory, determine the initial test case according to the execution time of the multiple to-be-selected initial test cases; each to-be-selected initial test case covers the largest number and the same number of test factors; Accordingly, the candidate test cases that cover the largest number of remaining test factors are searched from the target directory as supplementary test cases, including: If there are multiple supplementary test cases to be selected in the target directory, the supplementary test case is determined according to the execution time of the multiple supplementary test cases to be selected; each of the multiple supplementary test cases to be selected covers the largest and equal number of remaining test factors.
5. The method according to claim 4, characterized in that After determining the initial test case according to the execution time of the plurality of initial test cases to be selected, the method further includes: taking the initial test cases to be selected other than the initial test case among the plurality of initial test cases to be selected as candidate test cases; Accordingly, after determining the supplementary test case according to the execution time of the plurality of supplementary test cases to be selected, the method further includes: taking the supplementary test cases other than the supplementary test case in the plurality of supplementary test cases to be selected as candidate test cases; Accordingly, after obtaining the minimum test case set, it also includes: Determine whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set; If expansion is performed, the minimum test case set is expanded according to the number of test factors or the content of test factors covered by the alternative test cases.
6. The method according to claim 5, characterized in that Determine the target directory based on the functions corresponding to the test requirements, including: Determine relevant directories, irrelevant directories, and directories with unknown relationships according to the target function and commonly used functions corresponding to the test requirements; the relevant directories are directories that match the target function and correspond to the user's commonly used functions, the irrelevant directories are directories corresponding to functions that are irrelevant to the target function, and the directories with unknown relationships are directories that cannot be determined whether they have a correlation with the target function; Accordingly, determining whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set includes: If the target directory is a directory with unknown relationship or a related directory, determining whether to expand the minimum test case set according to the test time and the execution time of the minimum test case set; If the target directory is an irrelevant directory, cancel the expansion of the minimum test case set.
7. The method according to claim 6, characterized in that Expanding the minimum test case set according to the number of test factors or the content of test factors covered by the alternative test cases includes: If the target directory is a related directory, determining the candidate test cases with different test factors according to the contents of the test factors covered by the candidate test cases, and expanding the minimum test case set according to the candidate test cases with different test factors; If the target directory is an unknown directory, the minimum test case set is expanded according to the number of test factors covered by the alternative test cases.
8. A test case processing device, characterized in that: include: A target catalog determination module is used to determine a target catalog according to the function corresponding to the test requirement, wherein the target catalog includes a plurality of test cases to be selected, each of which covers one or more test factors; A minimum test case set generation module is used to determine the initial test cases according to the target directory and the number of test factors covered by the candidate test cases; According to the number of remaining test factors covered by the test cases to be selected in the target directory, supplementary test cases are determined until all test factors included in the target directory are covered, thereby obtaining a minimum test case set.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the test case processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the test case processing method according to any one of claims 1 to 7 when executed.
Citation Information
Patent Citations
Regression test case screening method based on partial multi-coverage
CN101908017A
Method and system for optimizing software test case
CN103810104A
Automatic test case selection method based on greedy algorithm
CN104391790A
Testing method, testing device and electronic equipment
CN108920353A
Recommendation method and device of regression test case, medium and equipment
CN114519008A