Automatic generation method and device of test case, equipment and medium

By dividing the cloud platform into functional units and conducting dependency level classification training tests, test cases are automatically generated, solving the problem of low efficiency in writing traditional test cases in the cloud platform and achieving efficient and accurate test case generation.

CN121833484APending Publication Date: 2026-04-10CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Traditional test case writing methods are inefficient in cloud platforms and cannot meet the needs of increased complexity.

Method used

By extracting key information from development requirements documents, dividing functional units, generating dependency levels based on component call relationships, and using test datasets for training and testing, test cases are automatically generated.

Benefits of technology

It improves the efficiency of test case generation, ensures the accuracy and coverage of test cases, reduces repetitive steps, and optimizes the testing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833484A_ABST
    Figure CN121833484A_ABST
Patent Text Reader

Abstract

The invention provides an automatic generation method of a test case, belongs to the technical field of cloud platforms, and aims to improve the generation efficiency of the test case, the method comprises the following steps: obtaining key information from a received target document, and obtaining a test data set corresponding to the target document, the key information at least comprises a plurality of to-be-tested functions and a plurality of components required to be called by each to-be-tested function; dividing each to-be-tested function into a plurality of function units based on the key information; dividing the plurality of function units into a plurality of categories according to a calling relationship among a plurality of components in each to-be-tested function; adopting the test data set to perform training test on the function units included in the plurality of categories to obtain an execution result corresponding to each function unit; and generating a test case corresponding to each to-be-tested function based on the execution results corresponding to the plurality of function units.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of cloud platform technology, and in particular to a method, apparatus, device, and medium for automatically generating test cases. Background Technology

[0002] In traditional software development, writing test cases is a crucial step in ensuring software quality. However, in cloud platform technologies, the complexity of testing has increased dramatically, rendering traditional test case writing methods outdated and inefficient. Summary of the Invention

[0003] Based on the background technology, this invention proposes a method, apparatus, device, and medium for automatically generating test cases.

[0004] In a first aspect, the present invention provides a method for automatically generating test cases, applied to a cloud platform. The method includes: obtaining key information from a received development requirement document and obtaining a test dataset corresponding to the development requirement document. The key information includes at least multiple functions to be tested and multiple components to be called by each function to be tested. Based on the aforementioned key information, each of the functions to be tested is divided into multiple functional units; Based on the calling relationship between multiple components in each of the functions to be tested, the multiple functional units are divided into multiple categories, wherein the functional units in different categories have different dependency levels, and the dependency level represents the number of other functional units besides the functional unit that the functional unit depends on for execution. Using the test dataset, the functional units included in the multiple categories are trained and tested respectively to obtain the execution result corresponding to each functional unit; Based on the execution results of the multiple functional units, test cases are generated for each of the functions to be tested.

[0005] Optionally, the step of dividing the multiple functional units into multiple categories based on the calling relationships between the multiple components required for each of the functions to be tested includes: Based on the calling order of the components required by each function to be tested, a dependency model between multiple functional units is generated; Based on the dependency model, the dependency level of each functional unit is determined, and the multiple functional units are divided into multiple categories according to the dependency level.

[0006] Optionally, the step of using the test dataset to train and test the functional units included in the multiple categories respectively, and obtaining the execution result corresponding to each functional unit, includes: According to the dependency level from low to high, the multiple functional units included in each category are trained and tested in sequence to obtain the execution result set corresponding to each category; During the training and testing process, for each second category, the multiple functional units included in the second category are trained and tested based on the execution result set corresponding to at least one first category; wherein the dependency level of the first category is lower than the dependency level of the second category.

[0007] Optionally, the step of training and testing multiple functional units included in the second category based on the execution result set corresponding to the first category includes... For each second functional unit in the second category, the execution result corresponding to at least one first functional unit that has a dependency relationship with the second functional unit is obtained from the execution result set; the dependency relationship indicates that there is a calling relationship between the component executing the second functional unit and the component executing the first functional unit; Based on the execution results, the second functional unit is trained and tested.

