Software test case automatic generation method and related equipment thereof

By analyzing demand conditions, extracting features, calculating weight values ​​and dynamic combination features, the automated generation of software test cases is achieved, and the problems of redundancy, insufficient coverage and high maintenance costs in the existing technology are solved, and the testing efficiency and quality are improved.

CN120216378APending Publication Date: 2025-06-27PING AN HEALTH INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510324270.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-18
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The existing software test case generation methods have problems such as redundancy, insufficient coverage and high maintenance costs, resulting in inefficient testing and increased risk of potential defects.

Method used

A software test case automation generation method is adopted to analyze the requirements conditions, extract the test case features, and use the random forest algorithm to calculate the feature weight value, set the weight threshold to filter the key use case features, and finally dynamically combine the key features based on the requirements conditions to generate test cases.

Benefits of technology

It effectively reduces redundant use cases, improves the targetedness and coverage of test cases, and significantly improves test efficiency and quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216378A_ABST
    Figure CN120216378A_ABST
Patent Text Reader

Abstract

The invention discloses a software test case automatic generation method and related equipment thereof, belongs to the technical field of artificial intelligence, and is applied to online application scenes of financial insurance and wisdom medical treatment. The method comprises the steps of obtaining a demand condition corresponding to a to-be-generated test case; analyzing the demand condition, and extracting a test case feature corresponding to the to-be-generated test case; weight values of the test case features are calculated based on a preset random forest algorithm, and the weight values represent the importance of the test case features when the test cases are generated; setting a weight threshold, and screening the test case features according to the weight threshold and the weight value to obtain key case features; and dynamically combining the key case characteristics based on demand conditions to generate a test case. According to the method, the key case characteristics are screened through the random forest algorithm, so that automatic generation of the software test case is realized, redundant cases are effectively reduced, and the pertinence and coverage rate of the test case are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of artificial intelligence, and particularly relates to a method, device, computer device and storage medium for automatically generating software test cases. Background Art

[0002] In the current software industry, the application of various technologies is increasing day by day, and more attention is paid to R & D efficiency, which also leads to higher requirements for the level of practitioners. As a software tester, how to improve the test efficiency and assist in automatically generating test cases to perform test work more accurately and conveniently under the background of increasing throughput of R & D requirements is an important node to ensure quality and quantity. Taking the insurance business system and the intelligent medical system as examples, the number of test cases required in the process of iteration of the insurance business system or the intelligent medical system is large and diverse. Therefore, how to generate test cases adapted to each iteration update has become the key challenge to improve test efficiency and quality.

[0003] Traditional software test case generation methods mainly rely on rules or random generation, and these methods have significant problems in practical applications. First, the phenomenon of test case redundancy is serious. A large number of repeated or invalid test cases lead to low test execution efficiency and waste of valuable resources and time. Second, the test coverage is insufficient, and many key code paths and boundary conditions are not fully covered, increasing the risk of potential software defects. In addition, with the continuous expansion of software scale and the increasing complexity of functions, the number of test cases increases exponentially, and the maintenance cost also rises significantly, bringing a huge burden to the test team. Summary of the Invention

[0004] The purpose of the embodiments of this application is to propose a method, device, computer device and storage medium for automatically generating software test cases to solve the technical problems of redundancy, insufficient coverage and high maintenance cost existing in the existing software test case generation methods, and improve test efficiency and accuracy.

[0005] To solve the above technical problems, the embodiments of this application provide a method for automatically generating software test cases, which adopts the following technical solutions:

[0006] A method for automatically generating software test cases includes:

[0007] Receiving a test case generation instruction and obtaining the requirement conditions corresponding to the test case to be generated;

[0008] Parsing the requirement conditions and extracting the test case features corresponding to the test case to be generated;

[0009] Calculating the weight value of the test case features based on the preset random forest algorithm, where the weight value represents the importance of the test case features in test case generation;

[0010] Set a weight threshold, and filter the test case features according to the weight threshold and the weight values to obtain the key use case features;

[0011] Dynamically combine the key use case features based on the requirement conditions to generate test cases.

[0012] To solve the above technical problems, an embodiment of the present application further provides a software test case automatic generation device, which adopts the following technical solutions:

[0013] A software test case automatic generation device includes:

[0014] A requirement condition module, configured to receive a test case generation instruction and obtain the requirement conditions corresponding to the test cases to be generated;

[0015] A use case feature module, configured to analyze the requirement conditions and extract the test case features corresponding to the test cases to be generated;

[0016] A feature weight module, configured to calculate the weight values of the test case features based on a preset random forest algorithm, where the weight values represent the importance of the test case features during test case generation;

[0017] A feature screening module, configured to set a weight threshold, and filter the test case features according to the weight threshold and the weight values to obtain the key use case features;

[0018] A use case generation module, configured to dynamically combine the key use case features based on the requirement conditions to generate test cases.

[0019] To solve the above technical problems, an embodiment of the present application further provides a computer device, which adopts the following technical solutions:

[0020] A computer device includes a memory and a processor. Computer-readable instructions are stored in the memory, and when the processor executes the computer-readable instructions, the steps of the software test case automatic generation method as described in any one of the above are implemented.

[0021] To solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solutions:

