Test case generation model training method, test case generation method and device
By constructing a test case generation model based on decision trees, the problem of time-consuming and low-quality manual test case writing is solved, and fast and accurate automatic test case generation is achieved, thus improving the software release speed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2026-03-27
AI Technical Summary
Manually writing test cases is time-consuming and of low quality, which affects the speed of software release. How to quickly and accurately generate test cases automatically is an urgent problem to be solved.
By constructing a test case generation model based on multiple decision trees, inputting a requirements document, selecting historical test cases, conducting quality assessments, and adjusting the decision trees, a target test case generation model that meets the preset assessment results is generated.
It improved the quality and efficiency of test case generation, reduced the time spent manually writing test cases, and increased the speed of software release.
Smart Images

Figure CN119782157B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of automated testing, and in particular to a test case generation model training method, a test case generation method and device. BACKGROUND
[0002] With the continuous expansion of the field of software applications, the scale and complexity of software design are also rising, which leads to that manually writing test cases is very time-consuming and of low quality, thereby prolonging the test cycle and affecting the release speed of software. In order to improve the quality and efficiency of manually writing test cases, the automatic generation of test cases can be realized by introducing automated testing technology. However, how to further quickly and accurately generate test cases is a problem to be solved. SUMMARY
[0003] Therefore, the present application provides a test case generation model training method, a test case generation method and device, which can quickly and accurately generate test cases.
[0004] In a first aspect, the present application provides a test case generation model training method, comprising: obtaining a test case generation model to be trained, the test case generation model to be trained being generated based on a plurality of first decision trees, the plurality of first decision trees corresponding to different generation processes of test cases, and each first decision tree being constructed based on a plurality of historical test cases under each first feature value; inputting a first requirement document into the test case generation model to be trained, selecting 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; performing quality evaluation on the first test case, and adjusting 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 meets a preset evaluation result to obtain a target test case generation model.
[0005] In a second aspect, the present application provides a test case generation method, comprising: obtaining a target test case generation model, the target test case generation model being generated based on a plurality of first decision trees, the plurality of first decision trees corresponding to different generation processes of test cases, and each first decision tree being constructed based on a plurality of historical test cases under each first feature value; inputting a second requirement document into the target test case generation model, selecting a historical test case matched with 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.
[0006] In a third aspect, the present application provides a training device for a test case generation model, comprising: a first obtaining module configured to obtain a test case generation model to be trained, the test case generation model to be trained being generated based on a plurality of first decision trees, the plurality of first decision trees corresponding to different generation processes of test cases, and each first decision tree being constructed based on a plurality of historical test cases at each first feature value; a first processing module configured to input a first requirement document into the test case generation model to be trained, and select one historical test case corresponding to the first requirement document at each first feature value in each first decision tree to obtain a first test case corresponding to the first requirement document; an evaluation module configured to perform quality evaluation on the first test case; and an adjustment module configured to adjust the plurality of first decision trees based on a first evaluation result, so that an evaluation result obtained based on an adjusted test case generation model meets a 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, comprising: a second obtaining module configured to obtain a target test case generation model, the target test case generation model being generated based on a plurality of first decision trees, the plurality of first decision trees corresponding to different generation processes of test cases, and each first decision tree being constructed based on a plurality of historical test cases at each first feature value; and a second processing module configured to input a second requirement document into the target test case generation model, and select one historical test case matching the second requirement document at each first feature 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, the processor, the memory and the communication interface performing communication with each other through the communication bus; and the memory is configured to store one or more executable instructions, the executable instructions causing the processor to execute the method of the first aspect or the second aspect.
[0009] In a sixth aspect, the present application provides a computer readable storage medium, the computer readable storage medium storing a computer program, the computer program being executed by one or more processors to implement the method of the first aspect or the second aspect.
[0010] In a seventh aspect, the present application provides a computer program product, comprising computer program instructions, the computer program instructions causing a computer to execute the method of the first aspect or the second aspect.
[0011] In an eighth aspect, the present application provides a computer program, when the computer program is run on a computer, causing the computer to execute the method of the first aspect or the second aspect.
[0012] The application provides a training method of a test case generation model, which can obtain a test case generation model to be trained; inputs a first requirement document into the test case generation model to be trained, selects 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; performs quality evaluation on the first test case, and adjusts a plurality of first decision trees based on a first evaluation result, so that an evaluation result obtained based on the adjusted test case generation model meets a preset evaluation 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 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 DRAWINGS
[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments described in the embodiments of the present application, and other drawings can also be obtained by those skilled in the art based on these drawings.
[0014] Figure 1 is a flowchart of a training method of a test case generation model provided by the embodiments of the present application;
[0015] Figure 2 is a flowchart of obtaining each first feature value provided by the embodiments of the present application;
[0016] Figure 3 is a flowchart of generating a test case generation model provided by the embodiments of the present application;
[0017] Figure 4 is a flowchart of generating a quality evaluation model provided by the embodiments of the present application;
[0018] Figure 5 is a flowchart of a test case generation method provided by the embodiments of the present application;
[0019] Figure 6 is a detailed flowchart of a training method of a test case generation model provided by the embodiments of the present application;
[0020] Figure 7 is a component structure diagram of a training device of a test case generation model provided by the embodiments of the present application;
[0021] Figure 8 is a component structure diagram of a test case generation device provided by the embodiments of the present application;
[0022] Figure 9 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order for 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 with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the embodiments of the present application, all other embodiments obtained by those skilled in the art should belong to the scope of protection of the present application.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.
[0025] In the following description, "some embodiments" are related to a subset of all possible embodiments, but it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0026] It should also be noted that the terms "first", "second", "third" in the embodiments of the present application are only used to distinguish similar objects, and do not represent a specific order of the objects. It can be understood that "first", "second", "third" can be interchanged in a specific order or sequence as allowed, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0027] In addition, the term "and / or" in the embodiments of the present application is only a description of the association relationship between the associated objects, which means that there can be three relationships, for example, A and / or B can represent the existence of A alone, the existence of A and B together, and the existence of B alone. In addition, the character " / " in this paper generally represents an "or" relationship between the associated objects before and after it.
[0028] In order to facilitate the understanding of the technical solutions of the embodiments of the present application, the related technologies of the embodiments of the present application are described below. The following related technologies can be combined with the technical solutions of the embodiments of the present application in any way, and all belong to the protection scope of the embodiments of the present application.
[0029] A test case is a basic unit in software testing, which describes the conditions, steps, expected results and actual results of executing the test in detail. The test case is a key tool to ensure software quality, and through the test case, it can be verified whether the software works as expected and whether it meets the requirement specification. Further, based on the function description, business rules, user scenarios and other information in the requirement document, corresponding test cases can be designed. The test cases can cover all key points and boundary conditions in the requirement document to ensure a more comprehensive test of the software.
[0030] With the rapid progress of technology and the continuous expansion of software application fields, the scale of software design is increasingly large, and its complexity also rises sharply, which leads to a very time-consuming and low-quality manual test case writing, thereby prolonging the test cycle and affecting the release speed of the software. In order to improve the quality and efficiency of manually written test cases, automatic test technology can be introduced to realize the automatic generation of test cases. However, how to further quickly and accurately generate test cases is a problem to be solved.
[0031] Based on this, the embodiments of the present application provide a training method of 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, 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 quality evaluation on the first test case, and adjust a 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 meets a preset evaluation 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 test case can be automatically generated by using the target test case generation model, thereby improving the quality and efficiency of generating test cases.
[0032] In order to facilitate the 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 with the technical solutions of the embodiments of the present application as optional solutions, which 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 flowchart of a training method of a test case generation model provided by the embodiments of the present application, as shown in Figure 1 The method can include the following steps.
[0034] S110, acquire a test case generation model to be trained, 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 first decision tree is constructed based on a plurality of historical test cases under each first feature value.
[0035] It should be noted that in the embodiments of the present application, the test case generation model training method can be applied to a test case generation model training device, or an electronic device integrated with the device. The electronic device can be implemented in various forms, for example, the electronic device can include a vehicle, a smart phone, a tablet computer, a notebook computer, a palm computer, a personal digital assistant (PDA), a portable media player (PMP), etc., which are not limited here.
[0036] It should be noted that each first feature value can be key information in the plurality of historical test cases, or a feature value constructed based on the key information in the plurality of historical test cases, which is not limited in the embodiments of the present application.
[0037] Exemplarily, the plurality of first feature values can include a function module, a function point, a test method, a pre-parameter, an intermediate step, an expected result, etc., which are not limited in the embodiments of the present application.
[0038] Among them, the function module is mainly the sub-function of each system, such as the sub-function of dynamic data acquisition system including basic data management, signal pool management, acquisition task management, business monitoring statistics; the function point contains the addition, deletion, editing, query of each sub-function; the test method can be understood as the idea of writing test cases, including equivalence class, boundary value, decision table, orthogonal array, etc.; the pre-parameter, the intermediate step and the expected result are the components of the test case.
[0039] Exemplarily, the different generation processes of test cases can include preconditions, intermediate processes, expected results, etc. for generating test cases, which are not limited in the embodiments of the present application.
[0040] Exemplarily, the first decision tree based on the precondition can be constructed based on the plurality of first characteristic values: the plurality of historical test cases under each first characteristic value of the function module, the function point, the test method, the precondition parameter, the intermediate step, and the expected result; the first decision tree based on the intermediate process can be constructed based on the plurality of first characteristic values: the plurality of historical test cases under each first characteristic value of the function module, the function point, the test method, the precondition parameter, the intermediate step, and the expected result; and the first decision tree based on the expected result can be constructed based on the plurality of first characteristic values: the plurality of historical test cases under each first characteristic value of the function module, the function point, the test method, the precondition parameter, the intermediate step, and the expected result.
[0041] It should be noted that, taking one first characteristic value and one historical test case as an example, the plurality of historical test cases under each first characteristic value can be understood as at least part of the historical test cases in the one historical test case corresponding to the one first characteristic value. Exemplarily, taking the function module as the first characteristic value, one historical test case under the function module can be understood as at least part of the historical test cases in the one historical test case corresponding to the function module.
[0042] Figure 2 is a flowchart of a process for obtaining each first characteristic value provided by the embodiment of the present application, as shown in Figure 2 The method can include the following steps:
[0043] S210, obtaining a plurality of historical test cases;
[0044] S220, extracting key information from the plurality of historical test cases to obtain candidate characteristic values;
[0045] S230, selecting characteristic values having a correlation relationship from the candidate characteristic values to obtain each first characteristic value.
[0046] It should be noted that the candidate characteristic values can be key information in the plurality of historical test cases, or can be characteristic values constructed based on the key information in the plurality of historical test cases, and the embodiment of the present application does not limit this.
[0047] It should also be noted that the number of candidate characteristic values can be one or a plurality, and the embodiment of the present application does not limit this.
[0048] Exemplarily, the plurality of first characteristic values can include the function module, the function point, and the test method, and the internal relationship between each first characteristic value can be: what function point corresponds to a certain function module, and what unified test method.
[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 here.
[0050] By this method, by selecting the feature values with the association relationship from the alternative feature values as each first feature value, the redundant and irrelevant feature values can be removed, thereby the structure of the test case generation model can be simplified, and the generation result of the test case generation model is more accurate.
[0051] In some embodiments, obtaining the plurality of historical test cases can comprise: obtaining a test case training set; selecting alternative historical test cases from the test case training set, and performing at least one of the following operations on the alternative historical test cases to obtain the plurality of historical test cases:
[0052] For the repeated historical test cases in the alternative historical test cases, the latest created historical test case is retained, and the other historical test cases are deleted;
[0053] The missing historical test cases are filled into the alternative historical test cases;
[0054] The abnormal historical test cases in the alternative historical test cases are deleted, wherein the abnormal historical test cases do not include at least one first feature value (and / or at least one second feature value in the following embodiments).
[0055] It should be noted that the test case training set can include: test cases (such as alternative historical test cases, and / or second test cases), requirement documents (such as first requirement documents, and / or second requirement documents), execution results, code change records, defect reports, and other related software testing data.
[0056] Exemplarily, the abnormal historical test cases in the alternative historical test cases can be captured by a box plot visualization method.
[0057] It should be noted that for the repeated historical test cases, by retaining the latest created historical test case and deleting the other historical test cases, the redundancy of the historical test cases can be avoided, and the plurality of historical test cases obtained are more accurate.
[0058] It should be further noted that by filling the missing historical test cases into the alternative historical test cases, the plurality of historical test cases obtained can be more complete.
[0059] It should be further noted that by deleting the abnormal historical test cases in the alternative historical test cases, the quality of the plurality of historical test cases obtained can be improved.
[0060] Through the method, through performing the at least one operation on the candidate historical test cases, the obtained multiple historical test cases can be more refined and accurate, and can be more effectively used for training of a subsequent test case generation model and training of a quality evaluation model, thereby improving efficiency of subsequent model training and reducing unnecessary resource consumption.
[0061] In some embodiments, the method can further include: sorting each first feature value by a decision tree algorithm; and constructing each first decision tree based on the multiple historical test cases under each sorted first feature value.
[0062] Exemplarily, the decision tree algorithm can be a Constrained Resource Allocation Tree (CRAT) algorithm, or can be another algorithm, which is not limited in the embodiments of the present application.
[0063] It should be noted that each first feature value can be sorted based on an influence degree of the first feature value on a generation result of the test case generation model. Exemplarily, a first feature value with a greater influence degree on the generation result can be arranged in the front row, and a first feature value with a smaller influence degree on the generation result can be arranged in the back row.
[0064] Through the method, based on the multiple historical test cases under each sorted first feature value, each first decision tree can be constructed, so that in the process of training the test case generation model generated by the multiple first decision trees, more attention can be paid to the first feature value that has an important influence on the generation result, thereby improving accuracy of the generation result of the test case generation model, and improving generalization ability of the test case generation model.
[0065] Exemplarily, Figure 3 is a flowchart of a method for generating a test case generation model provided by the embodiments of the present application. As shown in Figure 3 the method can include the following steps:
[0066] S310, three first feature values: function points, function modules, and test methods are obtained;
[0067] S320, the three first feature values are sorted based on a CRAT algorithm, and the sorted three first feature values: function modules, function points, and test methods are obtained;
[0068] S330, a first decision tree based on a precondition is constructed based on the multiple historical test cases under each first feature value;
[0069] S340, a first decision tree based on an intermediate process is constructed based on the multiple historical test cases under each first feature value;
[0070] S350, constructing a first decision tree based on expected results based on the plurality of historical test cases under each first feature value;
[0071] S360, generating 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 functional points, functional modules and test methods can be taken as three first feature values based on the internal relationship between the functional points, functional modules and test methods, such as a certain functional module corresponding to what functional point, what unified test method.
[0073] It can also be understood that the three first feature values are sorted based on the CRAT algorithm, which can make the functional module with a greater degree of influence on the generation result of the test case generation model be arranged in the first place, and the test method with a smaller degree of influence on the generation result of the test case generation model be arranged in the third place.
[0074] It can also be understood that the first decision tree based on preconditions, intermediate processes and expected results is obtained based on the plurality of historical test cases under each first feature value. In this way, the three first decision trees are distinguished from different generation processes of test cases, and each first decision tree represents a generation process of test cases, 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, thereby improving the accuracy of the generation result of the subsequent test case generation model.
[0075] Through the method, the preconditions, intermediate processes and expected results in the test case generation model can cover a plurality of historical test cases, thereby improving the generalization ability of the test case generation model.
[0076] S120, inputting the 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 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 one first decision tree as an example, the historical test case corresponding to the first requirement document under different first feature values can be the same or different, and the embodiments of the present application do not limit this.
[0078] It should be further noted that the first test case can be considered as being obtained by selecting a historical test case corresponding to the first requirement document from each first feature value in each first decision tree and combining all the selected historical test cases. Further, the historical test case selected from a first feature value can be a complete historical test case or a part of a complete historical test case corresponding to the first feature value, and the embodiments of the present application do not limit this.
[0079] Exemplarily, it is assumed that the plurality of first decision trees are a precondition-based first decision tree, an intermediate process-based first decision tree, and an expected result-based first decision tree, and the plurality of first feature values are function modules and function points. In the precondition-based first decision tree, a historical test case corresponding to the first requirement document can be selected from a function module, and a historical test case corresponding to the first requirement document can be selected from a function point. In the intermediate process-based first decision tree, a historical test case corresponding to the first requirement document can be selected from a function module, and a historical test case corresponding to the first requirement document can be selected from a function point. In the expected result-based first decision tree, a historical test case corresponding to the first requirement document can be selected from a function module, and a historical test case corresponding to the first requirement document can be selected from a function point. The plurality of historical test cases selected above can be combined to obtain a first test case corresponding to the first requirement document.
[0080] It can be understood that the first test case can be considered as an output of a to-be-trained test case generation model, and the first test case can be automatically generated by the to-be-trained test case generation model.
[0081] In S130, quality evaluation is performed on the first test case to obtain a first evaluation result.
[0082] It can be understood that the implementation manner of performing quality evaluation on the first test case can be as follows:
[0083] In one possible implementation manner, a mapping relationship between test cases and evaluation results is established, and based on the first test case and the mapping relationship, the first evaluation result can be obtained.
[0084] It should be noted that the mapping relationship can be established based on an experience rule, can be established artificially, or can be established through other manners, and the embodiments of the present application do not limit this.
[0085] It should be further noted that the first test case can be substituted into the mapping relationship, so that the first evaluation result corresponding to the first mapping relationship can be obtained.
[0086] Based on the implementation mode, the first evaluation result corresponding to the first test case can be quickly obtained by establishing the mapping relationship, so as to improve the efficiency of training the model based on the first evaluation result for the test case.
[0087] In another possible implementation mode, the quality evaluation of the first test case can include: obtaining a target quality evaluation model, the target quality evaluation model being generated based on a plurality of second decision trees, the plurality of second decision trees corresponding to different quality evaluation dimensions of the test case, and each second decision tree being constructed based on the grades of a plurality of historical test cases under each second feature value; inputting the first test case into the target quality evaluation model, selecting a historical test case corresponding to the first test case from each second feature value in each second decision tree, to obtain the grade of the first test case under each second decision tree; and performing weighted processing on the grade under each second decision tree to obtain the first evaluation result.
[0088] It should be noted that each second feature value can be key information in the plurality of historical test cases, or can be a feature value constructed based on the key information in the plurality of historical test cases, and the embodiments of the present application are not limited thereto.
[0089] It should be further noted that the grades of the plurality of historical test cases under each second feature value can be set based on an experience rule, or can be set artificially, and the embodiments of the present application are not limited thereto. For example, the grade of each historical test case can include excellent, good, medium, and poor.
[0090] For example, the different quality evaluation dimensions of the test case can include readability evaluation dimension, integrity evaluation dimension, consistency evaluation dimension, repeatability evaluation dimension, independence evaluation dimension, exception handling capability evaluation dimension, robustness evaluation dimension, and maintainability evaluation dimension, and the like, and the embodiments of the present application are not limited thereto.
[0091] For example, the second decision tree based on readability can be constructed based on the grades of the plurality of historical test cases under each second feature value in the aspects of sentence fluency, no misspelling, simplicity, and easy-to-understand description.
[0092] It can be understood that the method of obtaining each second feature value is similar to the method of obtaining each first feature value shown in the above embodiment, and will not be repeated here. Figure 2
[0093] In some embodiments, the method can further include: sorting each second feature value by a decision tree algorithm; and constructing each second decision tree based on the grades of the plurality of historical test cases under the sorted each second feature value.
[0094] Exemplarily, the decision tree algorithm can be a CRAT algorithm, or can be another algorithm, and the embodiments of the present application do not limit this.
[0095] It should be noted that each second feature value can be sorted based on the influence degree of the output result of the quality evaluation model. Exemplarily, the second feature value with a greater influence degree on the output result can be arranged in the front row, and the second feature value with a smaller influence degree on the output result can be arranged in the back row.
[0096] Through the method, each second decision tree is constructed based on the levels of the multiple historical test cases under each sorted second feature value, so that after the multiple second decision trees are used to generate the quality evaluation model, more attention is paid to the second feature value that has an important influence on the output result of the quality evaluation model, thereby improving the accuracy of the output result of the quality evaluation model, and improving the generalization ability of the quality evaluation model.
[0097] Exemplarily, Figure 4 is a flowchart of a method for generating a quality evaluation model provided by an embodiment of the present application. As Figure 4 shown, the method can include the following steps:
[0098] S410, obtaining multiple second feature values: no error, correct grammar, easy to understand, logical coherence, comprehensive information, and rich details;
[0099] S420, sorting no error, correct grammar, and easy to understand based on the CRAT algorithm, to obtain three sorted second feature values: correct grammar, no error, and easy to understand;
[0100] S430, sorting logical coherence, comprehensive information, and rich details based on the CRAT algorithm, to obtain three sorted second feature values: comprehensive information, logical coherence, and rich details;
[0101] S440, constructing a second decision tree based on readability based on the levels of the multiple historical test cases under each second feature value in correct grammar, no error, and easy to understand;
[0102] S450, constructing a second decision tree based on integrity based on the levels of the multiple historical test cases under each second feature value in comprehensive information, logical coherence, and rich details;
[0103] S460, generating a quality evaluation model based on the second decision trees based on readability and integrity.
[0104] It can be understood that the fluent sentence, no misprints and easy-to-understand description can be taken as three second characteristic values based on the internal relationship among the fluent sentence, no misprints and easy-to-understand description, such as whether there are misprints in the fluent sentence, whether the description is clear.
[0105] It can also be understood that the CRAT algorithm is used to sort the plurality of second characteristic values, so that the second characteristic value with a greater influence on the output result of the quality evaluation model is ranked first, and the characteristic value with a smaller influence on the output result of the quality evaluation model is ranked last.
[0106] It can also be understood that the second decision tree based on readability and the second decision tree based on completeness are obtained respectively based on the grades of the plurality of historical test cases under each first characteristic value. In this way, the two second decision trees are distinguished from each other in different quality evaluation dimensions of the test case, each second decision tree represents a quality evaluation dimension of the test case, so that each second decision tree has a clear division of labor, and each second decision tree covers a large number of grades of historical test cases, thereby improving the accuracy of the output result of the subsequent quality evaluation model.
[0107] Through the method, the two quality evaluation dimensions of readability and completeness in the quality evaluation model can cover the grades of a plurality of historical test cases, thereby improving the generalization ability of the quality evaluation model.
[0108] It should be noted that, taking one second decision tree as an example, the historical test case corresponding to the first test case under different second characteristic values can be the same or different, and in the case that the historical test case is the same, the grade of the historical test case under different second characteristic values can be the same or different, which is not limited in the embodiments of the present application.
[0109] It should also be noted that, taking one second decision tree as an example, the grade of each second decision tree corresponding to the first test case can be understood as, in one second decision tree, the grade of the historical test case selected under each second characteristic value is used to determine the grade of the second decision tree corresponding to the first test case.
[0110] Exemplarily, in one second decision tree of readability, the grade of the historical test case selected under the fluent sentence is excellent, the grade of the historical test case selected under no misprints is excellent, and the grade of the historical test case selected under easy-to-understand description is good, so the grade of the second decision tree of readability corresponding to the first test case is excellent.
[0111] It can be understood that the historical test case selected under each second feature value can be considered as the historical test case closest to the content of the first test case, and at this time, the grade of the historical test case under each second feature value can be used as the grade of the first test case under each second feature value.
[0112] It can also be understood that the grade of each second decision tree corresponding to the first test case can be considered as the output of the target quality evaluation model, and the grade of each second decision tree corresponding to the first test case can be automatically generated through the target quality evaluation model.
[0113] In some embodiments, the weighting processing of the grade under each second decision tree to obtain the first evaluation result can include: determining a weight value of the grade under each second decision tree; and performing weighting processing on the grade under each second decision tree based on the weight value of the grade under each second decision tree to obtain the first evaluation result.
[0114] For example, the weight value of the grade under the second decision tree based on readability is 0.4, the weight value of the grade under the second decision tree based on integrity is 0.6, and 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 weight values of the grades under the second decision trees based on readability and integrity, the first evaluation result corresponding to the first test case can be obtained.
[0115] Through this method, by performing weighting processing on the grade under each second decision tree, the accuracy and reliability of the obtained first evaluation result can be improved.
[0116] In some embodiments, obtaining the target quality evaluation model can include: obtaining a quality evaluation model to be trained and a predicted grade under each second decision tree corresponding to the second test case; inputting the second test case into the quality evaluation model to be trained, selecting a historical test case corresponding to the second test case from each second feature value in each second decision tree to obtain a real 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 real grade under each second decision tree; and adjusting the plurality of second decision trees based on the first loss under each second decision tree, so that the loss obtained based on the adjusted quality evaluation model satisfies a convergence condition to obtain the target quality evaluation model.
[0117] It should be noted that the convergence condition can be that the training of the quality evaluation model reaches a preset number of times, or that the loss is in a preset range. The preset number of times and the preset range can be appropriately set by those skilled in the art according to actual conditions, and the embodiments of the present application are not limited in this regard.
[0118] By the method, the accuracy of the output result of the target quality evaluation model trained can be improved, and the generalization ability of the target quality evaluation model is further improved.
[0119] In some embodiments, adjusting the plurality of second decision trees based on the first loss under each second decision tree can include at least one of:
[0120] adjusting the quality of the plurality of historical test cases;
[0121] adding new historical test cases to the plurality of historical test cases;
[0122] adjusting each second feature value in each second decision tree.
[0123] It should be noted that adjusting the quality of the plurality of historical test cases can include: for repeated historical test cases in the plurality of historical test cases, retaining the latest created historical test case and deleting other historical test cases; and / or, deleting abnormal historical test cases in the plurality of historical test cases, wherein the abnormal historical test cases do not include at least one second feature value.
[0124] It should also be noted that adjusting each second feature value in each second decision tree can include: deleting at least part of the second feature values in at least part of the second decision trees; and / or, adding new second feature values to at least part of the second decision trees.
[0125] By the method, adjusting the plurality of second decision trees based on the first loss under each second decision tree can speed up the training speed of the quality evaluation model, so that the quality evaluation model can reach a convergence state faster and more effectively improve the output accuracy of the quality evaluation model.
[0126] Based on the implementation, the quality of the first test case is evaluated by the target quality evaluation model, which can make the obtained first evaluation result more accurate, thereby improving the training accuracy of the subsequent test case generation model based on the first evaluation result.
[0127] S140, adjusting 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 meets the preset evaluation result to obtain a target test case generation model.
[0128] It should be noted that the preset evaluation result can be appropriately set by those skilled in the art according to actual conditions, and the embodiments of the present application are not limited thereto.
[0129] In some embodiments, adjusting the plurality of first decision trees based on the first evaluation result can include at least one of:
[0130] adjusting the quality of the plurality of historical test cases;
[0131] adding a new historical test case to the plurality of historical test cases;
[0132] adjusting each first feature value in each first decision tree.
[0133] It should be noted that adjusting each first feature value in each first decision tree can include: deleting at least part of the at least part of the first feature values in the first decision tree; and / or adding new first feature values to the at least part of the first decision tree.
[0134] Through the method, adjusting the plurality of first decision trees based on the first evaluation result can accelerate the training speed of the test case generation model, so that the test case generation model can reach a convergent state faster, and more effectively improve the output accuracy of the test case generation model.
[0135] The embodiment of the present application provides a test case generation model training method, 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, 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 quality evaluation on the first test case, and 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 meets a preset evaluation 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 test case can be automatically generated by using the target test case generation model, thereby improving the quality and efficiency of generating test cases.
[0136] In the embodiment of the present application, the test case generation model is trained by the technical solution shown in Figures 1 to 4 It can be understood that based on the trained target test case generation model, the test case can be automatically generated. The process of automatically generating the test case by the target test case generation model will be described below. Figure 5
[0137] Figure 5 is a flowchart of a test case generation method provided by the embodiment of the present application, as shown in Figure 5 The method can include the following steps:
[0138] S510, acquire a target test case generation model, the target test case generation model 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 first decision tree is constructed based on a plurality of historical test cases under each first feature value;
[0139] S520, input the second requirement document into the target test case generation model, select one historical test case corresponding to 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, assuming that the plurality of first decision trees are first decision trees based on preconditions, first decision trees based on intermediate processes, and first decision trees based on expected results, and the plurality of first feature values are function modules and function points. In the first decision tree based on preconditions, one historical test case corresponding to the second requirement document can be selected from the function module, and one historical test case corresponding to the second requirement document can be selected from the function point; in the first decision tree based on intermediate processes, one historical test case corresponding to the second requirement document can be selected from the function module, and one historical test case corresponding to the second requirement document can be selected from the function point; in the first decision tree based on expected results, one historical test case corresponding to the second requirement document can be selected from the function module, and one historical test case corresponding to the second requirement document can be selected from the function point. The plurality of historical test cases selected above are combined to obtain the third test case corresponding to the second requirement document.
[0141] It should be noted that the structure of the target test case generation model can be referred to the structure of the test case generation model to be trained in the foregoing embodiments, and the present embodiment will not be described again.
[0142] The embodiment of the present application provides a test case generation method, which can automatically generate test cases by 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 of manually writing test cases by testers is reduced, so that the testers can devote more energy to the execution of valuable test cases and the analysis of the execution results.
[0143] The training method of the test case generation model provided in the foregoing embodiments will be described in detail in combination with specific application scenarios.
[0144] Figure 6 is a detailed flowchart of the training method of the test case generation model provided by the embodiment of the present application, as Figure 6 shown, the method can include the following steps.
[0145] S601, acquire a test case training set.
[0146] It should be noted that the test case training set can include test cases (such as second test cases), requirement documents (such as first requirement documents), execution results, code change records, defect reports, and other related software testing data.
[0147] S602, obtain a plurality of first feature values and a plurality of second feature values from the test case training set.
[0148] It should be noted that the candidate historical test cases can be selected from the test case training set, and operations such as deletion and filling can be performed on the candidate historical test cases to obtain a plurality of historical test cases; the plurality of first feature values and the plurality of second feature values having the association relationship can be extracted from the plurality of historical test cases.
[0149] S603, obtain a test case generation model to be trained based on the plurality of first feature values.
[0150] It should be noted that a plurality of first decision trees can be constructed based on the plurality of historical test cases under each first feature value, and the plurality of first decision trees correspond to different generation processes of test cases; and the test case generation model to be trained is generated based on the plurality of first decision trees.
[0151] S604, input the first requirement document into the test case generation model to be trained to obtain a first test case.
[0152] It should be noted that one historical test case corresponding to the first requirement document can be selected from each first feature 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 evaluation model to be trained based on the plurality of second feature values.
[0154] It should be noted that a plurality of second decision trees can be constructed based on the levels of the plurality of historical test cases under each second feature value, and the plurality of second decision trees correspond to different quality evaluation dimensions of test cases; and the quality evaluation model to be trained is generated based on the plurality of second decision trees.
[0155] S606, input the second test case into the quality evaluation model to be trained to obtain a real level under each second decision tree corresponding to the second test case.
[0156] It should be noted that, based on the level of the selected historical test case, the true level of the second test case corresponding to each second decision tree can be obtained.
[0157] S607, based on the true level under each second decision tree, it is judged whether the loss meets the convergence condition.
[0158] It should be noted that, based on the predicted level under each second decision tree and the true level under each second decision tree, the loss (i.e. first loss) under each second decision tree can be determined; whether the first loss meets the convergence condition (such as whether the loss is within a preset range).
[0159] It should be further noted that, in the case that the loss meets the convergence condition, the trained target quality evaluation model can be deployed online, i.e. S608 is executed; in the case that the loss does not meet the convergence condition, the plurality of second decision trees can be adjusted based on the loss to obtain a target quality evaluation model based on the adjusted quality evaluation model whose loss meets the convergence condition, i.e. S609 is executed.
[0160] S608, deploying the target quality evaluation model online.
[0161] At this time, the target quality evaluation model is a trained quality evaluation model.
[0162] S609, adjusting the plurality of second decision trees based on the loss.
[0163] It should be noted that the plurality of second decision trees can be adjusted by at least one of the following: adjusting the quality of the plurality of historical test cases; adding new historical test cases to the plurality of historical test cases; adjusting each second feature value in each second decision tree.
[0164] It should be further noted that, after adjusting the plurality of second decision trees, the adjusted quality evaluation model needs to be trained again, i.e. S606 and S607 are executed again (at this time, new test cases can be input), until the loss of the adjusted quality evaluation model meets the convergence condition to obtain the target quality evaluation model.
[0165] S610, performing quality evaluation on the first test case by the target quality evaluation model to obtain a first evaluation result.
[0166] It should be noted that the first test case can be input into the target quality evaluation model, and a historical test case corresponding to the first test case is selected from each second feature value in each second decision tree to obtain a level of each second decision tree corresponding to the first test case; and the level of each second decision tree is weighted to obtain a first evaluation result.
[0167] S611, determining whether the first evaluation result meets a preset evaluation result.
[0168] It should be noted that in the case that 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; and in the case that the first evaluation result does not meet the preset evaluation result, the plurality of 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 to obtain the target test case generation model, that is, S613 is executed.
[0169] S612, deploying the target test case generation model online.
[0170] At this time, the target test case generation model is a trained test case generation model.
[0171] S613, adjusting the plurality of first decision trees based on the first evaluation result.
[0172] It should be noted that the plurality of first decision trees can be adjusted by at least one of the following: adjusting the quality of the plurality of historical test cases; adding new historical test cases to the plurality of historical test cases; and adjusting each feature value in each first decision tree.
[0173] It should be further noted that after the plurality of first decision trees are adjusted, the adjusted test case generation model needs to be trained again, that is, S604, S610 and S611 are executed again (at this time, a new requirement document can be input), until 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.
[0174] The embodiment of the present application provides a training method of a test case generation model, and the target test case generation model can be obtained by training the test case generation model to be trained, and the test case can be automatically generated by using the target test case generation model, so that the quality and efficiency of generating the test case are improved.
[0175] The preferred embodiments of the present application are described in detail above with reference to the drawings, but the present application is not limited to the specific details of the above-described embodiments. Within the technical concept of the present application, various simple modifications can be made to the technical solutions of the present application, and these simple modifications all belong to the protection scope of the present application. For example, in the above-described specific embodiments, various specific technical features described in the embodiments can be combined in any appropriate manner without contradiction. In order to avoid unnecessary repetition, various possible combination manners are not described again in the present application. For another example, various different embodiments of the present application can also be combined in any manner, as long as it does not deviate from the idea of the present application, and it should also be considered as disclosed in the present application. For another example, under the premise of no conflict, each embodiment described in the present application and / or technical features in each embodiment can be combined with any prior art, and the technical solutions obtained after combination should also fall within the protection scope of the present application.
[0176] It should also be understood that, in various method embodiments of the present application, the size of the sequence number of the above-described processes does not mean the order of execution, and the execution order of the processes should be determined according to its function and inherent 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 foregoing embodiments, Figure 7 is a component structure schematic diagram of a training device for a test case generation model provided by an embodiment of the present application, as Figure 7 shown, the training device 700 for the test case generation model can include a first acquisition module 710, a first processing module 720, an evaluation module 730, and an adjustment module 740, wherein:
[0178] The first acquisition module 710 is configured to acquire a test case generation model to be trained, 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 first decision tree is constructed based on a plurality of historical test cases under each first feature value;
[0179] The first processing module 720 is configured 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] The evaluation module 730 is configured to perform quality evaluation on the first test case;
[0181] The adjustment module 740 is configured to adjust the plurality of first decision trees based on the first evaluation result, so that an evaluation result obtained based on an adjusted test case generation model satisfies a preset evaluation result to obtain a target test case generation model.
[0182] In some embodiments, the first acquisition module 710 is further configured to acquire a target quality assessment model, which is generated based on multiple second decision trees. The multiple second decision trees correspond to different quality assessment dimensions of test cases, and each second decision tree is constructed based on the levels of multiple historical test cases under each second feature value. The first processing module 720 is further configured to input a first test case into the target quality assessment model, select a historical test case corresponding to the first test case from each second feature value in each second decision tree to obtain the level under each second decision tree corresponding to the first test case, and perform weighted processing on the levels under each second decision tree to obtain a first evaluation result.
[0183] In some embodiments, such as 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 configured to acquire the quality assessment model to be trained, and the predicted level under each second decision tree corresponding to the second test case; the first processing module 720 is further configured 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 true level under each second decision tree corresponding to the second test case.
[0185] Module 750 is used to determine the first loss under each second decision tree based on the predicted level and the true level under each second decision tree.
[0186] The adjustment module 740 is also used to adjust 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 satisfies the convergence condition to obtain the target quality assessment model.
[0187] In some embodiments, such as 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] The sorting module 760 is used to sort each first feature value using a decision tree algorithm;
[0189] Module 770 is used to construct each first decision tree based on multiple historical test cases under each sorted first feature value.
[0190] In some embodiments, such as 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 obtaining module 710 is further configured to obtain a plurality of historical test cases.
[0192] The extracting module 780 is configured to perform key information extraction on the plurality of historical test cases to obtain candidate feature values, and select feature values having a correlation relationship from the candidate feature values to obtain each first feature value and / or each second feature value.
[0193] In some embodiments, the first obtaining module 710 is further configured to obtain a test case training set; and the first processing module 720 is further configured to select candidate historical test cases from the test case training set, and perform at least one of the following operations on the candidate historical test cases to obtain the plurality of historical test cases: for historical test cases that are repeated in the candidate historical test cases, retaining a latest created historical test case and deleting other historical test cases; filling in missing historical test cases in the candidate historical test cases; and deleting abnormal historical test cases in the candidate 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 adjusting module 740 is further configured to adjust the quality of the plurality of historical test cases, add new historical test cases to the plurality of historical test cases, and adjust each first feature value in each first decision tree.
[0195] In the scheme of the embodiments of the present application, the target test case generation model can be obtained by training the test case generation model to be trained, and the test case generation model can be used to automatically generate test cases, thereby improving the quality and efficiency of generating test cases.
[0196] Those skilled in the art should understand that the above description of the training device of the test case generation model of the embodiments of the present application can be understood with reference to the description of the training method of the test case generation model of the embodiments of the present application.
[0197] Based on the same inventive concept as the foregoing embodiments, Figure 8 is a constituent structure schematic diagram of a test case generation device provided by the embodiments of the present application, as Figure 8 shown, the test case generation device 800 can include a second obtaining module 810 and a second processing module 820, wherein:
[0198] The second obtaining module 810 is configured to obtain a target test case generation model, the target test case generation model being generated based on a plurality of first decision trees, the plurality of first decision trees corresponding to different generation processes of test cases, and each first decision tree being constructed based on a plurality of historical test cases under each first feature value.
[0199] The second processing module 820 is configured to input a 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 scheme of the embodiments 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 of manually writing test cases by testers is reduced, so that the testers can devote more energy to the execution of valuable test cases and the analysis of the execution results.
[0201] Those skilled in the art should understand that the above description of the test case generation apparatus of the embodiments of the present application can be understood with reference to the description of the test case generation method of the embodiments of the present application.
[0202] Figure 9 is a structural schematic diagram of an electronic device provided by the embodiments of the present application. The electronic device 900 can include a processor (Processor) 910, a communications interface (Communications Interface) 920, a memory (Memory) 930 storing a program 950, and a communications bus 940.
[0203] The processor 910, the communications interface 920, and the memory 930 complete mutual communication through the communications bus 940.
[0204] The communications interface 920 is configured to communicate with other electronic devices or servers.
[0205] The processor 910 is configured to execute the program 950, and specifically can execute the related steps in the above method embodiments.
[0206] Specifically, the program 950 can include program code, which includes one or more executable computer operation instructions.
[0207] The processor 910 can 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. One or more processors included in the smart device can be the same type of processor, such as one or more CPUs; or can be different types of processors, such as one or more CPUs and one or more ASICs.
[0208] The memory 930 is configured to store one or more executable instructions. The memory 930 can include a random access memory (RAM) and can further include a non-volatile memory, such as one or more disk storage devices.
[0209] The one or more executable instructions can be specifically configured to enable the processor 910 to perform the method provided by the embodiments of the present application.
[0210] In addition, the specific implementation of each step in the one or more executable instructions can refer to the corresponding description in the corresponding steps and units in the method embodiments described above, and will not be described herein. It can be clearly understood by those skilled in the art that, for the convenience and brevity of description, the specific working process of the device and the module described above can refer to the corresponding process description in the foregoing method embodiments, and will not be described herein.
[0211] The embodiments of the present application further provide 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 the computer program is executed by one or more processors to realize the corresponding processes realized by the electronic device in each method of the embodiments of the present application. For the sake of brevity, it will not be described herein.
[0213] The embodiments of the present application further provide 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 perform the corresponding processes realized by the electronic device in each method of the embodiments of the present application. For the sake of brevity, it will not be described herein.
[0215] The embodiments of the present application further provide a computer program.
[0216] In some embodiments, the computer program can be applied to the electronic device in the embodiments of the present application, and when the computer program runs on the computer, the computer performs the corresponding processes realized by the electronic device in each method of the embodiments of the present application. For the sake of brevity, it will not be described herein.
[0217] Those skilled in the art can appreciate that units and method steps of each example described in combination with the embodiments disclosed in the present application can be realized by electronic hardware, or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of the present application.
[0218] It should be noted that in the present application, the terms "comprising", "containing" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0219] The above-mentioned serial numbers of the embodiments of the present application are only for description, not representing the advantages and disadvantages of the embodiments.
[0220] The methods disclosed in the several method embodiments provided by the present application can be combined arbitrarily without conflict, to obtain new method embodiments.
[0221] The features disclosed in the several product embodiments provided by the present application can be combined arbitrarily without conflict, to obtain new product embodiments.
[0222] The features disclosed in the several method or device embodiments provided by the present application can be combined arbitrarily without conflict, to obtain new method or device embodiments.
[0223] The above-mentioned embodiments are only used for describing the embodiments of the present application, not limiting the embodiments of the present application. Those skilled in the art 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 belong to the scope of the embodiments of the present application, and the patent protection scope of the embodiments of the present application should be defined by the claims.
Claims
1. A training method of a test case generation model, characterized by, The method comprises the following steps: obtaining 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 feature value; 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 first feature value in each of the first decision trees to obtain a first test case corresponding to the first requirement document; performing quality evaluation on the first test case, and adjusting the plurality of first decision trees based on a first evaluation result to obtain a target test case generation model based on an evaluation result satisfying a preset evaluation result; wherein the quality evaluation on the first test case comprises: establishing a mapping relationship between the test case and the evaluation result, and obtaining the first evaluation result based on the first test case and the mapping relationship; or obtaining a target quality evaluation model, wherein the target quality evaluation model is generated based on a plurality of second decision trees, the plurality of second decision trees correspond to different quality evaluation dimensions of test cases, and each of the second decision trees is constructed based on a plurality of grades of the historical test cases under each second feature value; inputting the first test case into the target quality evaluation model, and selecting one of the historical test cases corresponding to the first test case from each second feature value in each of the second decision trees to obtain a grade under each of the second decision trees corresponding to the first test case; performing weighted processing on the grade under each of the second decision trees to obtain the first evaluation result.
2. The training method of a test case generation model according to claim 1, wherein, The obtaining of the target quality evaluation model comprises: obtaining a quality evaluation model to be trained, and a predicted grade under each of the second decision trees corresponding to a second test case; inputting the second test case into the quality evaluation model to be trained, and selecting one of the historical test cases corresponding to the second test case from each second feature value in each of the second decision trees to obtain a real grade under each of the second decision trees corresponding to the second test case; determining a first loss under each of the second decision trees based on the predicted grade under each of the second decision trees and the real grade under each of the second decision trees; adjusting the plurality of second decision trees based on the first loss under each of the second decision trees to obtain the target quality evaluation model based on a loss satisfying a convergence condition obtained by the adjusted quality evaluation model. 3.The training method of a test case generation model according to claim 1 or 2, characterized in that, Further comprising: sorting each of the first feature values by a decision tree algorithm; constructing each of the first decision trees based on the plurality of historical test cases under each of the sorted first feature values. 4.The training method of a test case generation model according to claim 1 or 2, characterized in that, Further comprising: obtaining a plurality of historical test cases; extracting key information from the plurality of historical test cases to obtain alternative feature values; Select a feature value having a correlation from the alternative feature values to obtain each first feature value and / or each second feature value.
5. The test case generation model training method according to claim 4, wherein, The obtaining of the plurality of historical test cases comprises: obtaining a test case training set; selecting alternative historical test cases from the test case training set, and performing at least one of the following operations on the alternative historical test cases to obtain the plurality of historical test cases: for the repeated historical test cases in the alternative historical test cases, retaining the latest created historical test case and deleting other historical test cases; filling in missing historical test cases in the alternative historical test cases; deleting 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. 6.The training method of a test case generation model according to claim 1 or 2, characterized in that, The adjusting of the plurality of first decision trees based on the first evaluation result comprises at least one of the following: adjusting the quality of the plurality of historical test cases; adding new historical test cases to the plurality of historical test cases; adjusting each first feature value in each first decision tree.
7. A test case generation method characterized by, comprises: obtaining a target test case generation model according to claim 1, wherein the target test case generation model 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 first decision tree is constructed based on a plurality of historical test cases under each first feature value; inputting a second requirement document into the target test case generation model, and selecting one historical test case under each first feature value in each first decision tree that matches the second requirement document to obtain a third test case corresponding to the second requirement document.
8. A training apparatus of a test case generation model, characterized by, comprises: a first obtaining module configured to 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 first decision tree is constructed based on a plurality of historical test cases under each first feature value; a first processing module configured to input a first requirement document into the test case generation model to be trained, and select one historical test case corresponding to the first requirement document under each first feature value in each first decision tree to obtain a first test case corresponding to the first requirement document; an evaluation module configured to perform quality evaluation on the first test case, wherein the evaluation module comprises establishing a mapping relationship between a test case and an evaluation result, obtaining a first evaluation result based on the first test case and the mapping relationship, or obtaining a target quality evaluation model, wherein the target quality evaluation model is generated based on a plurality of second decision trees, the plurality of second decision trees correspond to different quality evaluation dimensions of test cases, and each second decision tree is constructed based on the grades of a plurality of historical test cases under each second feature value; inputting the first test case into the target quality evaluation model, selecting a historical test case corresponding to the first test case from each second feature value in each second decision tree to obtain a level of each second decision tree corresponding to the first test case; weighting the level of each second decision tree to obtain the first evaluation result; an adjusting module configured to adjust a plurality of first decision trees based on the first evaluation result, so that an evaluation result obtained based on an adjusted test case generation model meets a preset evaluation result to obtain a target test case generation model.
9. A test case generation apparatus characterized by comprising: comprising: a second obtaining module configured to obtain a target test case generation model according to claim 1, the target test case generation model being generated based on a plurality of first decision trees, the plurality of first decision trees corresponding to different generation processes of test cases, and each first decision tree being constructed based on a plurality of historical test cases under each first feature value; a second processing module configured to input a 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.
10. An electronic device, comprising: comprising: a processor, a memory, a communication interface and a communication bus, the processor, the memory and the communication interface complete communication with each other through the communication bus; the memory is used to store one or more executable instructions, and the executable instructions make the processor execute the test case generation model training method according to any one of claims 1 to 6; or execute the test case generation method according to claim 7.
11. A computer readable storage medium, characterized in that, the computer readable storage medium stores a computer program, and the computer program is executed by one or more processors to implement the test case generation model training method according to any one of claims 1 to 6; or implement the test case generation method according to claim 7.
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