[0008] Optionally, generating test cases for each function to be tested based on the execution results of the multiple functional units includes: Based on the components to be called by the function to be tested, the test data and execution results corresponding to multiple functional units are clustered to form multiple datasets; Based on multiple datasets, a test case list is generated, which includes test cases corresponding to each function to be tested.

[0009] Optionally, generating a test case list based on multiple datasets includes: Analyze multiple functional units in each of the datasets to combine the multiple functional units into a function to be tested; For each of the functions to be tested, test cases are generated according to the combination order of the multiple functional units to obtain the test case list.

[0010] Optionally, the method further includes: Execute the test cases and obtain the actual results of the test cases; Compare the actual results of the test cases with the predicted results corresponding to the test cases; If the actual results do not match the predicted results, the combination order of the multiple functional units is adjusted to optimize the test case.

[0011] A second aspect of the present invention provides an automatic test case generation device applied to a cloud platform, the device comprising: The acquisition module is used to acquire key information from the received development requirement document and acquire the test dataset corresponding to the development requirement document. The key information includes at least multiple functions to be tested and the components to be called for each function to be tested. The determination module is used to divide each of the functions to be tested into multiple functional units based on the key information. A classification module is used to divide multiple functional units into multiple categories according to the calling relationship between multiple components in each function to be tested. The functional units included in different categories have different dependency levels, and the dependency level represents the number of other functional units besides the functional unit that the functional unit depends on. The testing module is used to train and test the functional units included in the multiple categories using the test dataset, and to obtain the execution result corresponding to each functional unit. The generation module is used to generate test cases for each of the functions to be tested based on the execution results of the multiple functional units.

[0012] A third aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executed, implements the automatic generation method for test cases as described in the first aspect above.

[0013] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that causes a processor to perform the steps of the automatic test case generation method as described in the first aspect above.

[0014] The present invention provides an automatic test case generation method, comprising: obtaining key information from a received development requirement document and obtaining a test dataset corresponding to the development requirement document, wherein the key information includes at least multiple functions to be tested and multiple components to be called by each function to be tested; dividing each function to be tested into multiple functional units based on the key information; dividing the multiple functional units into multiple categories according to the calling relationship between the multiple components in each function to be tested, wherein functional units in different categories have different dependency levels, wherein the dependency level represents the number of other functional units besides the functional unit that the functional unit depends on for execution; using the test dataset, training and testing the functional units included in the multiple categories respectively to obtain the execution result corresponding to each functional unit; and generating test cases corresponding to each function to be tested based on the execution results corresponding to the multiple functional units. Therefore, this invention divides each function to be tested into multiple functional units based on the components to be called by multiple functions to be tested, and further classifies the multiple functional units. After training and testing the functional units corresponding to each category, the results of the generation of multiple functional units are used.

[0015] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. It should be noted that the scale in the drawings is for illustration only and does not represent the actual scale.

[0017] Figure 1 A flowchart illustrating the steps of the automatic test case generation method provided in an embodiment of the present invention is shown. Figure 2 A flowchart illustrating the automatic test case generation method provided in an embodiment of the present invention is shown. Figure 3 A schematic diagram of the dependency model in an embodiment of the present invention is shown; Figure 4 A test schematic diagram of a functional unit of type I in an embodiment of the present invention is shown; Figure 5 A test schematic diagram of a functional unit of type II in an embodiment of the present invention is shown; Figure 6 A test schematic diagram of a functional unit of type III in an embodiment of the present invention is shown; Figure 7 A test schematic diagram of a functional unit of type IV in an embodiment of the present invention is shown; Figure 8 A test schematic diagram of a functional unit of type V in an embodiment of the present invention is shown; Figure 9 A schematic diagram of the structure of the automatic test case generation device provided in an embodiment of the present invention is shown. Detailed Implementation