[0022] A computer-readable storage medium has computer-readable instructions stored thereon, and when the computer-readable instructions are executed by a processor, the steps of the software test case automatic generation method as described in any one of the above are implemented.

[0023] Compared with the prior art, the embodiments of the present application mainly have the following beneficial effects:

[0024] This application discloses an automated software test case generation method and related devices, belonging to the field of artificial intelligence technology and applied to online application scenarios of financial insurance and intelligent healthcare. By combining requirement condition parsing and the random forest algorithm, this application realizes the automated generation of software test cases. First, by parsing requirement conditions and extracting test case features, the core elements of test requirements can be accurately captured. Second, the random forest algorithm is used to calculate feature weight values, scientifically quantifying the importance of each feature in test case generation and avoiding the deviation of manual subjective judgment. Then, by setting a weight threshold to screen key use case features, redundant use cases are effectively reduced, and the pertinence and coverage rate of test cases are improved. Finally, based on requirement conditions, key features are dynamically combined, and the generated test cases can flexibly adapt to different test scenarios, significantly improving test efficiency and quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] To more clearly illustrate the solutions in this application, the following will briefly introduce the drawings required for the description of the embodiments of this application. Obviously, the following-described drawings are some embodiments of this application, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.

[0026] Figure 1 Shows an exemplary system architecture diagram to which this application can be applied;

[0027] Figure 2 Shows a flowchart of an embodiment of the automated software test case generation method according to this application;

[0028] Figure 3 Shows a schematic structural diagram of an embodiment of the automated software test case generation device according to this application;

[0029] Figure 4 Shows a schematic structural diagram of an embodiment of the computer device according to this application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0030] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the art belonging to the technical field of this application; the terms used in the description of the embodiments of this application herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the description and claims of this application and the above drawings are intended to cover non-exclusive inclusion. The terms "first", "second", etc. in the description and claims of this application or the above drawings are used to distinguish different objects and not to describe a specific order.

[0031] References to "embodiments" in this specification mean that particular features, structures, or characteristics described in connection with the embodiments can be included in at least one embodiment of the present application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0032] To enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.

[0033] As Figure 1 shown, the system architecture 100 may include a terminal device 101, a network 102, and a server 103. The terminal device 101 may be a laptop computer 1011, a tablet computer 1012, or a mobile phone 1013. The network 102 is a medium for providing a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0034] A user may use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications may be installed on the terminal device 101, such as a web browser application, a shopping application, a search application, an instant messaging tool, an email client, a social platform software, etc.

[0035] The terminal device 101 may be various electronic devices with a display screen and supporting web browsing. In addition to the laptop computer 1011, the tablet computer 1012, or the mobile phone 1013, the terminal device 101 may also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop portable computer, a desktop computer, etc.

[0036] The server 103 may be a server providing various services, such as a background server supporting the pages displayed on the terminal device 101.

[0037] It should be noted that the software test case automated generation method provided in the embodiments of the present application is generally executed by the server / terminal device. Correspondingly, the software test case automated generation device is generally provided in the server / terminal device.

[0038] It should be understood that Figure 1 the number of terminal devices, networks, and servers in Figure 1 is only illustrative. According to implementation requirements, the above system may have any number of terminal devices, networks, and servers.

[0039] Continuing to refer to Figure 2 , a flowchart of an embodiment of a method for automatically generating software test cases according to the present application is shown. The method for automatically generating software test cases includes the following steps:

[0040] S201, receiving a test case generation instruction and obtaining the requirement conditions corresponding to the test case to be generated;

[0041] Specifically, first, the system receives a generation instruction from a tester or an automated testing tool. This instruction contains the basic requirements and objectives for generating test cases, and the information in the instruction includes relevant content such as software requirement documents, function descriptions, input / output requirements, boundary conditions, etc. The system extracts the specific requirement conditions for the test case to be generated from this information. These requirement conditions reflect the behavior of the software in a specific scenario. For example, the requirement conditions may involve the input range, expected output, performance requirements, error handling methods, etc. of a certain module. By obtaining these requirement conditions, the system can clarify the specific business scenarios that the test case should cover, providing a clear goal and basis for test case generation, ensuring that the generated test cases closely meet the actual requirements and avoiding irrelevant test content.

[0042] S202, parsing the requirement conditions and extracting the test case features corresponding to the test case to be generated;

[0043] Specifically, the system will perform a detailed analysis of the requirement conditions obtained in step S201. The analysis process includes semantic analysis and structured processing of text information such as requirement documents and function descriptions to ensure that relevant test case features can be accurately extracted. For example, for a requirement involving the input data range, the system will extract the valid range and boundary conditions of the input data; for functional requirements, the system will analyze the functional modules that the system needs to support and the specific behavior of each module. Feature extraction not only focuses on the surface information of functional requirements but also deeply explores potential test points, such as error handling, abnormal scenarios, performance bottlenecks, etc. In this way, the system can generate a set of high-quality information describing the characteristics of the test object, and these characteristics will provide comprehensive input for the automatic generation of test cases, ensuring that the test cases cover all possible functional scenarios and boundary conditions.

