Training method of test case generation model and test case generation method and device
By building a test case generation model based on decision tree, using the matching relationship between requirements documents and historical test cases to generate test cases, and by quality evaluation and adjustment of decision trees, the problem of low efficiency and quality of test case generation in the existing technology is solved, and fast and accurate high-quality test case generation is achieved.
Patent Information
- Application Number
- CN202411842926.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-12
AI Technical Summary
The prior art is difficult to automatically generate high-quality test cases quickly and accurately, resulting in extended software testing cycles and affecting the speed of software release.
By building a test case generation model based on multiple decision trees, the matching relationship between requirements documents and historical test cases is generated, and the decision tree is evaluated and adjusted to improve the accuracy of the generative model.
It realizes the rapid and accurate automatic generation of high-quality test cases, improves the efficiency and quality of test case generation, and shortens the software test cycle.
Smart Images

Figure CN119782157A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of automated testing technology, and in particular to a test case generation model training method, a test case generation method and a device. Background Art
[0002] With the continuous expansion of software application fields, the scale and complexity of software design are also increasing, which makes manual writing of test cases very time-consuming and of low quality, thus extending the testing cycle and affecting the speed of software release. In order to improve the quality and efficiency of manually written test cases, the automatic generation of test cases can be achieved by introducing automated testing technology. However, how to further quickly and accurately automatically generate test cases is an urgent problem to be solved. Summary of the invention
[0003] In view of this, the present application provides a test case generation model training method, a test case generation method and a device, which can automatically generate test cases quickly and accurately.
[0004] In a first aspect, the present application provides a training method for a test case generation model, comprising: obtaining a test case generation model to be trained, the test case generation model to be trained is generated based on multiple first decision trees, the multiple first decision trees correspond to different generation processes of test cases, and each first decision tree is constructed based on multiple historical test cases under each first characteristic value; inputting a first requirement document into the test case generation model to be trained, and selecting a historical test case corresponding to the first requirement document from each first characteristic value in each first decision tree to obtain a first test case corresponding to the first requirement document; performing a quality assessment on the first test case, and adjusting the multiple first decision trees based on the first assessment result, so that the assessment result obtained based on the adjusted test case generation model meets the preset assessment result to obtain a target test case generation model.
[0005] In a second aspect, the present application provides a test case generation method, including: obtaining a target test case generation model, the target test case generation model is generated based on multiple first decision trees, the multiple first decision trees correspond to different generation processes of the test case, and each first decision tree is constructed based on multiple historical test cases under each first characteristic value; inputting a second requirement document into the target test case generation model, selecting a historical test case that matches the second requirement document from each first characteristic value in each first decision tree, and obtaining a third test case corresponding to the second requirement document.
[0006] In a third aspect, the present application provides a training device for a test case generation model, comprising: a first acquisition module, used to acquire a test case generation model to be trained, the test case generation model to be trained is generated based on multiple first decision trees, the multiple first decision trees correspond to different generation processes of the test case, and each first decision tree is constructed based on multiple historical test cases under each first eigenvalue; a first processing module, used to input a first requirement document into the test case generation model to be trained, and select a historical test case corresponding to the first requirement document from each first eigenvalue in each first decision tree to obtain a first test case corresponding to the first requirement document; an evaluation module, used to perform quality evaluation on the first test case; and an adjustment module, used to adjust the multiple first decision trees based on the first evaluation result, so that the evaluation result obtained based on the adjusted test case generation model meets the preset evaluation result to obtain a target test case generation model.
[0007] In a fourth aspect, the present application provides a test case generation device, including: a second acquisition module, used to obtain a target test case generation model, the target test case generation model is generated based on multiple first decision trees, the multiple first decision trees correspond to different generation processes of test cases, and each first decision tree is constructed based on multiple historical test cases under each first characteristic value; a second processing module, used to input a second requirement document into the target test case generation model, and select a historical test case that matches the second requirement document from each first characteristic value in each first decision tree to obtain a third test case corresponding to the second requirement document.
[0008] In a fifth aspect, the present application provides an electronic device comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store one or more executable instructions, and the executable instructions enable the processor to execute the method of the first aspect or the second aspect mentioned above.
[0009] In a sixth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by one or more processors, it implements the method of the first aspect or the second aspect mentioned above.
[0010] In a seventh aspect, the present application provides a computer program product, comprising computer program instructions, which enable a computer to execute the method of the first aspect or the second aspect above.
[0011] In an eighth aspect, the present application provides a computer program, which, when executed on a computer, enables the computer to execute the method of the first aspect or the second aspect.
[0012] The present application provides a training method for a test case generation model, which can obtain a test case generation model to be trained; input a first requirement document into the test case generation model to be trained, and select a historical test case corresponding to the first requirement document from each first feature value in each first decision tree to obtain a first test case corresponding to the first requirement document; perform a quality assessment on the first test case, and adjust multiple first decision trees based on the first assessment result, so that the assessment result obtained based on the adjusted test case generation model meets the preset assessment result to obtain a target test case generation model. In this way, the target test case generation model can be obtained by training the test case generation model to be trained, and the target test case generation model can be used to automatically generate test cases, thereby improving the quality and efficiency of generating test cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0014] Figure 1 It is a flowchart of a training method for a test case generation model provided in an embodiment of the present application;
[0015] Figure 2 is a schematic diagram of a process for obtaining each first characteristic value provided by an embodiment of the present application;
[0016] Figure 3 It is a flow chart of a test case generation model provided by an embodiment of the present application;
[0017] Figure 4 It is a flow chart of a quality assessment model generated according to an embodiment of the present application;
[0018] Figure 5 It is a flowchart of a test case generation method provided in an embodiment of the present application;
[0019] Figure 6 It is a detailed flowchart of a training method for a test case generation model provided in an embodiment of the present application;
[0020] Figure 7 It is a schematic diagram of the composition structure of a training device for a test case generation model provided in an embodiment of the present application;
[0021] Figure 8 It is a schematic diagram of the composition structure of a test case generation device provided in an embodiment of the present application;
[0022] Fig. 9 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and in detail below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0025] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0026] It should also be pointed out that the terms "first\second\third" involved in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0027] In addition, the term "and / or" in the embodiments of the present application is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0028] To facilitate understanding of the technical solutions of the embodiments of the present application, the relevant technologies of the embodiments of the present application are described below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.
[0029] A test case is the basic unit in software testing. It describes in detail the conditions, steps, expected results, and actual results of executing the test. Test cases are a key tool for ensuring software quality. Through test cases, it can be verified whether the software works as expected and meets the requirements specifications. Furthermore, corresponding test cases can be designed based on the functional description, business rules, user scenarios and other information in the requirements document. Test cases can cover all key points and boundary conditions in the requirements document to ensure a more comprehensive test of the software.
[0030] With the rapid advancement of science and technology and the continuous expansion of software application fields, the scale of software design is becoming increasingly large, and its complexity is also rising sharply, which makes manual writing of test cases very time-consuming and of low quality, thus extending the testing cycle and affecting the speed of software release. In order to improve the quality and efficiency of manually written test cases, the automatic generation of test cases can be achieved by introducing automated testing technology. However, how to further quickly and accurately automatically generate test cases is an urgent problem to be solved.
[0031] Based on this, the embodiment of the present application provides a training method for a test case generation model, which can obtain a test case generation model to be trained; input a first requirement document into the test case generation model to be trained, and select a historical test case corresponding to the first requirement document from each first feature value in each first decision tree to obtain a first test case corresponding to the first requirement document; perform a quality assessment on the first test case, and adjust multiple first decision trees based on the first assessment result, so that the assessment result obtained based on the adjusted test case generation model meets the preset assessment result to obtain a target test case generation model. In this way, the target test case generation model can be obtained by training the test case generation model to be trained, and the target test case generation model can be used to automatically generate test cases, thereby improving the quality and efficiency of generating test cases.
[0032] To facilitate understanding of the technical solutions of the embodiments of the present application, the technical solutions of the present application are described in detail below through specific embodiments. The above related technologies can be combined arbitrarily with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application. The embodiments of the present application include at least part of the following contents.
[0033] Figure 1 is a flow chart of a training method for a test case generation model provided in an embodiment of the present application, such as Figure 1 As shown, the method may include the following steps.
[0034] S110. Obtain a test case generation model to be trained, where the test case generation model to be trained is generated based on multiple first decision trees, the multiple first decision trees correspond to different generation processes of test cases, and each first decision tree is constructed based on multiple historical test cases under each first eigenvalue.
[0035] It should be noted that, in the embodiments of the present application, the training method of the test case generation model can be applied to a training device for the test case generation model, or an electronic device integrated with the device. The electronic device can be implemented in various forms, for example, the electronic device can include vehicles, smart phones, tablet computers, laptop computers, PDAs, portable media players (PMPs), etc., which are not limited here.
[0036] It should be noted that each first characteristic value may be key information in multiple historical test cases, or may be a characteristic value constructed based on key information in multiple historical test cases, which is not limited in the embodiments of the present application.
[0037] Exemplarily, the multiple first characteristic values may include: functional modules, functional points, test methods, pre-parameters, intermediate steps, expected results, etc., which are not limited in the embodiments of the present application.
[0038] Among them, the functional modules are mainly sub-functions of each system, such as the sub-functions of the dynamic data acquisition system include basic data management, signal pool management, acquisition task management, and business monitoring statistics; the functional points include the addition, deletion, editing, and query of each sub-function; the test method can be understood as the idea of writing test cases, including equivalence classes, boundary values, decision tables, orthogonal arrangements, etc.; pre-parameters, intermediate steps, and expected results are components of the test cases.
[0039] Exemplarily, different test case generation processes may include preconditions, intermediate processes, expected results, etc. for generating test cases, which is not limited in the embodiments of the present application.
[0040] Exemplarily, a first decision tree based on preconditions can be constructed based on multiple first characteristic values: multiple historical test cases under each first characteristic value among functional modules, functional points, test methods, pre-parameters, intermediate steps, and expected results; a first decision tree based on intermediate processes can be constructed based on multiple first characteristic values: multiple historical test cases under each first characteristic value among functional modules, functional points, test methods, pre-parameters, intermediate steps, and expected results; a first decision tree based on expected results can be constructed based on multiple first characteristic values: multiple historical test cases under each first characteristic value among functional modules, functional points, test methods, pre-parameters, intermediate steps, and expected results.
[0041] It should be noted that, taking a first characteristic value and a historical test case as an example, the multiple historical test cases under each first characteristic value can be understood as at least part of the historical test cases in the historical test case that corresponds to the first characteristic value. Exemplarily, taking the first characteristic value as a function module as an example, a historical test case under the function module can be understood as at least part of the historical test cases in the historical test case that corresponds to the function module.
[0042] Figure 2 is a schematic diagram of a process for obtaining each first characteristic value provided by an embodiment of the present application, such as Figure 2 As shown, the method may include the following steps:
[0043] S210, obtaining multiple historical test cases;
[0044] S220, extracting key information from multiple historical test cases to obtain candidate feature values;
[0045] S230 , selecting characteristic values with a correlation relationship from the candidate characteristic values to obtain each first characteristic value.
[0046] It should be noted that the candidate feature value may be key information in multiple historical test cases, or may be a feature value constructed based on key information in multiple historical test cases, which is not limited in the embodiments of the present application.
[0047] It should also be noted that the number of candidate feature values can be one or more, and this is not limited in the embodiments of the present application.
[0048] Exemplarily, the plurality of first characteristic values may include a function module, a function point, and a test method, wherein the internal connection between each first characteristic value may be: what function point a certain function module corresponds to, and what unified test method is there.
[0049] It can be understood that the method for obtaining each second characteristic value in the following embodiments is similar to the method for obtaining each first characteristic value, and will not be described in detail here.
[0050] Through this method, by selecting eigenvalues with correlation relationships from candidate eigenvalues as each first eigenvalue, redundant and irrelevant eigenvalues can be removed, thereby simplifying the structure of the test case generation model and making the generation result of the test case generation model more accurate.
[0051] In some embodiments, obtaining multiple historical test cases may include: obtaining a test case training set; selecting candidate historical test cases from the test case training set, and performing at least one of the following operations on the candidate historical test cases to obtain multiple historical test cases:
[0052] For repeated historical test cases in the candidate historical test cases, the most recently created historical test case is retained, and other historical test cases are deleted;
[0053] Filling missing historical test cases into alternative historical test cases;
[0054] Abnormal historical test cases in the candidate historical test cases are deleted, wherein the abnormal historical test cases do not include at least one first characteristic value (and / or at least one second characteristic value in the following embodiments).
[0055] It should be noted that the test case training set may include: test cases (such as alternative historical test cases, and also such as the second test cases), requirement documents (such as the first requirement documents, and also such as the second requirement documents), execution results, code change records, defect reports and other related software test data.
[0056] Exemplarily, abnormal historical test cases among the alternative historical test cases may be captured by a box plot visualization method.
[0057] It should be noted that, for repeated historical test cases, by retaining the most recently created historical test cases and deleting other historical test cases, redundancy of historical test cases can be avoided, making the obtained multiple historical test cases more accurate.
[0058] It should also be noted that by filling the missing historical test cases into the candidate historical test cases, the obtained multiple historical test cases can be made more complete.
[0059] It should also be noted that by deleting abnormal historical test cases from the candidate historical test cases, the quality of the obtained multiple historical test cases can be improved.
[0060] Through this method, by performing at least one of the above operations on the alternative historical test cases, the multiple historical test cases obtained can be made more refined and accurate, and can be more effectively used for the training of subsequent test case generation models and quality assessment models, thereby improving the efficiency of subsequent model training and reducing unnecessary resource consumption.
[0061] In some embodiments, the method may further include: sorting each first characteristic value by a decision tree algorithm; and constructing each first decision tree based on a plurality of historical test cases under each sorted first characteristic value.
[0062] Exemplarily, the decision tree algorithm may be a Constrained Resource Allocation Tree (CRAT) algorithm, or other algorithms, which is not limited in the embodiments of the present application.
[0063] It should be noted that each first eigenvalue may be ranked based on the degree of influence of each first eigenvalue on the generation result of the test case generation model. For example, the first eigenvalue with a greater degree of influence on the generation result may be ranked in the front row, while the first eigenvalue with a smaller degree of influence on the generation result may be ranked in the back row.
[0064] Through this method, each first decision tree is constructed based on multiple historical test cases under each first eigenvalue after sorting. This allows more attention to be paid to the first eigenvalue that has an important impact on the generation result during the training of the test case generation model generated by multiple first decision trees, thereby improving the accuracy of the generation result of the test case generation model and also improving the generalization ability of the test case generation model.
[0065] For example, Figure 3 Schematic diagram of a flow chart of generating a test case generation model provided by an embodiment of the present application. Figure 3 As shown, the method may include the following steps:
[0066] S310, obtaining three first characteristic values: function point, function module and test method;
[0067] S320, sorting the three first eigenvalues based on the CRAT algorithm to obtain three sorted first eigenvalues: function module, function point and test method;
[0068] S330, constructing a first decision tree based on a precondition based on a plurality of historical test cases under each first characteristic value;
[0069] S340, constructing a first decision tree based on the intermediate process based on multiple historical test cases under each first characteristic value;
[0070] S350, constructing a first decision tree based on expected results based on multiple historical test cases under each first characteristic value;
[0071] S360: Generate a test case generation model based on the first decision tree of preconditions, intermediate processes, and expected results.
[0072] It can be understood that the function points, function modules and test methods can be used as the three first characteristic values based on the intrinsic relationship between them, such as what function points a certain function module corresponds to and what unified test methods there are.
[0073] It can also be understood that sorting the three first eigenvalues based on the CRAT algorithm can rank the functional modules that have a greater impact on the generation results of the test case generation model first, while ranking the test methods that have a smaller impact on the generation results of the test case generation model third.
[0074] It can also be understood that based on multiple historical test cases under each first characteristic value, first decision trees based on preconditions, intermediate processes and expected results are obtained respectively. In this way, the three first decision trees are distinguished from different test case generation processes, and each first decision tree represents a test case generation process, so that each first decision tree has a clear division of labor, and each first decision tree covers a large number of historical test cases, which improves the accuracy of the generation results of the subsequent test case generation model.
[0075] Through this method, the preconditions, intermediate processes and expected results in the test case generation model can cover multiple historical test cases, thereby improving the generalization ability of the test case generation model.
[0076] S120. Input a first requirement document into the test case generation model to be trained, and select a historical test case corresponding to the first requirement document from each first feature value in each first decision tree to obtain a first test case corresponding to the first requirement document.
[0077] It should be noted that, taking a first decision tree as an example, under different first characteristic values, a historical test case corresponding to the first requirement document may be the same or different, and the embodiment of the present application does not limit this.
[0078] It should also be noted that the first test case can be considered as: from each first characteristic value in each first decision tree, a historical test case corresponding to the first requirement document is selected, and all the selected historical test cases are combined. Furthermore, a historical test case selected from a first characteristic value can be a complete historical test case, or a part of a complete historical test case corresponding to a first characteristic value, which is not limited in the embodiment of the present application.
[0079] Exemplarily, it is assumed that the multiple first decision trees are the first decision tree based on the precondition, the first decision tree based on the intermediate process, and the first decision tree based on the expected result, and the multiple first characteristic values are the function module and the function point. In the first decision tree based on the precondition, a historical test case corresponding to the first requirement document can be selected from the function module, and a historical test case corresponding to the first requirement document can be selected from the function point; in the first decision tree based on the intermediate process, a historical test case corresponding to the first requirement document can be selected from the function module, and a historical test case corresponding to the first requirement document can be selected from the function point; in the first decision tree based on the expected result, a historical test case corresponding to the first requirement document can be selected from the function module, and a historical test case corresponding to the first requirement document can be selected from the function point. The multiple historical test cases selected above are combined to obtain the first test case corresponding to the first requirement document.
[0080] It can be understood that the first test case can be considered as the output of the test case generation model to be trained, and the first test case can be automatically generated by the test case generation model to be trained.
[0081] S130: Perform quality assessment on the first test case to obtain a first assessment result.
[0082] It can be understood that there are two ways to implement the quality assessment of the first test case:
[0083] A possible implementation manner is to establish a mapping relationship between test cases and evaluation results; based on the first test case and the mapping relationship, a first evaluation result can be obtained.
[0084] It should be noted that the mapping relationship may be established based on empirical rules, may be established manually, or may be established in other ways, and the embodiments of the present application are not limited to this.
[0085] It should also be noted that the first test case can be substituted into the mapping relationship, so as to obtain the first evaluation result corresponding to the first mapping relationship.
[0086] Based on this implementation, by establishing a mapping relationship, the first evaluation result corresponding to the first test case can be quickly obtained, thereby improving the efficiency of subsequent training of the test case generation model based on the first evaluation result.
[0087] Another possible implementation method, performing quality assessment on the first test case, may include: obtaining a target quality assessment model, the target quality assessment model is generated based on multiple second decision trees, the multiple second decision trees correspond to different quality assessment dimensions of the test case, and each second decision tree is constructed based on the grades of multiple historical test cases under each second eigenvalue; inputting the first test case into the target quality assessment model, selecting a historical test case corresponding to the first test case from each second eigenvalue in each second decision tree to obtain the grade under each second decision tree corresponding to the first test case; and weighting the grade under each second decision tree to obtain a first evaluation result.
[0088] It should be noted that each second characteristic value may be key information in multiple historical test cases, or may be a characteristic value constructed based on key information in multiple historical test cases, which is not limited in the embodiments of the present application.
[0089] It should also be noted that the levels of multiple historical test cases under each second characteristic value can be set based on empirical rules or manually, and the embodiment of the present application does not limit this. Exemplarily, the level of each historical test case can include: excellent, good, medium, and poor.
[0090] Exemplarily, different quality assessment dimensions of test cases may include readability assessment dimension, integrity assessment dimension, consistency assessment dimension, repeatability assessment dimension, independence assessment dimension, exception handling capability assessment dimension, robustness assessment dimension, maintainability assessment dimension, etc., which is not limited to the embodiments of the present application.
[0091] Exemplarily, a second decision tree based on readability may be constructed based on the levels of multiple historical test cases under each second characteristic value of fluent sentences, no typos, simplicity, and understandable descriptions.
[0092] It can be understood that the method for obtaining each second eigenvalue is the same as Figure 2 The method for obtaining each first characteristic value shown is similar and will not be described in detail here.
[0093] In some embodiments, the method may further include: sorting each second characteristic value by a decision tree algorithm; and constructing each second decision tree based on the levels of multiple historical test cases under each sorted second characteristic value.
[0094] Exemplarily, the decision tree algorithm may be a CRAT algorithm or other algorithms, which is not limited in the embodiments of the present application.
[0095] It should be noted that each second eigenvalue may be ranked based on the degree of influence of each second eigenvalue on the output result of the quality assessment model. For example, the second eigenvalue with a greater influence on the output result may be ranked in the front row, while the second eigenvalue with a smaller influence on the output result may be ranked in the back row.
[0096] Through this method, each second decision tree is constructed based on the levels of multiple historical test cases under each sorted second eigenvalue. After the quality assessment model is generated based on multiple second decision trees, more attention can be paid to the second eigenvalue that has an important impact on the output result of the quality assessment model, thereby improving the accuracy of the output result of the quality assessment model and also improving the generalization ability of the quality assessment model.
[0097] For example, Figure 4 Schematic diagram of a process for generating a quality assessment model provided in an embodiment of the present application. Figure 4 As shown, the method may include the following steps:
[0098] S410, obtaining multiple second feature values: no typos, smooth sentences, easy-to-understand descriptions, logical coherence, comprehensive information, and rich details;
[0099] S420, sorting the words without typos, fluent sentences, and understandable descriptions based on the CRAT algorithm to obtain three second eigenvalues after sorting: fluent sentences, without typos, and understandable descriptions;
[0100] S430, sorting the logical coherence, comprehensive information, and rich details based on the CRAT algorithm to obtain three second eigenvalues after sorting: comprehensive information, logical coherence, and rich details;
[0101] S440, constructing a second decision tree based on readability based on the levels of multiple historical test cases under each second characteristic value in terms of sentence fluency, absence of typos, and easy-to-understand descriptions;
[0102] S450, constructing a second decision tree based on completeness based on the levels of multiple historical test cases under each second characteristic value in terms of comprehensive information, logical coherence, and rich details;
[0103] S460: Generate a quality assessment model based on the second decision tree of readability and completeness.
[0104] It can be understood that based on the intrinsic connection between smooth sentences, no typos and easy-to-understand descriptions, such as whether there are typos and whether the description is clear when the sentences are smooth, smooth sentences, no typos and easy-to-understand descriptions can be used as the three second eigenvalues; based on the intrinsic connection between comprehensive information, logical coherence and rich details, such as whether the logic is coherent and whether it contains more details when the information is comprehensive, comprehensive information, logical coherence and rich details can be used as the three second eigenvalues.
[0105] It can also be understood that by sorting multiple second eigenvalues based on the CRAT algorithm, the second eigenvalue with a greater impact on the output result of the quality assessment model can be ranked first, while the eigenvalue with a smaller impact on the output result of the quality assessment model can be ranked last.
[0106] It can also be understood that based on the levels of multiple historical test cases under each first feature value, second decision trees based on readability and completeness are obtained respectively. In this way, the two second decision trees are distinguished from different quality assessment dimensions of the test cases, and each second decision tree represents a quality assessment dimension of the test cases, so that each second decision tree has a clear division of labor, and each second decision tree covers the levels of a large number of historical test cases, thereby improving the accuracy of the output results of the subsequent quality assessment model.
[0107] Through this method, the two quality assessment dimensions of readability and completeness in the quality assessment model can cover the levels of multiple historical test cases, thereby improving the generalization ability of the quality assessment model.
[0108] It should be noted that, taking a second decision tree as an example, under different second characteristic values, a historical test case corresponding to a first test case may be the same or different; and, when a historical test case is the same, the level of the historical test case under different second characteristic values may be the same or different, and the embodiments of the present application do not limit this.
[0109] It should also be noted that, taking a second decision tree as an example, the level under each second decision tree corresponding to the first test case can be understood as, in a second decision tree, determining the level of the second decision tree corresponding to the first test case based on the level of a historical test case selected under each second characteristic value.
[0110] Exemplarily, in a second decision tree for readability, a historical test case selected under smooth sentences has an excellent rating, a historical test case selected under no typos has an excellent rating, and a historical test case selected under understandable description has a good rating. Then, the rating of the first test case corresponding to the second decision tree for readability is excellent.
[0111] It can be understood that a historical test case selected under each second characteristic value can be considered as the historical test case that is closest to the content of the first test case. At this time, the level of the historical test case under each second characteristic value can be used as the level of the first test case under each second characteristic value.
[0112] It can also be understood that the level under each second decision tree corresponding to the first test case can be considered as the output of the target quality assessment model, and the level under each second decision tree corresponding to the first test case can be automatically generated by the target quality assessment model.
[0113] In some embodiments, weighted processing is performed on the levels under each second decision tree to obtain a first evaluation result, which may include: determining the weight value of the level under each second decision tree; based on the weight value of the level under each second decision tree, weighted processing is performed on the level of each second decision tree to obtain the first evaluation result.
[0114] Exemplarily, the weight value of the grade under the second decision tree based on readability is 0.4, and the weight value of the grade under the second decision tree based on integrity is 0.6. Assuming that the grade under the second decision tree based on readability is good, and the grade under the second decision tree based on integrity is poor, considering the grade weight values under the second decision tree of readability and integrity, the first evaluation result deviation corresponding to the first test case can be obtained.
[0115] Through this method, by weighting the levels under each second decision tree, the accuracy and reliability of the obtained first evaluation result can be improved.
[0116] In some embodiments, obtaining a target quality assessment model may include: obtaining a quality assessment model to be trained, and a predicted grade under each second decision tree corresponding to a second test case; inputting the second test case into the quality assessment model to be trained, and selecting a historical test case corresponding to the second test case from each second characteristic value in each second decision tree to obtain a true grade under each second decision tree corresponding to the second test case; determining a first loss under each second decision tree based on the predicted grade under each second decision tree and the true grade under each second decision tree; and adjusting multiple second decision trees based on the first loss under each second decision tree so that the loss obtained based on the adjusted quality assessment model meets the convergence condition to obtain the target quality assessment model.
[0117] It should be noted that the convergence condition may be that the training of the quality assessment model reaches a preset number of times, or the loss is within a preset range. The preset number of times and the preset range may be appropriately set by those skilled in the art according to actual conditions, and the embodiments of the present application are not limited thereto.
[0118] Through this method, by training the quality assessment model, the accuracy of the output result of the trained target quality assessment model can be improved, and the generalization ability of the target quality assessment model can be further improved.
[0119] In some embodiments, adjusting the plurality of second decision trees based on the first loss under each second decision tree may include at least one of the following:
[0120] Adjust the quality of multiple historical test cases;
[0121] Add new historical test cases to multiple historical test cases;
[0122] Each second feature value in each second decision tree is adjusted.
[0123] It should be noted that adjusting the quality of multiple historical test cases may include: for repeated historical test cases among multiple historical test cases, retaining the most recently created historical test cases and deleting other historical test cases; and / or, deleting abnormal historical test cases among multiple historical test cases, wherein the abnormal historical test cases do not include at least one second characteristic value.
[0124] It should also be noted that adjusting each second eigenvalue in each second decision tree may include: deleting at least some of the second eigenvalues in at least some of the second decision trees; and / or adding new second eigenvalues to at least some of the second decision trees.
[0125] Through this method, multiple second decision trees are adjusted based on the first loss under each second decision tree, which can speed up the training speed of the quality assessment model, enable the quality assessment model to reach a convergence state faster, and more effectively improve the output accuracy of the quality assessment model.
[0126] Based on this implementation, quality assessment of the first test case is performed through the target quality assessment model, so that the obtained first assessment result can be made more accurate, thereby improving the training accuracy of the subsequent test case generation model trained based on the first assessment result.
[0127] S140. Adjust the plurality of first decision trees based on the first evaluation result, so that the evaluation result obtained based on the adjusted test case generation model satisfies the preset evaluation result to obtain a target test case generation model.
[0128] It should be noted that the preset evaluation results can be appropriately set by those skilled in the art according to actual conditions, and the embodiments of the present application are not limited to this.
[0129] In some embodiments, adjusting the plurality of first decision trees based on the first evaluation result may include at least one of the following:
[0130] Adjust the quality of multiple historical test cases;
[0131] Add new historical test cases to multiple historical test cases;
[0132] Each first feature value in each first decision tree is adjusted.
[0133] It should be noted that adjusting each first eigenvalue in each first decision tree may include: deleting at least some of the first eigenvalues in at least some of the first decision trees; and / or adding new first eigenvalues to at least some of the first decision trees.
[0134] Through this method, multiple first decision trees are adjusted based on the first evaluation result, which can speed up the training speed of the test case generation model, enable the test case generation model to reach a convergence state faster, and more effectively improve the output accuracy of the test case generation model.
[0135] The embodiment of the present application provides a training method for a test case generation model, which can obtain a test case generation model to be trained; input a first requirement document into the test case generation model to be trained, and select a historical test case corresponding to the first requirement document from each first feature value in each first decision tree to obtain a first test case corresponding to the first requirement document; perform a quality assessment on the first test case, and adjust multiple first decision trees based on the first assessment result, so that the assessment result obtained based on the adjusted test case generation model meets the preset assessment result to obtain a target test case generation model. In this way, the target test case generation model can be obtained by training the test case generation model to be trained, and the target test case generation model can be used to automatically generate test cases, thereby improving the quality and efficiency of generating test cases.
[0136] In the embodiment of the present application, by Figures 1 to 4 The technical solution shown in the figure trains the test case generation model to obtain a trained target test case generation model. It can be understood that based on the trained target test case generation model, test cases can be automatically generated. Figure 5 The process of automatically generating test cases by the target test case generation model is described.
[0137] Figure 5 is a flow chart of a test case generation method provided by an embodiment of the present application, such as Figure 5 As shown, the method may include the following steps:
[0138] S510, obtaining a target test case generation model, where the target test case generation model is generated based on a plurality of first decision trees, where the plurality of first decision trees correspond to different generation processes of test cases, and each first decision tree is constructed based on a plurality of historical test cases under each first characteristic value;
[0139] S520, input the second requirement document into the target test case generation model, select a historical test case matching the second requirement document from each first feature value in each first decision tree, and obtain a third test case corresponding to the second requirement document.
[0140] Exemplarily, it is assumed that the multiple first decision trees are the first decision tree based on the precondition, the first decision tree based on the intermediate process, and the first decision tree based on the expected result, and the multiple first characteristic values are the function module and the function point. In the first decision tree based on the precondition, a historical test case corresponding to the second requirement document can be selected from the function module, and a historical test case corresponding to the second requirement document can be selected from the function point; in the first decision tree based on the intermediate process, a historical test case corresponding to the second requirement document can be selected from the function module, and a historical test case corresponding to the second requirement document can be selected from the function point; in the first decision tree based on the expected result, a historical test case corresponding to the second requirement document can be selected from the function module, and a historical test case corresponding to the second requirement document can be selected from the function point. The multiple historical test cases selected above are combined to obtain a third test case corresponding to the second requirement document.
[0141] It should be noted that, for the description of the structure of the target test case generation model, reference can be made to the description of the structure of the test case generation model to be trained in the aforementioned embodiment, which will not be repeated in the embodiments of the present application.
[0142] The embodiment of the present application provides a test case generation method, which can automatically generate test cases using a target test case generation model. In this way, on the one hand, the quality and efficiency of generating test cases are improved; on the other hand, the time for testers to manually write test cases is reduced, so that testers can devote more energy to the execution of valuable test cases and the analysis of execution results.
[0143] The following describes in detail the training method of the test case generation model provided in the above embodiment in combination with specific application scenarios.
[0144] Figure 6 is a detailed flow chart of a training method for a test case generation model provided in an embodiment of the present application, such as Figure 6 As shown, the method may include the following steps.
[0145] S601. Obtain a test case training set.
[0146] It should be noted that the test case training set may include: test cases (such as the second test case), requirement documents (such as the first requirement document), execution results, code change records, defect reports and other related software test data.
[0147] S602: Obtain multiple first eigenvalues and multiple second eigenvalues from a test case training set.
[0148] It should be noted that alternative historical test cases can be selected from the test case training set, and deletion, filling and other operations can be performed on the alternative historical test cases to obtain multiple historical test cases; multiple first eigenvalues and multiple second eigenvalues with associated relationships can be extracted from the multiple historical test cases.
[0149] S603: Obtain a test case generation model to be trained based on the multiple first feature values.
[0150] It should be noted that, based on multiple historical test cases under each first eigenvalue, multiple first decision trees can be constructed, and the multiple first decision trees correspond to different generation processes of test cases; then, based on the multiple first decision trees, a test case generation model to be trained is generated.
[0151] S604: Input a first requirement document into the test case generation model to be trained to obtain a first test case.
[0152] It should be noted that a historical test case corresponding to the first requirement document can be selected from each first characteristic value in each first decision tree, and all the historical test cases obtained above can be combined to obtain the first test case corresponding to the first requirement document.
[0153] S605: Obtain a quality assessment model to be trained based on the multiple second feature values.
[0154] It should be noted that, based on the levels of multiple historical test cases under each second eigenvalue, multiple second decision trees can be constructed, and the multiple second decision trees correspond to different quality assessment dimensions of the test cases; then based on the multiple second decision trees, a quality assessment model to be trained is generated.
[0155] S606: Input a second test case into the quality assessment model to be trained, and obtain a true grade under each second decision tree corresponding to the second test case.
[0156] It should be noted that a historical test case corresponding to the second test case can be selected from each second characteristic value in each second decision tree, and based on the level of the selected historical test case, the actual level under each second decision tree corresponding to the second test case can be obtained.
[0157] S607: Based on the true level of each second decision tree, determine whether the loss meets the convergence condition.
[0158] It should be noted that the loss under each second decision tree (i.e., the first loss) can be determined based on the predicted level under each second decision tree and the actual level under each second decision tree; and it is determined whether the first loss meets the convergence condition (such as whether the loss is within a preset range).
[0159] It should also be noted that when the loss meets the convergence conditions, the trained target quality assessment model can be deployed online, that is, S608 is executed; when the loss does not meet the convergence conditions, multiple second decision trees can be adjusted based on the loss so that the loss obtained based on the adjusted quality assessment model meets the convergence conditions and the target quality assessment model is obtained, that is, S609 is executed.
[0160] S608. Deploy the target quality assessment model online.
[0161] At this time, the target quality assessment model is a trained quality assessment model.
[0162] S609: Adjust the multiple second decision trees based on the loss.
[0163] It should be noted that the multiple second decision trees can be adjusted by at least one of the following: adjusting the quality of multiple historical test cases; adding new historical test cases to multiple historical test cases; adjusting each second feature value in each second decision tree.
[0164] It should also be noted that after adjusting the multiple second decision trees, the adjusted quality assessment model needs to be trained again, that is, S606 and S607 are executed again (new test cases can be input at this time) until the loss obtained by the adjusted quality assessment model meets the convergence condition and the target quality assessment model is obtained.
[0165] S610: Perform quality assessment on the first test case using a target quality assessment model to obtain a first assessment result.
[0166] It should be noted that a first test case can be input into the target quality assessment model, and a historical test case corresponding to the first test case can be selected from each second characteristic value in each second decision tree to obtain the level under each second decision tree corresponding to the first test case; the level under each second decision tree is weighted to obtain a first evaluation result.
[0167] S611. Determine whether the first evaluation result satisfies a preset evaluation result.
[0168] It should be noted that, when the first evaluation result meets the preset evaluation result, the trained target test case generation model can be deployed online, that is, S612 is executed; when the first evaluation result does not meet the preset evaluation result, the multiple first decision trees can be adjusted based on the first evaluation result, so that the evaluation result obtained based on the adjusted test case generation model meets the preset evaluation result and the target test case generation model is obtained, that is, S613 is executed.
[0169] S612, online deployment target test case generation model.
[0170] At this time, the target test case generation model is a trained test case generation model.
[0171] S613: Adjust the multiple first decision trees based on the first evaluation result.
[0172] It should be noted that the multiple first decision trees can be adjusted by at least one of the following: adjusting the quality of multiple historical test cases; adding new historical test cases to multiple historical test cases; adjusting each feature value in each first decision tree.
[0173] It should also be noted that after adjusting the multiple first decision trees, the adjusted test case generation model needs to be trained again, that is, S604, S610 and S611 are executed again (a new requirement document can be input at this time) until the evaluation results obtained by the adjusted test case generation model meet the preset evaluation results and obtain the target test case generation model.
[0174] An embodiment of the present application provides a method for training a test case generation model. By training the test case generation model to be trained, a target test case generation model can be obtained. Test cases can be automatically generated using the target test case generation model, thereby improving the quality and efficiency of generating test cases.
[0175] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the idea of the present application, they should also be regarded as the contents disclosed in the present application. For another example, under the premise of no conflict, the various embodiments and / or the technical features in the various embodiments described in the present application can be arbitrarily combined with the prior art, and the technical solution obtained after the combination should also fall within the protection scope of the present application.
[0176] It should also be understood that in the various method embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0177] Based on the same inventive concept as the above embodiments, Figure 7 is a schematic diagram of the composition structure of a training device for a test case generation model provided in an embodiment of the present application, such as Figure 7 As shown, the training device 700 for the test case generation model may include a first acquisition module 710, a first processing module 720, an evaluation module 730, and an adjustment module 740, wherein:
[0178] A first acquisition module 710 is used to acquire a test case generation model to be trained, where the test case generation model to be trained is generated based on a plurality of first decision trees, where the plurality of first decision trees correspond to different generation processes of the test case, and each first decision tree is constructed based on a plurality of historical test cases under each first eigenvalue;
[0179] A first processing module 720 is used to input a first requirement document into the test case generation model to be trained, and select a historical test case corresponding to the first requirement document from each first feature value in each first decision tree to obtain a first test case corresponding to the first requirement document;
[0180] An evaluation module 730, configured to perform quality evaluation on the first test case;
[0181] The adjustment module 740 is used to adjust the multiple first decision trees based on the first evaluation result, so that the evaluation result obtained based on the adjusted test case generation model meets the preset evaluation result to obtain the target test case generation model.
[0182] In some embodiments, the first acquisition module 710 is also used to obtain a target quality assessment model, which is generated based on multiple second decision trees, which correspond to different quality assessment dimensions of the test case, and each second decision tree is constructed based on the levels of multiple historical test cases under each second eigenvalue; the first processing module 720 is also used to input the first test case into the target quality assessment model, select a historical test case corresponding to the first test case from each second eigenvalue in each second decision tree, so as to obtain the level under each second decision tree corresponding to the first test case; and perform weighted processing on the level under each second decision tree to obtain a first evaluation result.
[0183] In some embodiments, Figure 7 As shown, the training device 700 for the test case generation model may further include a determination module 750, wherein:
[0184] The first acquisition module 710 is further used to obtain the quality assessment model to be trained and the predicted grade under each second decision tree corresponding to the second test case; the first processing module 720 is further used to input the second test case into the quality assessment model to be trained, and select a historical test case corresponding to the second test case from each second feature value in each second decision tree to obtain the actual grade under each second decision tree corresponding to the second test case;
[0185] A determination module 750, configured to determine a first loss under each second decision tree based on a predicted grade under each second decision tree and a true grade under each second decision tree;
[0186] The adjustment module 740 is further used to adjust the multiple second decision trees based on the first loss under each second decision tree, so that the loss obtained based on the adjusted quality assessment model meets the convergence condition to obtain the target quality assessment model.
[0187] In some embodiments, Figure 7 As shown, the training device 700 for the test case generation model may further include a sorting module 760 and a construction module 770, wherein:
[0188] A sorting module 760, for sorting each first eigenvalue by a decision tree algorithm;
[0189] The construction module 770 is used to construct each first decision tree based on the sorted multiple historical test cases under each first characteristic value.
[0190] In some embodiments, Figure 7 As shown, the training device 700 for the test case generation model may further include an extraction module 780, wherein:
[0191] The first acquisition module 710 is also used to acquire multiple historical test cases;
[0192] The extraction module 780 is used to extract key information from multiple historical test cases to obtain candidate feature values; select feature values with associated relationships from the candidate feature values to obtain each first feature value and / or each second feature value.
[0193] In some embodiments, the first acquisition module 710 is also used to obtain a test case training set; the first processing module 720 is also used to select alternative historical test cases from the test case training set, and perform at least one of the following operations on the alternative historical test cases to obtain multiple historical test cases: for repeated historical test cases in the alternative historical test cases, retain the most recently created historical test cases, and delete other historical test cases; fill missing historical test cases in the alternative historical test cases; delete abnormal historical test cases in the alternative historical test cases, wherein the abnormal historical test cases do not include at least one first feature value and / or at least one second feature value.
[0194] In some embodiments, the adjustment module 740 is further used to adjust the quality of multiple historical test cases; add new historical test cases to the multiple historical test cases; and adjust each first feature value in each first decision tree.
[0195] In the scheme of the embodiment of the present application, a target test case generation model can be obtained by training the test case generation model to be trained, and test cases can be automatically generated using the target test case generation model, thereby improving the quality and efficiency of generating test cases.
[0196] Those skilled in the art should understand that the relevant description of the training device for the above-mentioned test case generation model in the embodiment of the present application can be understood by referring to the relevant description of the training method for the test case generation model in the embodiment of the present application.
[0197] Based on the same inventive concept as the above embodiments, Figure 8 is a schematic diagram of the composition structure of a test case generation device provided in an embodiment of the present application, such as Figure 8 As shown, the test case generating device 800 may include a second acquisition module 810 and a second processing module 820, wherein:
[0198] A second acquisition module 810 is used to acquire a target test case generation model, where the target test case generation model is generated based on a plurality of first decision trees, where the plurality of first decision trees correspond to different generation processes of test cases, and each first decision tree is constructed based on a plurality of historical test cases under each first characteristic value;
[0199] The second processing module 820 is used to input the second requirement document into the target test case generation model, and select a historical test case matching the second requirement document from each first feature value in each first decision tree to obtain a third test case corresponding to the second requirement document.
[0200] In the solution of the embodiment of the present application, the target test case generation model can be used to automatically generate test cases. In this way, on the one hand, the quality and efficiency of generating test cases are improved; on the other hand, the time for testers to manually write test cases is reduced, so that testers can devote more energy to the execution of valuable test cases and the analysis of execution results.
[0201] Those skilled in the art should understand that the relevant description of the above-mentioned test case generation device in the embodiment of the present application can be understood by referring to the relevant description of the test case generation method in the embodiment of the present application.
[0202] Fig. 9 It is a structural diagram of an electronic device provided in an embodiment of the present application. The electronic device 900 may include: a processor (Processor) 910, a communication interface (Communications Interface) 920, a memory (Memory) 930 storing a program 950, and a communication bus 940.
[0203] The processor 910 , the communication interface 920 , and the memory 930 communicate with each other via the communication bus 940 .
[0204] The communication interface 920 is used to communicate with other electronic devices or servers.
[0205] The processor 910 is used to execute the program 950, and specifically can execute the relevant steps in the above method embodiment.
[0206] Specifically, the program 950 may include program code, which includes one or more executable computer operation instructions.
[0207] The processor 910 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or may be processors of different types, such as one or more CPUs and one or more ASICs.
[0208] The memory 930 is used to store one or more executable instructions. The memory 930 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (Non-Volatile Memory), such as one or more disk memories.
[0209] One or more executable instructions may be specifically used to enable the processor 910 to execute the method provided in the embodiment of the present application.
[0210] In addition, the specific implementation of each step in one or more executable instructions can refer to the corresponding description of the corresponding steps and units in the above method embodiments, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above method embodiments, which will not be repeated here.
[0211] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program.
[0212] In some embodiments, the computer-readable storage medium can be applied to the electronic device in the embodiments of the present application, and when the computer program is executed by one or more processors, it implements the corresponding processes implemented by the electronic device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0213] An embodiment of the present application also provides a computer program product, including computer program instructions.
[0214] In some embodiments, the computer program product can be applied to the electronic device in the embodiments of the present application, and the computer program instructions enable the computer to execute the corresponding processes implemented by the electronic device in the various methods of the embodiments of the present application. For the sake of brevity, they will not be repeated here.
[0215] The embodiment of the present application also provides a computer program.
[0216] In some embodiments, the computer program can be applied to the electronic devices in the embodiments of the present application. When the computer program runs on a computer, the computer executes the corresponding processes implemented by the electronic devices in the various methods of the embodiments of the present application. For the sake of brevity, they will not be repeated here.
[0217] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of this application.
[0218] It should be noted that, in this application, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0219] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0220] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0221] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0222] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0223] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.
Claims
1. A training method for a test case generation model, characterized in that: include: Obtain a test case generation model to be trained, wherein the test case generation model to be trained is generated based on a plurality of first decision trees, the plurality of first decision trees correspond to different generation processes of test cases, and each of the first decision trees is constructed based on a plurality of historical test cases under each first eigenvalue; Inputting a first requirement document into the test case generation model to be trained, and selecting one of the historical test cases corresponding to the first requirement document from each of the first feature values in each of the first decision trees to obtain a first test case corresponding to the first requirement document; The first test case is quality evaluated, and the plurality of first decision trees are adjusted based on the first evaluation result, so that the evaluation result obtained based on the adjusted test case generation model satisfies the preset evaluation result to obtain the target test case generation model.
2. The method according to claim 1, characterized in that: The performing quality assessment on the first test case includes: Obtain a target quality assessment model, where the target quality assessment model is generated based on a plurality of second decision trees, where the plurality of second decision trees correspond to different quality assessment dimensions of the test case, and each of the second decision trees is constructed based on the levels of the plurality of historical test cases under each second eigenvalue; Inputting the first test case into the target quality assessment model, and selecting one of the historical test cases corresponding to the first test case under each of the second feature values in each of the second decision trees to obtain a grade under each of the second decision trees corresponding to the first test case; Weighted processing is performed on the levels under each of the second decision trees to obtain the first evaluation result.
3. The method according to claim 2, characterized in that The obtaining of the target quality assessment model comprises: Obtaining a quality assessment model to be trained, and a prediction level under each of the second decision trees corresponding to the second test case; Inputting the second test case into the quality assessment model to be trained, and selecting one of the historical test cases corresponding to the second test case under each of the second feature values in each of the second decision trees to obtain a true grade under each of the second decision trees corresponding to the second test case; Determine a first loss under each of the second decision trees based on the predicted grade under each of the second decision trees and the actual grade under each of the second decision trees; Based on the first loss under each of the second decision trees, multiple second decision trees are adjusted so that the loss obtained based on the adjusted quality assessment model meets the convergence condition to obtain the target quality assessment model.
4. The method according to any one of claims 1 to 3, characterized in that Also includes: Sorting each of the first characteristic values by a decision tree algorithm; Each of the first decision trees is constructed based on the sorted multiple historical test cases under each of the first feature values.
5. The method according to claim 2 or 3, characterized in that: Also includes: Obtaining a plurality of the historical test cases; Extracting key information from a plurality of the historical test cases to obtain candidate feature values; Select characteristic values with associated relationships from the candidate characteristic values to obtain each of the first characteristic values and / or each of the second characteristic values.
6. The method according to claim 5, characterized in that The obtaining of the plurality of historical test cases comprises: Get the test case training set; Selecting candidate historical test cases from the test case training set, and performing at least one of the following operations on the candidate historical test cases to obtain a plurality of the historical test cases: For repeated historical test cases in the candidate historical test cases, retain the most recently created historical test case and delete other historical test cases; Filling missing historical test cases into the candidate historical test cases; Abnormal historical test cases in the candidate historical test cases are deleted, wherein the abnormal historical test cases do not include at least one of the first feature values and / or at least one of the second feature values.
7. The method according to any one of claims 1 to 3, characterized in that The adjusting the plurality of the first decision trees based on the first evaluation result includes at least one of the following: adjusting the quality of a plurality of said historical test cases; Adding a new historical test case to the plurality of historical test cases; Each of the first feature values in each of the first decision trees is adjusted.
8. A test case generation method, characterized in that: include: Obtain a target test case generation model, where the target test case generation model is generated based on a plurality of first decision trees, where the plurality of first decision trees correspond to different generation processes of test cases, and each of the first decision trees is constructed based on a plurality of historical test cases under each first eigenvalue; Input a second requirement document into the target test case generation model, select a historical test case that matches the second requirement document from each of the first feature values in each of the first decision trees, and obtain a third test case corresponding to the second requirement document.
9. A training device for a test case generation model, characterized in that: include: A first acquisition module is used to acquire a test case generation model to be trained, wherein the test case generation model to be trained is generated based on a plurality of first decision trees, the plurality of first decision trees correspond to different generation processes of test cases, and each of the first decision trees is constructed based on a plurality of historical test cases under each first eigenvalue; A first processing module is used to input a first requirement document into the test case generation model to be trained, and select one of the historical test cases corresponding to the first requirement document from each of the first feature values in each of the first decision trees to obtain a first test case corresponding to the first requirement document; An evaluation module, used for performing quality evaluation on the first test case; An adjustment module is used to adjust the plurality of the first decision trees based on the first evaluation result, so that the evaluation result obtained based on the adjusted test case generation model satisfies the preset evaluation result to obtain a target test case generation model.
10. A test case generating device, characterized in that: include: A second acquisition module is used to acquire a target test case generation model, where the target test case generation model is generated based on a plurality of first decision trees, where the plurality of first decision trees correspond to different generation processes of test cases, and each of the first decision trees is constructed based on a plurality of historical test cases under each first eigenvalue; The second processing module is used to input a second requirement document into the target test case generation model, and select a historical test case that matches the second requirement document from each of the first feature values in each of the first decision trees to obtain a third test case corresponding to the second requirement document.
11. An electronic device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store one or more executable instructions, and the executable instructions enable the processor to execute the method according to any one of claims 1 to 7; or, execute the method according to claim 8.
12. A computer-readable storage medium, characterized in that: The computer storage medium stores a computer program, and when the computer program is executed by one or more processors, the method according to any one of claims 1 to 7 is implemented; or the method according to claim 8 is implemented.
Citation Information
Patent Citations
Test case scoring model training method and test case selection method
CN112948274A
Test case recommendation method and device, terminal and storage medium
CN115904920A
Interface test case generation system and interface test case execution method and device
CN117421218A
Optimized test case selection for quality assurance testing of video games
US20200310948A1