[0018] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] In traditional software development, writing test cases is a crucial step in ensuring software quality. However, in cloud platform technologies, testing complexity has increased dramatically, rendering traditional test case writing methods outdated and inefficient. In recent years, the development of AI and cloud technologies has demonstrated powerful capabilities in areas such as natural language processing and code generation. Therefore, how to leverage these new technologies in conjunction with cloud platforms to intelligently generate test cases and improve testing efficiency has become a pressing issue.

[0020] In view of this, the present disclosure provides a method, apparatus, device and medium for automatically generating test cases. The method divides multiple functions to be tested into multiple functional units, and further divides the multiple functional units into multiple categories according to the calling relationship between the multiple components called by the functions to be tested. The method then performs test training on each category of functional units in sequence, and combines each functional unit after testing to achieve automatic generation of test cases.

[0021] Reference Figure 1 , Figure 1 The flowchart illustrating the steps of the automatic test case generation method provided in this embodiment is shown. This automatic test case generation method is applied to a cloud platform, such as... Figure 1 As shown, the automatic generation method for this test case specifically includes: S101: Obtain key information from the received target document and obtain the test dataset corresponding to the target document.

[0022] The target documents include development requirements documents, detailed design documents, and component design documents. The development requirements document defines the cloud platform's functionalities, performance, user interface, and other requirements. Analyzing the development requirements document clarifies test points, facilitating subsequent test case generation. The detailed design document defines the cloud platform's software architecture, module division, and interface design. Analyzing the detailed design document also helps identify test points for subsequent test case generation. The component design document defines the internal logic, algorithms, and data flow of each module. Analyzing the component design document clarifies the components required to execute each function. Therefore, by analyzing these target documents (development requirements document, detailed design document, and component design document), key information can be obtained to determine the cloud platform's required test functions and the multiple components required to execute each test function.

[0023] In this embodiment, the analysis of the target document can be performed using natural language processing technology to analyze the document, extract key information from key fields such as function descriptions. For example, taking the field "users log in with username and password" in the development requirements document as an example, the login function can be extracted from it, and the components to be called by the login function can be determined according to the description of the login steps and component design in the document.

[0024] S102, based on key information, divides each function to be tested into multiple functional units.

[0025] In this embodiment, after obtaining multiple functions to be tested and the components to be called by each function, each function to be tested can be divided into multiple functional units according to the execution steps of each function. Each functional unit can be an execution step of the function to be tested, and the input of the functional unit can be the execution result of the previous execution step or test data. Thus, the function to be tested can be divided into multiple functional units. In this way, in the subsequent testing process, the functional units can be tested, and the execution result of the function to be tested can be obtained by combining the execution results of the functional units, reducing repetitive steps and improving the efficiency of test case generation.

[0026] Specifically, the function under test can be divided into multiple functional units based on the components it needs to call. Each functional unit includes input and output data, and each functional unit corresponds to one component, facilitating subsequent classification of functional units based on the calling relationships between multiple components. For example, if the function under test needs to call components A, B, and C, it can be divided into three functional units: functional unit 1 corresponds to component A, functional unit 2 corresponds to component B, and functional unit 3 corresponds to component C.

[0027] S103, based on the calling relationships between multiple components required for each function to be tested, divide multiple functional units into multiple categories.

[0028] Different categories of functional units have different dependency levels. The dependency level represents the number of other functional units besides the functional unit that the functional unit depends on for execution. For example, a functional unit in category 1 has a dependency level of 1, meaning its execution does not depend on the execution results of other functional units. A functional unit in category 2 has a dependency level of 2, meaning its execution depends on the execution result of one functional unit in category 1. Specifically, multiple functional units can be divided into multiple categories based on their dependency levels. For instance, functional units in category 1 do not depend on other functional units, functional units in category 2 depend on the execution results of functional units in category 1, functional units in category 3 depend on the execution results of functional units in both categories 1 and 2, and so on.

[0029] In this embodiment, each function to be tested includes one or more execution steps. Different execution steps require calling different components. Therefore, multiple functional units can be divided into multiple categories according to the calling relationship between the multiple components required to execute each function to be tested. In this way, multiple functional units can be classified according to whether the execution of each functional unit depends on the execution results of other functional units and the number of times it depends on the execution results of other functional units. Thus, when testing each functional unit, testing can be carried out according to the category of the functional unit, so that input data for the functional unit can be obtained during the testing process.