[0044] Taking an insurance test case as an example, assume that the requirement conditions include "the customer's insured age range is from 18 to 60 years old, the policy amount range is from 10,000 to 500,000, and the insurance period is from 1 to 20 years". In step S202, the system will parse these requirement conditions and extract the corresponding test case features. First, the system will extract "customer age" as a key feature and set its valid range to be from 18 to 60 years old; then, extract the "policy amount" feature and analyze its valid range to be from 10,000 to 500,000; in addition, the "insurance period" feature will also be extracted, with a range of 1 to 20 years. Next, the system will consider possible boundary conditions, such as the age being 18 years old and 60 years old, the policy amount being 10,000 yuan and 500,000 yuan, and the insurance period being 1 year and 20 years, etc. By extracting these features, the system can construct a set of clear test feature sets that are consistent with the requirement conditions.

[0045] S203, calculate the weight value of the test case features based on the preset random forest algorithm, where the weight value represents the importance of the test case features during the generation of test cases;

[0046] Specifically, the system analyzes and evaluates the test case features extracted from the requirement conditions according to the preset random forest algorithm. Random forest is an ensemble learning algorithm that makes a final prediction by generating multiple decision trees and combining the results of these decision trees. In this solution, the core role of the random forest algorithm is to calculate the weight value of each test case feature by analyzing historical data, existing test experience, or known software defects. The weight value reflects the importance of the feature during the generation of test cases. For example, for an input data type feature, its weight may be affected by factors such as the input range, data verification rules, and actual usage frequency. By this method, the system can automatically evaluate the contribution of different features to test coverage, helping to determine which features are more critical and which features may be redundant. This process makes the generated test cases more targeted and effective, thus improving the test efficiency.

[0047] S204, set a weight threshold, and screen the test case features according to the weight threshold and the weight value to obtain the key use case features;

[0048] Specifically, the system will screen the test case features according to the calculated feature weight values and the preset weight thresholds. The purpose of setting the weight threshold is to ensure that the key features of the test cases receive sufficient attention, while unimportant or redundant features will be excluded. The setting of the threshold can be adjusted according to the specific requirements of the project and is usually selected in combination with factors such as the depth of test coverage, the complexity of the requirements, and the available resources. By screening the feature weights, the system can focus on those features that most affect the system behavior or best reflect the requirement conditions. For example, if the weight value of a certain feature is higher than the set threshold, it indicates that this feature is crucial when generating test cases and needs to be retained; on the contrary, if the weight value of a certain feature is lower than the threshold, it can be excluded. Through this screening process, the system can optimize the test case feature set, ensure that the finally generated test cases focus on the most critical test points, and avoid ineffective or inefficient tests.

[0049] S205, Dynamically combine the key use case features based on the requirement conditions to generate test cases.

[0050] Specifically, after completing the feature screening, the system will dynamically combine the screened key features and the initial requirement conditions to generate specific test cases. The dynamic combination process takes into account the interactions between various features, especially that some features may affect the values or combination methods of other features. For example, when generating test cases, the system not only pays attention to the independence of each feature but also considers the interaction effects between features to ensure the comprehensiveness and depth of test coverage. The generated test cases will be arranged and combined for different scenarios, such as different ranges of test inputs, different operation steps, or different system states, etc. The system will dynamically adjust the combination method of test cases according to the requirement conditions and the generated features to achieve as comprehensive test coverage as possible and ensure that each test case can reflect the situations that may occur in the real environment. Finally, the system will generate a set of high-quality automated test cases that can comprehensively cover the requirement conditions, greatly improving the efficiency and accuracy of testing.

[0051] For example, in step S205, the system will dynamically combine according to the previously selected key features (such as customer age, policy amount, and insurance term) and requirement conditions to generate specific test cases. For example, the system will combine different customer age ranges, such as 18 years old, 30 years old, and 60 years old, with different policy amount ranges (such as 10,000, 100,000, 500,000) and insurance terms (such as 1 year, 10 years, 20 years) respectively to form multiple test scenarios. Each combination represents an independent test case to verify the performance of the system under different input conditions. For example, test case 1 may be a customer age of 30 years old, a policy amount of 100,000, and an insurance term of 5 years; test case 2 may be a customer age of 18 years old, a policy amount of 10,000, and an insurance term of 1 year; test case 3 may be a customer age of 60 years old, a policy amount of 500,000, and an insurance term of 20 years.

[0052] In the above embodiments, the present application realizes the automatic generation of software test cases by combining requirement condition parsing and the random forest algorithm. First, by parsing the requirement conditions and extracting test case features, the core elements of the test requirements can be accurately captured; second, the random forest algorithm is used to calculate the feature weight values, scientifically quantifying the importance of each feature in test case generation and avoiding the deviation of manual subjective judgment; then, by setting a weight threshold to screen the key use case features, redundant use cases are effectively reduced, and the pertinence and coverage rate of the test cases are improved; finally, based on the requirement conditions, the key features are dynamically combined, and the generated test cases can flexibly adapt to different test scenarios, significantly improving the test efficiency and quality.