[0030] S104 uses the test dataset to train and test the functional units included in multiple categories, and obtains the execution result corresponding to each functional unit.

[0031] After classifying multiple functional units, the obtained test dataset can be used to test all functional units included in multiple categories to obtain execution results. Specifically, when testing functional units included in multiple categories, the test data corresponding to each functional unit can be determined, and then the corresponding test data can be applied to the testing process of the functional unit. It can be understood that when using the test dataset to test multiple functional units, the correspondence between the test data and the functional units can be determined based on the test data corresponding to the function to be tested, so as to determine the test data in the training and testing process of each functional unit.

[0032] S105 generates test cases for each function to be tested based on the execution results of multiple functional units.

[0033] After obtaining the execution results of each functional unit, the execution results of multiple functional units can be clustered according to the execution steps of the function to be tested, and the correspondence between the execution results of each functional unit and multiple functions to be tested can be determined, so as to facilitate the generation of test cases for each function to be tested.

[0034] In some embodiments, after generating test cases for each function to be tested, the test cases can be verified to determine whether the generated test cases are accurate. If there are problems with the generated test cases, the test case generation process can be optimized so that the final generated test cases are accurate.

[0035] The automatic test case generation method provided in this embodiment of the invention divides each function to be tested into multiple functional units according to the components to be called by multiple functions to be tested, and divides the multiple functional units into multiple categories according to the dependency level of each functional unit before testing. The test method according to categories improves testing efficiency. Then, the execution results of multiple functional units are combined to generate test cases corresponding to each function to be tested, thereby realizing the automatic generation of test cases.

[0036] In one embodiment, the calling relationship between multiple components required by each function to be tested determines the execution order of multiple functional units. Therefore, an execution order diagram between multiple functional units can be drawn based on the calling order between multiple components to facilitate the clarification of the dependency level of multiple functional units. This process may specifically include: first, generating a dependency relationship pattern between multiple functional units based on the calling order between the components required by each function to be tested; then, determining the dependency level of each functional unit based on the dependency relationship model, and dividing the multiple functional units into multiple categories according to the dependency level.

[0037] In this embodiment, the calling relationships between multiple components can be drawn to determine the dependencies between multiple functional units. Taking the function under test calling components A, B, and C in sequence as an example, the function under test can be divided into functional unit 1, functional unit 2, and functional unit 3. Functional unit 1 corresponds to component A, functional unit 2 corresponds to component B, and functional unit 3 corresponds to component C. When the function under test is executed, the execution of functional unit 1 does not depend on other functional units, the execution of functional unit 2 depends on the execution result of functional unit 1, and the execution result of functional unit 3 depends on the execution result of functional unit 2. Thus, functional unit 1, functional unit 2, and functional unit 3 can be divided into three different categories.

[0038] Understandably, when testing multiple functional units using a test dataset, the input data for a functional unit can be the execution results of other functional units. Therefore, when testing multiple functional units, they need to be tested in order of category to ensure that each functional unit can be tested successfully. Specifically, this process can be as follows: train and test multiple functional units included in each category in order of dependency level from low to high, to obtain the execution result set corresponding to each category; during the training and testing process, for each second category, train and test multiple functional units included in the second category based on at least one execution result set corresponding to the first category; wherein, the dependency level of the first category is lower than that of the second category.

[0039] In this embodiment, multiple functional units across multiple categories can be trained and tested in ascending order of dependency level. This allows for the initial testing of functional units that do not depend on the execution results of other functional units, and the execution results of these functional units can then be applied to the training and testing of functional units across other categories, ensuring a smooth training and testing process. Specifically, for functional units in the category with the lowest dependency level—that is, functional units that do not depend on the execution results of other functional units—corresponding test data can be obtained from the test dataset as input data for training and testing to obtain the execution result for each functional unit. For functional units in other categories, the execution results of functional units that have a dependency relationship with the functional unit can be used as input for training and testing.