[0053] For another example, in the online application scenario of intelligent healthcare, the present application can be used to automatically generate test cases for remote healthcare systems to ensure the stability and accuracy of the systems. For example, in an online consultation platform, patients input disease descriptions, and the system needs to match doctors and recommend treatment plans according to established rules. To ensure the accuracy and reliability of this process, first, by parsing the requirement conditions, key test features are extracted, such as the integrity of the patient input information, the accuracy of the matching algorithm, the rationality of the doctor recommendation logic, etc. Then, the random forest algorithm is used to calculate the weight values of each feature to identify the core factors affecting the system performance and functions, avoiding the deviation caused by relying on manual experience. Next, a weight threshold is set to screen the key features, optimize the test case set, reduce redundancy, and improve the test coverage rate. For example, key scenarios such as abnormal input processing and the accuracy of cross-departmental recommendations are focused on. Finally, based on the requirement conditions, the test cases are dynamically combined to simulate different patient inputs, network environments, and abnormal situations to ensure that the system can operate stably in various scenarios.

[0054] Furthermore, the step of calculating the weight values of the test case features based on the preset random forest algorithm specifically includes:

[0055] Group the test case features and identify the association relationships among the test case features in each feature group;

[0056] Initialize the same number of random forest trees according to the number of feature groups;

[0057] For each random forest tree, sequentially import the test case features and association relationships of the corresponding group into the random forest tree. Among them, the random forest tree includes nodes and edges. Import the test case features into the nodes and the association relationships into the edges;

[0058] Identify the information gain when each random forest tree node splits;

[0059] Calculate the weight value of the test case feature based on the number of random forest trees and the information gain of each random forest tree.

[0060] In this embodiment, the system first groups all the test case features and identifies the association relationships among different features in each group. For example, for insurance test cases, the system may group "customer age" and "insurance period" as one group and "policy amount" as another group. Then, the system initializes the corresponding number of random forest trees according to the number of feature groups, and each tree is responsible for processing one feature group. Next, import the features and association relationships of each group into the corresponding tree in sequence, with the features as nodes and the association relationships as the edges of the tree. Each tree makes decisions, splits at the nodes, and evaluates the information gain, that is, the improvement degree of feature prediction after each split. The level of information gain reflects the importance of each feature in test case generation. Finally, by aggregating the information gains of each tree and combining the number of random forest trees, the system calculates the final weight value of each feature, and these weight values characterize the relative importance of the features in the process of generating test cases.

[0061] Furthermore, the formula for calculating the weight value of the test case feature is as follows:

[0062]

[0063] In the formula, FI(f i ) represents the weight value of feature f i , that is, the importance of f i in the process of generating test cases. N trees is the number of trees in the random forest. T represents the set of all trees, t represents the nodes in tree T, and imp(f i ,t) represents the information gain when splitting at node t using feature f i . N t is the number of samples at node t.

[0064] Through the above steps, with this method in the present application, the system can scientifically evaluate the importance of each feature, ensuring that the generated test cases can cover key test scenarios to the greatest extent, thereby improving the efficiency and accuracy of testing.

[0065] Further, for each random forest tree, the step of sequentially importing the test case features and association relationships of the corresponding group into the random forest tree specifically includes:

[0066] For each test case feature group, determine the target node corresponding to each test case feature in the random forest tree according to the association relationship between the test case features;

[0067] Embed each test case feature into the corresponding target node;

[0068] Match the edge between the association relationship and the target node, and embed the association relationship into the matched edge.

[0069] In this embodiment, for each feature group, the system first analyzes the association relationship between the test case features to determine the target node corresponding to each feature in the random forest tree. For example, if "customer age" has a strong association with "insurance amount", they may share a parent node in the tree, while other features will be distributed to different nodes according to the association relationship. Then, the system embeds each feature into the corresponding target node and matches these nodes and edges according to the relationship between the features. Finally, the system will embed the association relationship of the test case features into the matched edge to form a structured random forest tree model.

[0070] Through the above steps, the system can more accurately process the complex relationships between features, improve the prediction ability of the model and the effectiveness of test case generation, and ensure that the test covers key scenarios.

[0071] Further, the step of identifying the information gain when each random forest tree node splits specifically includes:

[0072] For each random forest tree, identify all the nodes of the random forest tree;

[0073] Use a preset recursive selection algorithm to perform node splitting on the random forest tree. When splitting nodes, it is required to perform recursive splitting with each node of the random forest tree as the parent node;

[0074] In each recursive split, obtain the feature set of the parent node, calculate the information entropy of the parent node, and at the same time obtain the feature set of the split child nodes and calculate the information entropy of the split child nodes;

[0075] Calculate the information gain when splitting the nodes of the random forest tree based on the feature set of the parent node, the information entropy of the parent node, the feature set of the split child nodes, and the information entropy of the split child nodes.

[0076] In this embodiment, the system first identifies all the nodes in the random forest tree, which represent different features or combinations of features. Each node is a splitting point of the tree, and the system uses a preset recursive selection algorithm to determine how to split these nodes. The core idea of the recursive selection algorithm is that at each split, the feature that can most reduce the information entropy is selected as the splitting basis. Information entropy measures the uncertainty of the data, and the goal of node splitting is to maximize the information gain, that is, to reduce the entropy. Specifically, at each recursive split, the system first obtains the feature set of the parent node and calculates the information entropy of the parent node. Then, the system selects the best splitting feature based on the feature set of the parent node and divides the data into different child nodes. Next, the system calculates the information entropy of each child node. Finally, by calculating the difference in information entropy between the parent node and the child nodes, the information gain is obtained. This process will reflect the contribution of each feature in the splitting process, thereby helping the system evaluate the importance of different features.