[0040] The dependency level of the first category is lower than that of the second category. That is, the number of execution results of other functional units that the functional unit in the first category depends on is the same as the number of execution results of other functional units that the functional unit in the second category depends on. Therefore, after training and testing the functional units in the first category, the multiple functional units included in the second category are then tested. During the testing of the functional units in the second category, the execution results of functional units that have a dependency relationship with the functional unit can be obtained to test the functional unit.

[0041] Specifically, for each second functional unit in the second category, the execution result of at least one first functional unit that has a dependency relationship with the second functional unit is obtained from the execution result set; the dependency relationship represents the calling relationship between the component executing the second functional unit and the component executing the first functional unit; then, the second functional unit is trained and tested based on the execution result.

[0042] In this embodiment, when training and testing a second functional unit in the second category, a first functional unit that has a dependency relationship with the second functional unit can be identified. The number of first functional units can be one or more, and they are obtained based on the dependency relationship of the second functional unit. This dependency relationship can be determined based on the calling relationship between the component corresponding to the functional unit and other components, or, if a dependency relationship model between multiple functional units is established, it can be directly obtained from the dependency relationship model. For example, taking the execution results of functional unit A depending on the execution results of functional units B and C as an example, if it is determined that the component executing functional unit A needs to call the component corresponding to functional unit B and the component corresponding to functional unit C, then it can be determined that functional unit A has a dependency relationship with functional units B and C. Therefore, the execution results of functional unit B and functional unit C can be obtained from the execution result set for training and testing functional unit A.

[0043] Understandably, test cases cannot be directly generated after training and testing multiple functional units. The execution results of multiple functional units must be combined. At this point, the execution results of multiple functional units can be clustered to facilitate the generation of test cases. Specifically, firstly, based on the components that the function to be tested needs to call, the test data and execution results corresponding to multiple functional units are clustered to form multiple datasets. Then, based on multiple datasets, a test case list is generated, which includes test cases corresponding to each function to be tested.

[0044] In this embodiment, based on the components required for each function to be tested, the functions to be tested belonging to multiple functional units can be determined. This allows for the clustering of test data and execution results corresponding to multiple functional units, forming multiple datasets. Each test case includes elements such as input data, expected results, and test steps; therefore, each dataset needs to include the test input and execution results for each functional unit. After obtaining multiple datasets, multiple functional units within these datasets can be combined to generate test cases corresponding to each function to be tested, thus forming a test case list.

[0045] In the process of generating a test case list, one can first analyze multiple functional units in each dataset to combine them into a function to be tested; then, for each function to be tested, test cases are generated according to the combination order of multiple functional units to obtain a test case list.

[0046] In this embodiment, the execution order of each functional unit can be determined based on the components corresponding to the functional units included in each dataset. Multiple functional units can then be recombined into a function to be tested. At this point, the input data and execution results corresponding to each step in the function to be tested can be determined based on the execution order of the multiple functional units, thereby generating test cases for that function. The above operation is performed on all functional units included in each dataset to generate a test case list. The test case list may include a description of the test scenario, test case dependencies, test case steps, and result predictions.

[0047] In one embodiment, after generating the test case list, the execution result of each test case can be verified to ensure the accuracy of the test cases. If there are quality problems with the test cases, the test case generation process can be optimized to ensure the quality of the test cases. Specifically, the actual results of the test cases can be obtained first; then, the actual results of the test cases can be compared with the predicted results corresponding to the test cases; if the actual results do not match the test results, the test cases can be optimized.

[0048] In this embodiment, after generating test cases, the test cases can be verified. Specifically, the test data of the test cases can be used for actual execution to obtain the actual results of the test cases. The actual results are then compared with the predicted results corresponding to the test cases to determine whether they match. If they match, it indicates that the test case quality is acceptable; if they do not match, it indicates that there may be a problem in the test case generation process. In this case, the specific problem can be analyzed to optimize the test case generation process. For example, if the analysis of the test case generation process determines that the inaccurate test case prediction results are caused by the combination order of multiple functional units, the test cases can be optimized by adjusting the combination order of multiple functional units.

[0049] The automatic test case generation method provided in this disclosure divides each function to be tested into multiple functional units according to the components to be called by multiple functions to be tested, and further classifies the multiple functional units. After training and testing the functional units corresponding to each category, test cases are obtained by combining the execution results of multiple functional units, thereby realizing the automatic generation of test cases and improving the generation efficiency of test cases.

[0050] The automatic test case generation method provided by the embodiments of the present invention will be described in detail below with reference to the accompanying drawings: Reference Figure 2 , Figure 2 The diagram illustrates a flowchart of the automatic test case generation method provided by this invention. This automatic test case generation method is applied to a cloud platform, such as... Figure 2 As shown, the automatic generation method for this test case specifically includes: First, the target documents, such as product requirements documents and development process documents, are analyzed to extract key information to determine the functions to be tested on the cloud platform and the components to be called for each function. Simultaneously, test data is collected and categorized according to the functions to be tested to form a test dataset.

[0051] Next, based on the components required by the function to be tested, the function to be tested is divided into multiple functional units. Each functional unit executes one step of the function to be tested, and the calling relationships between various components in the cloud platform are organized to generate a dependency model between multiple functional units. Among them, the multiple functional units are divided into multiple functions as shown in Table 1 below.

[0052] Table 1. Multiple functional units categorized by module

[0053] After dividing multiple functions to be tested into multiple functional units, the calling relationships between multiple components of the cloud platform can be analyzed to determine the execution order of the multiple functional units, resulting in a dependency model. Based on the dependencies, the multiple functional units can be divided into multiple categories. The dependency model can be as follows: Figure 3 As shown in the table. Specifically, multiple functional units can be divided into five types, namely Type I to Type V. Type I functional units are the smallest atomic units of functionality, do not depend on any interface or service, can automatically close the loop, and output true or false. Type II functional units have two-level execution dependencies, meaning the first step depends on the execution result of the second step. Type III functional units have three-level execution dependencies, meaning the first step depends on the execution results of the second and third steps. Type IV functional units have four-level execution dependencies, meaning the first step depends on the execution results of the second, third, and fourth steps. Type V functional units have five-level execution dependencies, meaning the first step depends on the execution results of the second, third, fourth, and fifth steps. The dependency relationships between multiple functional units can be obtained based on the dependency model, as shown in Table 2 below.

[0054] Table 2 Dependencies among multiple functional units

[0055] After classifying multiple functional units into multiple categories, training and testing can be performed on these functional units, and the execution results for each functional unit can be recorded. Specifically, refer to... Figures 4-8 , Figures 4-8 The flowchart illustrates the training and testing methods for five types of functional units, as follows: Figures 4-8As shown, we can first test the multiple functional units included in Type I to obtain the execution result of each functional unit in Type I; then, we can test the multiple functional units included in Type II, and at this time, the execution results of the functional units in Type I can be used for the training and testing process of Type II to obtain the execution of multiple functional units in Type II; then, we can test the multiple functional units included in Type III, and at this time, the execution results of the functional units in Type I and Type II can be applied to the training and testing process of the functional units in Type III to obtain the execution results of multiple functional units in Type III; then, based on the execution results of multiple functional units in Type I, Type II, and Type III, we can train and test multiple functional units in Type IV to obtain the execution results of multiple functional units in Type IV; finally, based on the execution results of multiple functional units in Type I, Type II, Type III, and Type IV, we can train and test multiple functional units in Type V to obtain the execution results of multiple functional units in Type IV.

[0056] After obtaining the execution results of multiple functional units included in each type, the execution results of multiple functional units can be clustered according to the correspondence between the functional units and the function to be tested, resulting in multiple datasets. Each dataset contains the test data and execution results of multiple functional units included in a function to be tested. Then, a test case system can be used to process the datasets in batches, forming test cases for each function to be tested, ultimately creating a test case list. The test case list includes descriptions of test scenarios, test case dependencies, test case steps, and result predictions.