[0077] Furthermore, the formula for calculating the information gain when splitting the nodes of the random forest tree is as follows:

[0078]

[0079] In the formula, IG(D p , f i ) is the information gain of the node where the feature f i is located, D p is the data set of the parent node, D j is the data set of the split child nodes, H(D p ) is the information entropy of the parent node, and H(D j ) is the information entropy of the child nodes.

[0080] Through the above steps, the system can carefully evaluate the changes when splitting each node, accurately calculate the information gain of the features, thereby improving the accuracy and coverage of test case generation, and ensuring that the test cases can effectively detect the key behaviors and potential problems of the system.

[0081] Furthermore, the steps of dynamically combining the key use case features based on the requirement conditions to generate test cases specifically include:

[0082] Perform a preliminary combination of the key use case features based on the requirement conditions to obtain the initial test cases;

[0083] Import the initial test cases into the preset business software system and obtain the software test results;

[0084] Cross-validate the key test case features in the initial test cases according to the software test results until the software test results meet the preset test criteria, and obtain the generated test cases.

[0085] In this embodiment, the system first makes a preliminary combination of the screened key test case features according to the requirement conditions to generate a set of initial test cases. These initial test cases cover all important test scenarios, such as functions, boundary conditions, and possible abnormal situations. Then, the system imports these initial test cases into the preset business software system and runs the tests to obtain the corresponding test results. By analyzing the test results, the system can identify which feature combinations produce the expected results in actual execution and which do not meet the expectations. Based on these test feedbacks, the system will cross-validate the key test case features in the initial test cases, and repeatedly adjust through different combination methods to gradually optimize the accuracy and effectiveness of the test cases. This process will continue until the software test results meet the preset criteria, such as system stability, function coverage, etc., and finally obtain a set of complete and verified test cases.

[0086] Further, the system dynamically generates test cases based on the following formula:

[0087] TC new ={f i |FI(f i )>θ}

[0088] In the formula, TC new represents the newly generated test case set, and θ is the importance threshold, which is determined through cross-validation.

[0089] Through the above steps, through this dynamic optimization and verification process, the system can continuously adjust and optimize the generated test cases to ensure that the test results not only meet the requirements but also can effectively reveal potential defects in the system, thereby improving the quality and test efficiency of the software.

[0090] Further, the steps of cross-validating the key test case features in the initial test cases according to the software test results until the software test results meet the preset test criteria to obtain the generated test cases specifically include:

[0091] Classification of key test case features according to requirement conditions;

[0092] For each key test case feature category, perform key test case feature cross-rotation in sequence to generate a dynamic key test case feature set;

[0093] Import the dynamic key test case feature set into the preset business software system until all software test results that meet the preset test criteria are obtained, and obtain the generated test cases.

[0094] In this embodiment, the system first classifies the key use case features according to the requirement conditions, for example, classifying features such as input data type, boundary conditions, and functional requirements separately. Next, for each category, the system performs cross-rotation of the key use case features in turn. Through this cross-validation method, the system generates a dynamically updated set of key use case features. This set can cover a wider range of test scenarios to ensure that all possible feature combinations can be verified. Then, the system imports this dynamic feature set into a preset business software system for testing and continuously executes until all test results meet the preset standards, such as functional integrity, performance metrics, or security requirements. Once the standards are met, the system generates the final test cases.

[0095] Through the above steps, the system can continuously optimize the test cases, ensuring that the generated test cases not only cover all key scenarios but also precisely meet the requirements, significantly improving the test efficiency and accuracy.

[0096] Furthermore, when dynamically generating test cases, diversity constraints can be introduced to constrain the generation of test cases, ensuring that the generated test cases have sufficient diversity in feature combinations and avoiding repeated testing of similar scenarios. For example, different input data combinations, operation sequences, boundary conditions, etc. can be set to ensure that each test case covers different test angles and potential defects. At the same time, the system can flexibly adjust the constraint conditions according to actual requirements to optimize the test case generation process, thereby improving the comprehensiveness and effectiveness of testing. The formula for specific diversity constraints is as follows:

[0097]

[0098] In the formula, Diversity(DC) represents the diversity of the test case set TC, f i and f j represent different features in the test case set, and dist(f i , f j ) represents the distance metric between features f i and f j , such as Hamming distance or cosine similarity.

[0099] Furthermore, after the step of dynamically combining key use case features based on requirement conditions to generate test cases, it also includes:

[0100] Identifying the feature path coverage rate of each test case when performing use case testing in a preset business software system;

[0101] Calculating the execution priority level of the test case according to the feature path coverage rate;

[0102] Execute test cases according to the execution priority levels respectively.

[0103] In this embodiment, the system first identifies the feature path coverage rate when each test case is executed in a preset business software system. The feature path coverage rate reflects how many specific functional paths or critical paths are covered during the execution of the test case, ensuring that the test can effectively cover different modules and scenarios of the software. During the calculation, the system will analyze the feature combinations involved in each test case and evaluate their coverage of the system paths. Next, the system calculates the execution priority level of each test case based on its feature path coverage rate. Generally, test cases with a higher coverage rate have a higher priority because they can more comprehensively verify the system functions. Test cases with a lower priority may contain redundant or low-coverage scenarios. According to the calculated execution priority levels, the system executes the test cases in order of priority, ensuring that the most representative and important test cases are executed first, thereby maximizing the test coverage and the chance of defect discovery in the shortest time.