[0057] After generating test cases, the actual results corresponding to the input data in the test cases can be determined, and the actual results can be compared with the predicted results to verify whether the test cases are accurate. If the actual results do not match the predicted results, the test case generation process can be optimized.

[0058] Based on the same inventive concept, embodiments of the present invention also provide an automatic test case generation device, referring to... Figure 9 , Figure 9 This diagram illustrates the structure of an automatic test case generation device provided in an embodiment of the present invention. This device is applied to a cloud platform, such as... Figure 9 As shown, the automatic test case generation device includes: The first acquisition module 201 is used to acquire key information from the received target document and acquire the test dataset corresponding to the target document. The key information includes at least multiple functions to be tested and the components to be called for each function to be tested. The partitioning module 202 is used to divide each function to be tested into multiple functional units based on key information; The classification module 203 is used to divide multiple functional units into multiple categories according to the calling relationship between multiple components in each function to be tested. The functional units included in different categories have different dependency levels. The dependency level represents the number of other functional units besides the functional unit that the functional unit depends on. The test module 204 is used to train and test the functional units included in multiple categories using the test dataset, and obtain the execution result corresponding to each functional unit. The generation module 205 is used to generate test cases for each test case based on the execution results of multiple functional units.

[0059] In one embodiment, the partitioning module 202 includes: The first generation submodule is used to generate a dependency model between multiple functional units based on the calling order between the components required by each function to be tested. Sub-modules are used to determine the dependency level of each functional unit based on the dependency model, and to divide multiple functional units into multiple categories according to the dependency level.

[0060] In one embodiment, the test module 204 includes: The first testing submodule is used to train and test multiple functional units included in each category in order of dependency level from low to high, so as to obtain the execution result set corresponding to each category. During the training and testing process, training and testing are performed on multiple functional units included in each second category. The dependency level of the first category is lower than that of the second category.

[0061] In one embodiment, the first test submodule includes: The acquisition unit is used to acquire, for each second functional unit of the second category, the execution result corresponding to at least one first functional unit that has a dependency relationship with the second functional unit from the execution result set; firstly, the relationship indicates that there is a calling relationship between the component executing the second functional unit and the component executing the first functional unit; The test unit is used to train and test the second functional unit based on the execution results.

[0062] In one embodiment, the generation module 205 includes: The clustering submodule is used to cluster the test data and execution results corresponding to multiple functional units based on the components to be called by the function under test, forming multiple datasets; The second generation submodule is used to generate a test case list based on multiple datasets. The test case list includes test cases for each function to be tested.

[0063] In one embodiment, the second generation submodule includes: Analysis unit, used to analyze multiple functional units in each dataset to combine multiple functional units into a function to be tested; The generation unit is used to generate test cases for each function to be tested, according to the combination order of multiple functional units, so as to obtain a test case list.

[0064] In one embodiment, the automatic test case generation device further includes: The second acquisition module is used to acquire the actual results of the test cases; The comparison module is used to compare the actual results of test cases with the predicted results corresponding to the test cases; The optimization module is used to optimize test cases when the actual results do not match the predicted results.

[0065] Based on the same inventive concept, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps in the automatic generation method of test cases as described in any of the above embodiments.

[0066] Based on the same inventive concept, embodiments of the present invention also provide a computer-readable storage medium storing a computer program that causes a processor to execute the automatic generation method of test cases as described in any of the above embodiments.

[0067] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0068] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0069] The above provides a detailed description of the automatic test case generation method, apparatus, device, and medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

[0070] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention described herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not invented herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.

[0071] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

[0072] The terms "an embodiment," "embodiment," or "one or more embodiments" as used herein mean that a particular feature, structure, or characteristic described in connection with an embodiment is included in at least one embodiment of the invention. Furthermore, please note that the examples of the phrase "in one embodiment" do not necessarily all refer to the same embodiment.

[0073] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0074] In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising a plurality of different elements and by means of a suitably programmed computer. In a unit claim enumerating a plurality of means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.