[0104] Furthermore, a priority model can be constructed to calculate the execution priority level of test cases. The formula for constructing the priority model is as follows:

[0105] Priority(TC i )=α*FI avg +β*Coverage(TC i )

[0106] In the formula, Priority(TC i ) represents the priority of test case TC i , FI avg represents the average importance of the features in test case TC i , Coverage(TC i ) represents the path coverage rate of test case TC i , and α and β are the weight parameters of the priority model, used to balance the influence of feature importance and path coverage rate. Among them, α = 0.7 and β = 0.3.

[0107] Through the above steps, with this priority execution strategy based on feature path coverage rate, the system can effectively optimize the test process, concentrate resources on executing those test cases that can maximize the test efficiency, thereby improving the test coverage rate, reducing redundancy, and accelerating defect location.

[0108] In the above embodiments, the present application discloses a method for automatically generating software test cases, belonging to the field of artificial intelligence technology, and is applied to online application scenarios of financial insurance and intelligent healthcare. By combining requirement condition parsing and the random forest algorithm, the present application realizes the automatic generation of software test cases. First, by parsing requirement conditions and extracting test case features, the core elements of test requirements can be accurately captured; second, the random forest algorithm is used to calculate feature weight values, scientifically quantifying the importance of each feature in test case generation and avoiding the deviation of manual subjective judgment; then, by setting a weight threshold to screen key use case features, redundant use cases are effectively reduced, and the pertinence and coverage rate of test cases are improved; finally, based on requirement conditions, key features are dynamically combined, and the generated test cases can flexibly adapt to different test scenarios, significantly improving test efficiency and quality.

[0109] In this embodiment, the electronic device (such as Figure 1 the server shown) on which the software test case automatic generation method runs can receive instructions or obtain data through a wired connection or a wireless connection. It should be noted that the above wireless connection methods can include but are not limited to 3G / 4G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra wideband) connections, and other currently known or future-developed wireless connection methods.

[0110] It should be emphasized that to further ensure the privacy and security of the above test case information, the above test case information can also be stored in a node of a blockchain.

[0111] The blockchain referred to in the present application is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. A blockchain, essentially a decentralized database, is a series of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity (anti-counterfeiting) of the information and generate the next block. A blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer, etc.

[0112] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is to use a digital computer or a machine controlled by a digital computer to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results in theory, method, technology, and application systems.

[0113] The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, robotics, biometric technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0114] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0115] It should be understood that although the steps in the flowchart of the accompanying drawings are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order restriction, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.

[0116] Further reference Figure 3 to Figure 2 As an implementation of the method shown above, an embodiment of a software test case automatic generation device is provided in this application. This device embodiment corresponds to the method embodiment shown in Figure 2 and this device can be specifically applied to various electronic devices.

[0117] As Figure 3 shown, the software test case automatic generation device 300 described in this embodiment includes:

[0118] A requirement condition module 301, configured to receive a test case generation instruction and obtain the requirement conditions corresponding to the test cases to be generated;

[0119] A use case feature module 302, configured to analyze the requirement conditions and extract the test case features corresponding to the test cases to be generated;

[0120] A feature weight module 303, configured to calculate a weight value of a test case feature based on a preset random forest algorithm, where the weight value represents the importance of the test case feature during test case generation;

[0121] A feature screening module 304, configured to set a weight threshold, and screen the test case features according to the weight threshold and the weight value to obtain key use case features;

[0122] A use case generation module 305, configured to dynamically combine the key use case features based on requirement conditions to generate test cases.

[0123] Further, the feature weight module 303 specifically includes:

[0124] A grouping unit, configured to group the test case features and identify the association relationships between the test case features in each feature group;

[0125] An initialization unit, configured to initialize the same number of random forest trees according to the number of feature groups;

[0126] An import unit, configured to, for each random forest tree, sequentially import the test case features and the association relationships of the corresponding group into the random forest tree, where the random forest tree includes nodes and edges, import the test case features into the nodes, and import the association relationships into the edges;

[0127] An information gain unit, configured to identify the information gain when each node of the random forest tree splits;

[0128] A weight calculation unit, configured to calculate the weight value of the test case feature based on the number of random forest trees and the information gain of each random forest tree.

[0129] Further, the import unit specifically includes:

[0130] A node determination subunit, configured to, for each test case feature group, determine the target node corresponding to each test case feature in the random forest tree according to the association relationship between the test case features;

[0131] A feature embedding subunit, configured to embed each test case feature into the corresponding target node;

[0132] An association relationship embedding subunit, configured to match the association relationship with the edge between the target nodes and embed the association relationship into the matched edge.

[0133] Further, the information gain unit specifically includes:

[0134] A node identification subunit, configured to, for each random forest tree, identify all nodes of the random forest tree;

[0135] A node splitting subunit, which is used to perform node splitting of a random forest tree by using a preset recursive selection algorithm. When performing node splitting, it is required to use each node of the random forest tree as a parent node for recursive splitting;