[0075] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for automatically generating test cases, characterized in that, Applied to a cloud platform, the method includes: Obtain key information from the received target document and obtain the test dataset corresponding to the target document. The key information includes at least multiple functions to be tested and multiple components to be called for each function to be tested. Based on the aforementioned key information, each of the functions to be tested is divided into multiple functional units; Based on the calling relationship between multiple components in each of the functions to be tested, the multiple functional units are divided into multiple categories, wherein the functional units in different categories have different dependency levels, and the dependency level represents the number of other functional units besides the functional unit that the functional unit depends on for execution. Using the test dataset, the functional units included in the multiple categories are trained and tested respectively to obtain the execution result corresponding to each functional unit; Based on the execution results of the multiple functional units, test cases are generated for each of the functions to be tested.

2. The method for automatically generating test cases according to claim 1, characterized in that, The method involves dividing the multiple functional units into multiple categories based on the calling relationships between the multiple components required for each of the functions to be tested, including: Based on the calling order of the components required by each function to be tested, a dependency model between multiple functional units is generated; Based on the dependency model, the dependency level of each functional unit is determined, and the multiple functional units are divided into multiple categories according to the dependency level.

3. The method for automatically generating test cases according to claim 1, characterized in that, The step of using the test dataset to train and test the functional units included in multiple categories to obtain the execution result corresponding to each functional unit includes: According to the dependency level from low to high, the multiple functional units included in each category are trained and tested in sequence to obtain the execution result set corresponding to each category; During the training and testing process, for each second category, the multiple functional units included in the second category are trained and tested based on the execution result set corresponding to at least one first category; wherein the dependency level of the first category is lower than the dependency level of the second category.

4. The method for automatically generating test cases according to claim 3, characterized in that, The step of training and testing multiple functional units included in the second category based on the execution result set corresponding to the first category includes... For each second functional unit in the second category, the execution result corresponding to at least one first functional unit that has a dependency relationship with the second functional unit is obtained from the execution result set; the dependency relationship indicates that there is a calling relationship between the component executing the second functional unit and the component executing the first functional unit; Based on the execution results, the second functional unit is trained and tested.

5. The method for automatically generating test cases according to claim 1, characterized in that, The step of generating test cases for each function to be tested based on the execution results of the multiple functional units includes: Based on the components to be called by the function to be tested, the test data and execution results corresponding to multiple functional units are clustered to form multiple datasets; Based on multiple datasets, a test case list is generated, which includes test cases corresponding to each function to be tested.

6. The method for automatically generating test cases according to claim 5, characterized in that, The process of generating a test case list based on multiple datasets includes: Analyze multiple functional units in each of the datasets to combine the multiple functional units into a function to be tested; For each of the functions to be tested, test cases are generated according to the combination order of the multiple functional units to obtain the test case list.

7. The method for automatically generating test cases according to claim 6, characterized in that, The method further includes: Obtain the actual results of the test cases; Compare the actual results of the test cases with the predicted results corresponding to the test cases; If the actual results do not match the predicted results, the test cases are optimized.

8. An automatic test case generation device, characterized in that, The device, applied to a cloud platform, includes: The acquisition module is used to acquire key information from the received target document and acquire the test dataset corresponding to the target document. The key information includes at least multiple functions to be tested and the components to be called for each function to be tested. The partitioning module is used to divide each of the functions to be tested into multiple functional units based on the key information. A classification module is used to divide multiple functional units into multiple categories according to the calling relationship between multiple components in each function to be tested. The functional units included in different categories have different dependency levels, and the dependency level represents the number of other functional units besides the functional unit that the functional unit needs to depend on. The testing module is used to train and test the functional units included in the multiple categories using the test dataset, and to obtain the execution result corresponding to each functional unit. The generation module is used to generate test cases for each of the functions to be tested based on the execution results of the multiple functional units.

9. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executed, implements the method for automatically generating test cases as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The stored computer program causes the processor to execute the steps of the automatic test case generation method as described in any one of claims 1-7.