[0136] A splitting information acquisition subunit, which is used to, during each recursive splitting, acquire the feature set of the parent node, calculate the information entropy of the parent node, and at the same time acquire the feature sets of the split child nodes and calculate the information entropy of the split child nodes;

[0137] An information gain calculation subunit, which is used to calculate the information gain during node splitting of the random forest tree according to the feature set of the parent node, the information entropy of the parent node, the feature sets of the split child nodes, and the information entropy of the split child nodes.

[0138] Furthermore, the use case generation module 305 specifically includes:

[0139] A preliminary combination unit, which is used to perform a preliminary combination of key use case features based on requirement conditions to obtain initial test cases;

[0140] A preliminary testing unit, which is used to import the initial test cases into a preset business software system and obtain software test results;

[0141] A cross-validation unit, which is used to perform cross-validation on the key use case features in the initial test cases according to the software test results until the software test results meet the preset test standards to obtain generated test cases.

[0142] Furthermore, the cross-validation unit specifically includes:

[0143] A feature classification subunit, which is used to classify the key use case features according to requirement conditions;

[0144] A cross-rotation subunit, which is used to, for each key use case feature category, perform key use case feature cross-rotation in sequence to generate a dynamic key use case feature set;

[0145] An iterative testing subunit, which is used to import the dynamic key use case feature set into a preset business software system until all software test results that meet the preset test standards are obtained to obtain generated test cases.

[0146] Furthermore, the software test case automatic generation device 300 further includes:

[0147] A path coverage rate calculation module, which is used to identify the feature path coverage rate when each test case performs use case testing in a preset business software system;

[0148] An execution priority level module, which is used to calculate the execution priority level of the test cases according to the feature path coverage rate;

[0149] A test case execution module for executing test cases according to the execution priority levels respectively.

[0150] In the above embodiments, the present application discloses a software test case automatic generation device, belonging to the field of artificial intelligence technology, and is applied to online application scenarios of financial insurance and intelligent healthcare. The present application realizes the automatic generation of software test cases by combining requirement condition parsing and the random forest algorithm. First, by parsing the requirement conditions and extracting test case features, the core elements of the test requirements can be accurately captured; second, the random forest algorithm is used to calculate the feature weight values, scientifically quantifying the importance of each feature in test case generation and avoiding the deviation of manual subjective judgment; then, by setting a weight threshold to screen key use case features, redundant use cases are effectively reduced, and the pertinence and coverage rate of the test cases are improved; finally, based on the requirement conditions, the key features are dynamically combined, and the generated test cases can flexibly adapt to different test scenarios, significantly improving the test efficiency and quality.

[0151] To solve the above technical problems, the embodiments of the present application also provide a computer device. Specifically, please refer to Figure 4 , Figure 4 which is the basic structural block diagram of the computer device in this embodiment.

[0152] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are communicatively connected to each other through a system bus. It should be noted that only the computer device 4 with a memory 41, a processor 42, and a network interface 43 is shown in the figure, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be alternatively implemented. Among them, those skilled in the art of the present technology can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.

[0153] The computer device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The computer device can perform human-computer interaction with the user through a keyboard, a mouse, a remote control, a touchpad, a voice control device, or the like.

[0154] The memory 41 at least includes one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, FlashCard, etc. equipped on the computer device 4. Of course, the memory 41 may also include both the internal storage unit and the external storage device of the computer device 4. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions for the software test case automation generation method. In addition, the memory 41 may also be used to temporarily store various data that have been output or will be output.

[0155] In some embodiments, the processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the computer-readable instructions stored in the memory 41 or process data, such as running the computer-readable instructions for the software test case automation generation method.

[0156] The network interface 43 may include a wireless network interface or a wired network interface, and the network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0157] In the above embodiments, the present application discloses a computer device, belonging to the fields of artificial intelligence technology and fintech. By combining requirement condition parsing and the random forest algorithm, the present application realizes the automatic generation of software test cases. First, by parsing requirement conditions and extracting test case features, the core elements of test requirements can be accurately captured; second, the random forest algorithm is used to calculate feature weight values, scientifically quantifying the importance of each feature in test case generation and avoiding the deviation of manual subjective judgment; then, by setting a weight threshold to screen key use case features, redundant use cases are effectively reduced, and the pertinence and coverage rate of test cases are improved; finally, based on requirement conditions, key features are dynamically combined, and the generated test cases can flexibly adapt to different test scenarios, significantly improving test efficiency and quality.

[0158] The present application also provides another implementation manner, that is, to provide a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor, so that the at least one processor executes the steps of the software test case automatic generation method as described above.

[0159] In the above embodiments, the present application discloses a computer storage medium, belonging to the fields of artificial intelligence technology and fintech. By combining requirement condition parsing and the random forest algorithm, the present application realizes the automatic generation of software test cases. First, by parsing requirement conditions and extracting test case features, the core elements of test requirements can be accurately captured; second, the random forest algorithm is used to calculate feature weight values, scientifically quantifying the importance of each feature in test case generation and avoiding the deviation of manual subjective judgment; then, by setting a weight threshold to screen key use case features, redundant use cases are effectively reduced, and the pertinence and coverage rate of test cases are improved; finally, based on requirement conditions, key features are dynamically combined, and the generated test cases can flexibly adapt to different test scenarios, significantly improving test efficiency and quality.

[0160] Through the description of the above implementation manners, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation manner. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc), including several instructions for causing a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present application.

[0161] This application can be used in numerous general-purpose or special-purpose computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This application can also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0162] It should be noted that the non-company software tools or components appearing in various embodiments of this application are only introduced by way of example and do not represent actual use.

[0163] Obviously, the above-described embodiments are only a part of the embodiments of this application, rather than all of them. The accompanying drawings show the preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosed content of this application more thorough and comprehensive. Although this application has been described in detail with reference to the foregoing embodiments, for those skilled in the art, they can still modify the technical solutions described in the foregoing specific embodiments, or perform equivalent replacements on some of the technical features. Any equivalent structures directly or indirectly using the content of this application's specification and drawings in other related technical fields are equally within the scope of this application's patent protection.

Claims

1. A method for automatically generating software test cases, characterized in that: include: Receive test case generation instructions and obtain requirement conditions corresponding to the test case to be generated; Analyze the requirement conditions and extract test case features corresponding to the test case to be generated; Calculating the weight value of the test case feature based on a preset random forest algorithm, wherein the weight value represents the importance of the test case feature when the test case is generated; Setting a weight threshold, screening the test case features according to the weight threshold and the weight value, and obtaining key test case features; The key use case features are dynamically combined based on the requirement conditions to generate test cases.

2. The method for automatically generating software test cases according to claim 1, characterized in that: The step of calculating the weight value of the test case feature based on the preset random forest algorithm specifically includes: Grouping the test case features, and identifying associations between the test case features in each feature group; Initialize the same number of random forest trees according to the number of feature groups; For each random forest tree, the test case features and the association relationships of the corresponding group are sequentially imported into the random forest tree, wherein the random forest tree includes nodes and edges, the test case features are imported into the nodes, and the association relationships are imported into the edges; Identify the information gain when splitting each random forest tree node; Based on the number of the random forest trees and the information gain of each of the random forest trees, a weight value of the test case feature is calculated.

3. The method for automatically generating software test cases according to claim 2, characterized in that: The step of sequentially importing the test case features and the association relationships of the corresponding groups into the random forest tree for each random forest tree specifically includes: For each test case feature group, determine the target node corresponding to each test case feature in the random forest tree according to the correlation relationship between the test case features; Embed each test case feature into the corresponding target node; The association relationship is matched with the edge between the target nodes, and the association relationship is embedded into the matched edge.

4. The method for automatically generating software test cases according to claim 2, characterized in that: The step of identifying the information gain when each random forest tree node is split specifically includes: For each random forest tree, identifying all nodes of the random forest tree; A preset recursive selection algorithm is used to perform node splitting of the random forest tree. When splitting the node, each node of the random forest tree is required to be recursively split as a parent node; At each recursive split, the feature set of the parent node is obtained and the information entropy of the parent node is calculated. At the same time, the feature set of the child node after the split is obtained and the information entropy of the child node after the split is calculated. The information gain when the random forest tree node is split is calculated according to the feature set of the parent node, the information entropy of the parent node, the feature set of the child node after the split, and the information entropy of the child node after the split.

5. The method for automatically generating software test cases according to claim 3, characterized in that: The step of dynamically combining the key use case features based on the requirement conditions to generate test cases specifically includes: Preliminarily combining the key use case features based on the requirement conditions to obtain an initial test case; Importing the initial test case into a preset business software system and obtaining software test results; The key test case features in the initial test case are cross-validated according to the software test results until the software test results meet the preset test standards, thereby generating test cases.

6. The method for automatically generating software test cases according to claim 5, characterized in that: The step of cross-validating the key test case features in the initial test case according to the software test result until the software test result reaches a preset test standard to generate a test case specifically includes: Classification of the key use case characteristics according to the requirements; For each key use case feature category, the key use case features are rotated in turn to generate a dynamic key use case feature set; The dynamic key use case feature set is imported into a preset business software system until all software test results that meet the preset test standards are obtained, thereby generating test cases.

7. The method for automatically generating software test cases according to claim 1, characterized in that: After the step of dynamically combining the key use case features based on the requirement conditions to generate test cases, the method further includes: Identify the characteristic path coverage of each test case when performing case testing in a preset business software system; Calculating the execution priority of the test case according to the feature path coverage; The test cases are executed respectively according to the execution priority levels.

8. A software test case automatic generation device, characterized in that: include: The requirement condition module is used to receive the test case generation instruction and obtain the requirement conditions corresponding to the test case to be generated; A test case feature module, used to parse the requirement conditions and extract test case features corresponding to the test case to be generated; A feature weight module, used to calculate the weight value of the test case feature based on a preset random forest algorithm, wherein the weight value represents the importance of the test case feature when the test case is generated; A feature screening module, used to set a weight threshold, screen the test case features according to the weight threshold and the weight value, and obtain key test case features; The use case generation module is used to dynamically combine the key use case features based on the requirement conditions to generate test cases.

9. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the method for automatically generating software test cases as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the method for automatically generating software test cases according to any one of claims 1 to 7.