Test case generation method and device, electronic equipment and storage medium

By using methods to automatically generate test cases and leveraging clustering and sequence prediction techniques based on object operation behavior, the problem of time-consuming and labor-intensive manual test case writing has been solved. This has enabled efficient and accurate test case generation, thereby improving the efficiency and quality of software testing.

CN120994554APending Publication Date: 2025-11-21CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511103451.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-06
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Manually writing test cases is time-consuming and labor-intensive, resulting in low software testing efficiency. This is especially true in fintech and digital healthcare scenarios, where existing technologies struggle to efficiently generate test cases when testing sensitive information and functions is required.

Method used

By acquiring object operation behavior, clustering and sequence prediction are performed to generate test cases that conform to actual business scenarios, including feature extraction, cluster center update, sequence generation and dynamic operation adjustment, and test cases are automatically generated.

Benefits of technology

It improves the efficiency and accuracy of test case generation, covers more behavioral patterns, and enhances the efficiency and quality of software testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994554A_ABST
    Figure CN120994554A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a test case generation method and device, electronic equipment and a storage medium, belongs to the technical field of computers, and is suitable for the field of financial science and technology and the field of digital medical treatment. The method comprises the steps of obtaining object operation behaviors, clustering the object operation behaviors to obtain an operation behavior cluster which is provided with a target cluster center, performing sequence prediction on the target cluster center through a sequence generation model to obtain an operation behavior sequence, screening out target operation from a preset action space according to the operation behavior sequence, and executing the target operation on the operation behavior sequence to obtain the target behavior sequence, and generating the target test case according to the target behavior sequence, so that the software test efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and is applied to the fields of financial technology and digital healthcare. In particular, it relates to a test case generation method, device, electronic device, and storage medium. Background Technology

[0002] In software development, feature development or code modifications can impact software performance. To ensure software system quality, testing is essential. For example, in fintech scenarios, financial software systems process large amounts of sensitive financial data, such as user account information and transaction records. To ensure the security of this data, the access functions of the financial software system need to be tested to prevent unauthorized third-party access. Similarly, in digital healthcare scenarios, functions of medical software systems, such as diagnostic report generation and medication management, may not function correctly. To ensure the proper functioning of medical software systems, software testing is necessary. In related technologies, software testing is performed by writing test cases; however, manually writing test cases is time-consuming and labor-intensive, resulting in low efficiency in software testing. Summary of the Invention

[0003] The main objective of this application is to provide a test case generation method, apparatus, electronic device, and storage medium, which aims to improve the efficiency of software testing.

[0004] To achieve the above objectives, a first aspect of this application proposes a test case generation method, the method comprising:

[0005] Get the object's operation behavior;

[0006] The operation behaviors of the object are clustered to obtain operation behavior clusters; wherein, the operation behavior clusters have target cluster centers;

[0007] The target cluster center is predicted using a sequence generation model to obtain the operation behavior sequence;

[0008] Target operations are selected from a preset action space based on the operation behavior sequence;

[0009] The target operation is performed on the sequence of operation behaviors to obtain the target behavior sequence;

[0010] Target test cases are generated based on the target behavior sequence.

[0011] In some embodiments, clustering the object operation behaviors to obtain operation behavior clusters includes:

[0012] Feature extraction is performed on the object's operational behavior to obtain operational behavior features;

[0013] The operational behavior features are filtered according to a preset number of clusters to obtain the original cluster centers;

[0014] Calculate the feature distance between the operational behavior feature and the original cluster center;

[0015] The operation behavior features are clustered based on the feature distance to obtain the operation behavior cluster.

[0016] In some embodiments, clustering the operational behavior features based on the feature distance to obtain the operational behavior cluster includes:

[0017] Cluster the operational behavior features based on the feature distance to obtain a reference behavior cluster;

[0018] The original cluster centers are updated based on the reference behavior clusters to obtain reference cluster centers;

[0019] The target number of clusters is obtained by filtering the preset number of clusters based on the reference behavior clusters and the reference cluster centers.

[0020] The reference behavior clusters are filtered based on the target cluster number to obtain the operation behavior clusters.

[0021] In some embodiments, the step of filtering the preset number of clusters based on the reference behavioral clusters and the reference cluster centers to obtain the target number of clusters includes:

[0022] Calculate the target distance between the reference behavior cluster and the reference cluster center;

[0023] Draw a graph showing the relationship between the preset number of clusters and the target distance;

[0024] The target number of clusters is obtained by filtering the preset number of clusters based on the relationship diagram.

[0025] In some embodiments, the step of filtering the preset number of clusters based on the reference behavioral clusters and the reference cluster centers to obtain the target number of clusters includes:

[0026] Calculate the intra-cluster density based on the reference behavior cluster and the reference cluster center;

[0027] Calculate the inter-cluster separation degree based on the reference behavior cluster and the reference cluster center;

[0028] The profile coefficient is determined based on the intra-cluster compactness and the inter-cluster separation.

[0029] The target number of clusters is obtained by filtering the preset number of clusters based on the silhouette coefficient.

[0030] In some embodiments, the preset action space includes reference operations, and the step of filtering target operations from the preset action space according to the sequence of operation behaviors includes:

[0031] The operation sequence and the reference operation are scored using an action selection model to obtain the operation score of the reference operation;

[0032] The reference operations are filtered based on the operation scores to obtain the target operations.

[0033] In some embodiments, after generating target test cases based on the target behavior sequence, the test case generation method further includes:

[0034] Obtain system load parameters using testing tools;

[0035] The thread concurrency is obtained based on the system load parameters.

[0036] Configure the testing tool according to the thread concurrency level, and execute the target test cases according to the configured testing tool.

[0037] To achieve the above objectives, a second aspect of this application provides a test case generation apparatus, the apparatus comprising:

[0038] The acquisition module is used to acquire object operation behavior;

[0039] A clustering module is used to cluster the operation behaviors of the object to obtain operation behavior clusters; wherein, the operation behavior clusters have target cluster centers;

[0040] The prediction module is used to predict the sequence of the target cluster center through a sequence generation model to obtain the operation behavior sequence;

[0041] The filtering module is used to filter out target operations from a preset action space based on the operation behavior sequence;

[0042] An execution module is used to perform the target operation on the operation sequence to obtain the target behavior sequence;

[0043] The generation module is used to generate target test cases based on the target behavior sequence.

[0044] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.

[0045] To achieve the above objectives, a fourth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.

[0046] The test case generation method, device, electronic device, and computer-readable storage medium proposed in this application automatically generate test cases that closely resemble real-world business scenarios by acquiring object operation behaviors. Object operation behaviors are clustered to capture behavior patterns, resulting in operation behavior clusters. Each operation behavior cluster has a target cluster center, representing the object behavior pattern. Object behaviors exhibit temporal order and dependency; a sequence generation model is used to predict the sequence of target cluster centers to capture temporal dependencies, generating a sequence that matches the actual object behavior, thus obtaining an operation behavior sequence. To ensure that the generated test cases cover more behavior patterns, target operations are selected from a preset action space based on the operation behavior sequence. These target operations are then executed on the operation behavior sequence to dynamically adjust the operation behavior sequence, resulting in a target behavior sequence. Target test cases are then generated based on this target behavior sequence, enabling automatic test case generation and improving software testing efficiency. Attached Figure Description

[0047] Figure 1 This is a flowchart of the test case generation method provided in the embodiments of this application;

[0048] Figure 2 yes Figure 1 The flowchart of step S120 in the middle;

[0049] Figure 3 yes Figure 2 The flowchart of step S240 in the text;

[0050] Figure 4 yes Figure 3 The flowchart of step S330 in the text;

[0051] Figure 5 yes Figure 3 Another flowchart of step S330 in the process;

[0052] Figure 6 yes Figure 1 The flowchart of step S140 in the middle;

[0053] Figure 7 This is another flowchart of the test case generation method provided in the embodiments of this application;

[0054] Figure 8 This is a schematic diagram of the test case generation device provided in the embodiments of this application;

[0055] Figure 9 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0056] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0057] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0059] In software development, feature development or code modifications can impact software performance. To ensure software system quality, testing is essential. For example, in fintech scenarios, financial software systems process large amounts of sensitive financial data, such as user account information and transaction records. To ensure the security of this data, the access functions of the financial software system need to be tested to prevent unauthorized third-party access. Similarly, in digital healthcare scenarios, functions of medical software systems, such as diagnostic report generation and medication management, may not function correctly. To ensure the proper functioning of medical software systems, software testing is necessary. In related technologies, software testing is performed by writing test cases; however, manually writing test cases is time-consuming and labor-intensive, resulting in low efficiency in software testing.

[0060] Based on this, embodiments of this application provide a test case generation method, a test case generation device, an electronic device, and a computer-readable storage medium, aiming to improve the efficiency of software testing.

[0061] The test case generation method, test case generation device, electronic device, and computer-readable storage medium provided in this application are specifically described through the following embodiments. First, the test case generation method in this application is described.

[0062] The test case generation method provided in this application relates to the field of computer technology. The test case generation method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the test case generation method, but is not limited to the above forms.

[0063] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. 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 distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0064] Figure 1 This is an optional flowchart of the test case generation method provided in the embodiments of this application. Figure 1 The method may include, but is not limited to, steps S110 to S160.

[0065] Step S110: Obtain object operation behavior;

[0066] Step S120: Cluster the object operation behaviors to obtain operation behavior clusters; wherein, the operation behavior clusters have target cluster centers;

[0067] Step S130: Predict the sequence of the target cluster center using a sequence generation model to obtain the operation behavior sequence;

[0068] Step S140: Select the target operation from the preset action space according to the operation behavior sequence;

[0069] Step S150: Perform the target operation on the operation sequence to obtain the target action sequence;

[0070] Step S160: Generate target test cases based on the target behavior sequence.

[0071] Steps S110 to S160 shown in the embodiments of this application improve the efficiency of test case generation by automatically generating test cases, compared with manually coding test cases, thereby improving the efficiency of software testing.

[0072] In step S110 of some embodiments, object operation behavior refers to various operation behaviors and their patterns performed by the user on the software system. Object operation behavior includes operation path, operation frequency, time distribution, input / output data, and boundary conditions. The operation path describes the entire process from entering the software system to completing the task. For example, the operation path for purchasing insurance products is: browsing the homepage → searching for insurance products → viewing product details → adding to cart → completing payment. Operation frequency refers to the number of times a user performs a certain operation within a certain period, such as the number of times the user logs into the system each week or the frequency of clicking buttons. Time distribution refers to the user's behavior patterns in different time periods; for example, users use office software more on weekdays and entertainment software more on weekends. Input / output data refers to the data input by the user during the operation and the output results returned by the software system, including request parameters and response parameters. Boundary conditions refer to the limits set by the system when the user performs an operation, such as the maximum number of requests the system can process simultaneously.

[0073] You can set up tracking points on the front-end webpage of the software system to record object operation behaviors, or you can obtain the system log files of the software system. The system log files can be user operation logs or application interface call logs. Object operation behaviors can be extracted from the system log files, or they can be obtained from database records. Each data record can be regarded as an object operation behavior.

[0074] To improve the accuracy of test case generation, data cleaning is performed on object operation behaviors to remove noisy data such as duplicates and invalid data. Data formatting is also performed to ensure data quality. To identify user behavior patterns, such as frequently called interface combinations and specific operation paths, object operation behaviors are clustered to obtain operation behavior clusters. The clustering process is described in detail below.

[0075] Please see Figure 2 In some embodiments, step S120 may include, but is not limited to, steps S210 to S240:

[0076] Step S210: Extract features from the object's operation behavior to obtain operation behavior features;

[0077] Step S220: Select the features of the operation behavior according to the preset number of clusters to obtain the original cluster centers;

[0078] Step S230: Calculate the feature distance between the operational behavior features and the original cluster centers;

[0079] Step S240: Cluster the operation behavior features based on feature distance to obtain operation behavior clusters.

[0080] In step S210 of some embodiments, the object operation behavior is extracted by a convolutional neural network, and the object operation behavior is converted into a feature vector to extract key features such as interface call frequency, request parameter combination, operation path, etc., and redundant features are removed to obtain operation behavior features.

[0081] In step S220 of some embodiments, the preset number of clusters is a pre-defined number of cluster centers, which is an integer greater than 0 and less than or equal to a preset number of data points, and the preset number of data points is the number of object operation behaviors. Operation behavior features are randomly selected as original cluster centers, and the number of original cluster centers is equal to the preset number of clusters.

[0082] In step S230 of some embodiments, the Euclidean distance between the operational behavior feature and each original cluster center corresponding to a preset number of clusters is calculated to obtain the feature distance between the operational behavior feature and each original cluster center. The feature distance is used to measure the similarity between the operational behavior feature and the original cluster centers. The larger the feature distance, the smaller the similarity between the operational behavior feature and the original cluster centers.

[0083] In step S240 of some embodiments, the operation behavior features are assigned to the original cluster centers with the smallest feature distance, resulting in operation behavior clusters. The number of operation behavior clusters is equal to the preset number of clusters. Each operation behavior cluster represents a user's behavior pattern; for example, one operation behavior cluster may represent a combination of frequently called interfaces, another may represent an operation path in a specific scenario, and yet another may represent abnormal operation behavior. Each operation behavior cluster has a target cluster center, which is obtained by updating the original cluster centers using the operation behavior features located within the cluster. The target cluster center can be obtained by calculating the mean of all operation behavior features located within the cluster.

[0084] Clustering can extract different user behavior patterns, and test cases covering multiple scenarios can be generated based on these patterns, including normal scenarios, abnormal scenarios (such as network latency and service unavailability), and boundary condition scenarios.

[0085] Through steps S210 to S240 above, user behavior patterns can be obtained, and test cases that conform to the actual scenario can be generated based on user behavior patterns.

[0086] Please see Figure 3 In some embodiments, step S240 may include, but is not limited to, steps S310 to S340:

[0087] Step S310: Cluster the operation behavior features based on feature distance to obtain reference behavior clusters;

[0088] Step S320: Update the original cluster centers according to the reference behavior clusters to obtain the reference cluster centers;

[0089] Step S330: Filter the preset number of clusters based on the reference behavior clusters and reference cluster centers to obtain the target number of clusters;

[0090] Step S340: Filter the reference behavior clusters according to the target cluster number to obtain the operation behavior clusters.

[0091] In step S310 of some embodiments, the operational behavior features are assigned to the original cluster centers with the smallest feature distance to obtain reference behavior clusters.

[0092] In step S320 of some embodiments, the mean value of all operational behavior features located within the reference behavior cluster is calculated to obtain the mean feature. The original cluster centers are then updated with the mean feature to obtain the reference cluster centers.

[0093] In step S330 of some embodiments, an excessive number of cluster centers increases computational load and results in too few operational behavior features within each cluster, with high similarity, leading to poor adaptability to new operational behavior data. Conversely, an insufficient number of cluster centers means that operational behavior features representing different behavior patterns are clustered into the same cluster, resulting in significant differences in the operational behavior features within each cluster and failing to accurately reflect different user behavior patterns. Therefore, to better capture the behavioral patterns of object operations, the number of cluster centers, i.e., the preset number of clusters, needs to be optimized.

[0094] Multiple preset cluster numbers can be set, such as 1, 2, 3, ..., K, where K is an integer greater than 0 and less than or equal to the number of object operation behaviors. The preset cluster numbers are filtered based on the reference behavior cluster and the reference cluster center to obtain the optimal number of cluster centers and the target number of clusters.

[0095] In step S340 of some embodiments, clustering the operation behavior features according to different preset cluster numbers will yield different reference behavior clusters. Selecting the reference behavior cluster corresponding to the target cluster number yields the operation behavior cluster. Each operation behavior cluster has a target cluster center, which is the reference cluster center of the reference behavior cluster corresponding to the target cluster number.

[0096] By going through steps S310 to S340 above, the optimal number of cluster centers can be obtained. By performing feature clustering according to the optimal number of cluster centers, user behavior patterns can be accurately captured, and the efficiency of behavior pattern analysis can be improved.

[0097] Please see Figure 4 In some embodiments, step S330 may include, but is not limited to, steps S410 to S430:

[0098] Step S410: Calculate the target distance between the reference behavior cluster and the reference cluster center;

[0099] Step S420: Draw a graph showing the relationship between the preset number of clusters and the target distance;

[0100] Step S430: Filter the preset number of clusters according to the relationship diagram to obtain the target number of clusters.

[0101] In step S410 of some embodiments, the sum of squares of the distances between each operational behavior feature within a reference behavior cluster and the reference cluster center is calculated to obtain the cluster distance. The cluster distances of each reference behavior cluster are then summed to obtain the target distance. The formula for calculating the target distance is expressed as:

[0102]

[0103] Where k is the preset number of clusters; C i Let x be the i-th reference behavior cluster; let x be the operational behavior feature located within the i-th reference behavior cluster; μ i It serves as the reference cluster center for the i-th reference behavior cluster.

[0104] In step S420 of some embodiments, a curve is plotted using a preset number of clusters as the horizontal axis and the target distance between the reference behavior clusters obtained by clustering according to the preset number of clusters and the reference cluster centers of the reference behavior clusters as the vertical axis, to obtain a relationship diagram.

[0105] In step S430 of some embodiments, the difference between two adjacent preset cluster numbers is calculated according to the relationship graph, following the order of the preset cluster numbers from smallest to largest. The distance reduction between the target distances corresponding to two adjacent preset cluster numbers is then calculated according to the relationship graph. The distance reduction is divided by the difference to obtain the distance reduction rate. The speed reduction between two adjacent distance reduction rates is calculated, and the speed reduction is divided by the difference to obtain the target acceleration. The preset cluster number whose target acceleration changes from positive to negative is taken as the target cluster number.

[0106] Through the above steps S410 to S430, a better number of cluster centers can be obtained.

[0107] Please see Figure 5 In some embodiments, step S330 may also include, but is not limited to, steps S510 to S540:

[0108] Step S510: Calculate the intra-cluster compactness based on the reference behavioral clusters and reference cluster centers;

[0109] Step S520: Calculate the inter-cluster separation based on the reference behavioral clusters and reference cluster centers;

[0110] Step S530: Determine the profile coefficient based on intra-cluster compactness and inter-cluster separation.

[0111] Step S540: Filter the preset number of clusters based on the silhouette coefficient to obtain the target number of clusters.

[0112] In step S510 of some embodiments, intra-cluster tightness is used to measure the similarity between operational behavior features within the same cluster. The distance between each operational behavior feature within the reference behavior cluster and the reference cluster center of the reference behavior cluster is calculated, and the mean of each distance is calculated to obtain the intra-cluster tightness.

[0113] In step S520 of some embodiments, the inter-cluster separation is used to measure the difference between different clusters. For each reference behavior cluster, the Euclidean distance between the reference cluster center of the current reference behavior cluster and the reference cluster center of any other reference behavior cluster is calculated, and the other reference behavior cluster with the smallest Euclidean distance is selected as the intermediate cluster. The distance between each operation behavior feature in the current reference behavior cluster and the reference cluster center of the intermediate cluster is calculated, and the average distance of each operation behavior feature is calculated to obtain the inter-cluster separation between the current reference behavior cluster and the intermediate cluster.

[0114] In step S530 of some embodiments, the maximum inter-cluster separation is selected from the inter-cluster separation of each reference behavioral cluster to obtain the maximum separation. The maximum separation is subtracted from the intra-cluster compactness to obtain the intermediate difference. The maximum value of the intra-cluster compactness and the inter-cluster separation is selected. The ratio between the intermediate difference and the maximum value is calculated to obtain the profile coefficient.

[0115] In step S540 of some embodiments, a preset number of clusters corresponds to a silhouette coefficient. The larger the silhouette coefficient, the better the clustering effect of the object operation behavior. The preset number of clusters with the largest silhouette coefficient is selected as the target number of clusters.

[0116] Steps S510 to S540 above improve the efficiency of contour coefficient calculation by combining cluster centers, thereby improving the efficiency of behavior pattern recognition.

[0117] In step S130 of some embodiments, the user's browsing behavior, purchasing behavior, etc., on the software system have a temporal sequence. To capture temporal dependencies, a Long Short-Term Memory (LSTM) network can be used as a sequence generation model. The target cluster center is input into the sequence generation model for sequence prediction to determine the operation path based on the user's behavior pattern, thus obtaining the operation behavior sequence. The operation behavior sequence ensures that test cases can cover the logical dependencies between interfaces, improving the coherence and realism of the tests. For example, when purchasing an insurance product, the operation behavior sequence could be [browse insurance products, add to cart, view cart, modify cart, submit order, pay order, view order status]. For example, when handling hospital admission procedures, the operation behavior sequence could be [create patient record, enter patient information, click the admission button].

[0118] Please see Figure 6 In some embodiments, the preset action space includes reference operations, which include insertion, deletion, update, or termination operations. An insertion operation adds a new operation to the action sequence; a deletion operation removes an existing operation from the action sequence; an update operation modifies an operation in the action sequence; and a termination operation terminates the operation on the action sequence. Step S140 may include, but is not limited to, steps S610 to S620.

[0119] Step S610: The action selection model is used to score the action sequence and the reference action to obtain the action score of the reference action.

[0120] Step S620: Filter the reference operations based on the operation scores to obtain the target operations.

[0121] In step S610 of some embodiments, to dynamically generate more comprehensive and effective test cases and thus improve the quality of software testing, reinforcement learning is introduced to dynamically adjust the sequence of operation behaviors. The action selection model is a deep Q-network. The sequence of operation behaviors and reference operations in a preset action space are input into the action selection model for scoring, and the operation score of the reference operation is obtained. The operation score is the Q value output by the action selection model.

[0122] The training process of the action selection model is as follows:

[0123] The process involves acquiring a sample behavior sequence, a source Q-network, and a target Q-network. A greedy probability is determined, and candidate actions are randomly selected from a predefined action space based on this probability. Alternatively, the sample behavior sequence and reference actions are input into the source Q-network based on the greedy probability, and the reference action with the largest Q-value output by the source Q-network is selected as the candidate action. The candidate actions are then executed on the sample behavior sequence to obtain an updated behavior sequence, and the reward score for executing the candidate actions is obtained. The updated behavior sequence and each reference action are input into the target Q-network to obtain the Q-value output by the target Q-network for each reference action, and the largest Q-value is selected. The reward score is added to the largest Q-value output by the target Q-network to obtain the target Q-value. The sample behavior sequence and candidate actions are then input into the source Q-network to obtain the original Q-value. The mean squared error between the target Q-value and the original Q-value is calculated to obtain the target loss. The model parameters of the source Q-network are updated by minimizing the target loss to obtain the action selection model. During training, the model parameters of the target Q-network are updated to the model parameters of the source Q-network every predefined time interval.

[0124] It should be noted that test cases can be generated based on the update behavior sequence. Executing these test cases will award a positive score if the test case executes successfully, and a negative score if the test case fails. Positive and negative scores are opposites; for example, a positive score is 1, and a negative score is -1.

[0125] In step S620 of some embodiments, in order to obtain the optimal action, the reference operation with the largest operation score is selected from the preset action space as the target operation.

[0126] Through steps S610 to S620 above, the optimal operation can be obtained, and the behavior sequence can be dynamically adjusted based on the optimal operation to generate high-quality and diverse test cases.

[0127] In step S150 of some embodiments, if the target operation is an insertion operation, the operation behavior sequence is input into a sequence generation model for operation behavior prediction to obtain the insertion position and operation behavior. Based on the insertion position, an operation behavior is added to the operation behavior sequence to obtain the target behavior sequence. For example, if a user's operation behavior sequence in a medical system is [Login, Search for Patients, Logout], the sequence generation model predicts the operation behavior sequence, resulting in an insertion position of 2 and the operation behavior being "View Patient Information". The operation behavior of "View Patient Information" is inserted at the second position of the operation behavior sequence, resulting in the target behavior sequence [Login, View Patient Information, Search for Patients, Logout].

[0128] The action sequence includes multiple actions. If the target action is deletion, one action is randomly deleted from the action sequence to obtain the target action sequence. For example, if the action sequence is [Login, Search for Patients, Logout], deleting the action "Search for Patients" will result in the target action sequence [Login, Logout].

[0129] If the target operation is an update operation, then any two operations are randomly selected from the operation sequence and swapped, or the operation sequence is input into a sequence generation model to predict the operation, obtaining the update position and reference operation. The operation at the update position in the operation sequence is then updated to the reference operation to obtain the target operation sequence. For example, if the operation sequence is [Login, Search Patient, Logout], the update position is 2, and the reference operation is to update patient information, then the target operation sequence is [Login, Update Patient Information, Logout].

[0130] If the target operation is a termination operation, no operation is performed on the operation sequence, and the operation sequence is directly used as the target operation sequence.

[0131] In step S160 of some embodiments, each operation in the target behavior sequence is sequentially converted into test operations to generate target test cases. A target test case is a set of test inputs, execution conditions, and expected results designed for a specific test objective. For example, if the target behavior sequence is [Login, Search Patient, Logout], the test operation for login is to call the login interface and enter the username and password; the test operation for searching patients is to call the patient search interface and enter the patient ID; and the test operation for logout is to call the logout interface.

[0132] Please see Figure 7 In some embodiments, after step S160, the test case generation method may include, but is not limited to, steps S710 to S730:

[0133] Step S710: Obtain system load parameters using testing tools;

[0134] Step S720: Obtain thread concurrency based on system load parameters;

[0135] Step S730: Configure the test tool according to the thread concurrency and execute the target test cases according to the configured test tool.

[0136] In step S710 of some embodiments, the testing tool has the function of detecting various indicators of the software system, such as computing resource utilization and memory usage. The load of the software system is obtained through the testing tool, and the system load coefficient is obtained. The system load coefficient includes computing resource utilization (CPU utilization) and memory usage.

[0137] In step S720 of some embodiments, a first utilization threshold and a second utilization threshold are set for resource utilization. The first utilization threshold is less than the second utilization threshold, and both the first and second utilization thresholds are greater than 0 and less than 1. The first utilization threshold can be 40%, and the second utilization threshold can be 70%. Similarly, a first utilization threshold and a second utilization threshold are set for memory occupancy. The first utilization threshold is less than the second utilization threshold, and both the first and second utilization thresholds are greater than 0 and less than 1. The first utilization threshold can be 60%, and the second utilization threshold can be 80%.

[0138] If resource utilization is less than the first utilization threshold, or memory usage is less than the first utilization threshold, it indicates that the software system is under low load. To improve system resource utilization, the current concurrency level is incrementally increased to obtain the thread concurrency level. The current concurrency level is the currently set concurrency level, and the thread concurrency level is the number of threads that the software system can run simultaneously. During the incremental processing, the current concurrency level can be incremented by 1 until the resource utilization is greater than or equal to the first utilization threshold, or the memory usage is greater than or equal to the first utilization threshold, at which point the system jumps to the specific processing logic.

[0139] If the resource utilization rate is greater than or equal to the first utilization rate threshold and less than the second utilization rate threshold, or the memory utilization rate is greater than or equal to the first utilization rate threshold and less than the second utilization rate threshold, it indicates that the software system is in a medium load state, and the current concurrency level is taken as the thread concurrency level.

[0140] If the resource utilization rate is greater than or equal to the second utilization rate threshold, or the memory usage rate is greater than or equal to the second usage rate threshold, it indicates that the software system is under high load. In this case, the current concurrency level is reduced to obtain the thread concurrency level. During the reduction process, the current concurrency level can be gradually decreased by 1 until the resource utilization rate is less than the second utilization rate threshold, or the memory usage rate is less than the second usage rate threshold, at which point the system jumps to the specific processing logic.

[0141] In step S730 of some embodiments, the concurrency parameter of the testing tool is set to the thread concurrency. The testing tool starts an asynchronous thread according to the thread concurrency and executes the target test cases concurrently through the asynchronous thread to test the software system, thereby improving the efficiency of software testing.

[0142] Testing tools typically generate test cases based on fixed rules, failing to dynamically adapt to changes in user behavior, resulting in insufficient consistency and realism of test cases. This application's embodiment dynamically generates test cases based on user behavior patterns, enabling test cases to accurately simulate real user business operations, thus improving the consistency and realism of test cases.

[0143] Obtain the test results from executing the target test cases and store them in the database. Based on the test results, system optimization suggestions can be proposed, such as optimizing interface logic and adjusting system resource allocation. Based on the test results and optimization suggestions, iteratively improve the system, regenerate test cases, and execute them to verify the optimization effects. Test results include the target test case number, execution status (e.g., success or failure), and execution time.

[0144] Steps S710 to S730 above dynamically adjust the thread concurrency based on system load, enabling test cases to be executed dynamically according to system load, thereby improving the execution efficiency of test cases and thus improving the efficiency of software testing.

[0145] Please see Figure 8 This application also provides a test case generation apparatus that can implement the above-described test case generation method. The test case generation apparatus includes:

[0146] Module 810 is used to obtain object operation behavior;

[0147] Clustering module 820 is used to cluster object operation behaviors to obtain operation behavior clusters; wherein, the operation behavior clusters have target cluster centers;

[0148] Prediction module 830 is used to predict the sequence of the target cluster center through a sequence generation model to obtain the operation behavior sequence;

[0149] The filtering module 840 is used to filter target operations from a preset action space based on the sequence of operation behaviors;

[0150] Execution module 850 is used to perform target operations on the sequence of operation behaviors to obtain the target sequence of behavior.

[0151] The generation module 860 is used to generate target test cases based on the target behavior sequence.

[0152] The specific implementation of this test case generation device is basically the same as the specific implementation of the test case generation method described above, and will not be repeated here.

[0153] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described test case generation method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.

[0154] Please see Figure 9 , Figure 9 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:

[0155] The processor 910 can be implemented using a general-purpose central processing unit (CPU), microprocessor, application specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.

[0156] The memory 920 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 920 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 920 and is called and executed by the processor 910 using the test case generation method of the embodiments of this application.

[0157] The input / output interface 930 is used to implement information input and output;

[0158] The communication interface 940 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0159] Bus 950 transmits information between various components of the device (e.g., processor 910, memory 920, input / output interface 930, and communication interface 940);

[0160] The processor 910, memory 920, input / output interface 930 and communication interface 940 are connected to each other within the device via bus 950.

[0161] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described test case generation method.

[0162] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0163] The test case generation method, test case generation device, electronic device, and computer storage medium provided in this application improve the efficiency of test case generation by automatically generating test cases compared with manually coding test cases, thereby improving the efficiency of software testing.

[0164] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0165] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0166] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0167] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0168] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0169] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0170] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0171] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0172] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0173] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0174] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A test case generation method, characterized in that, The method includes: Get the object's operation behavior; The operation behaviors of the object are clustered to obtain operation behavior clusters; wherein, the operation behavior clusters have target cluster centers; The target cluster center is predicted using a sequence generation model to obtain the operation behavior sequence; Target operations are selected from a preset action space based on the operation behavior sequence; The target operation is performed on the sequence of operation behaviors to obtain the target behavior sequence; Target test cases are generated based on the target behavior sequence.

2. The method according to claim 1, characterized in that, The clustering of the object operation behaviors to obtain operation behavior clusters includes: Feature extraction is performed on the object's operational behavior to obtain operational behavior features; The operational behavior features are filtered according to a preset number of clusters to obtain the original cluster centers; Calculate the feature distance between the operational behavior feature and the original cluster center; The operation behavior features are clustered based on the feature distance to obtain the operation behavior cluster.

3. The method according to claim 2, characterized in that, The step of clustering the operation behavior features based on the feature distance to obtain the operation behavior cluster includes: Cluster the operational behavior features based on the feature distance to obtain a reference behavior cluster; The original cluster centers are updated based on the reference behavior clusters to obtain reference cluster centers; The target number of clusters is obtained by filtering the preset number of clusters based on the reference behavior clusters and the reference cluster centers. The reference behavior clusters are filtered based on the target cluster number to obtain the operation behavior clusters.

4. The method according to claim 3, characterized in that, The step of filtering the preset number of clusters based on the reference behavioral clusters and the reference cluster centers to obtain the target number of clusters includes: Calculate the target distance between the reference behavior cluster and the reference cluster center; Draw a graph showing the relationship between the preset number of clusters and the target distance; The target number of clusters is obtained by filtering the preset number of clusters based on the relationship diagram.

5. The method according to claim 3, characterized in that, The step of filtering the preset number of clusters based on the reference behavioral clusters and the reference cluster centers to obtain the target number of clusters includes: Calculate the intra-cluster density based on the reference behavior cluster and the reference cluster center; Calculate the inter-cluster separation degree based on the reference behavior cluster and the reference cluster center; The profile coefficient is determined based on the intra-cluster compactness and the inter-cluster separation. The target number of clusters is obtained by filtering the preset number of clusters based on the silhouette coefficient.

6. The method according to any one of claims 1 to 5, characterized in that, The preset action space includes reference operations, and the step of filtering target operations from the preset action space according to the operation behavior sequence includes: The operation sequence and the reference operation are scored using an action selection model to obtain the operation score of the reference operation; The reference operations are filtered based on the operation scores to obtain the target operations.

7. The method according to any one of claims 1 to 5, characterized in that, After generating target test cases based on the target behavior sequence, the method further includes: Obtain system load parameters using testing tools; The thread concurrency is obtained based on the system load parameters. Configure the testing tool according to the thread concurrency level, and execute the target test cases according to the configured testing tool.

8. A test case generation device, characterized in that, The device includes: The acquisition module is used to acquire object operation behavior; A clustering module is used to cluster the operation behaviors of the object to obtain operation behavior clusters; wherein, the operation behavior clusters have target cluster centers; The prediction module is used to predict the sequence of the target cluster center through a sequence generation model to obtain the operation behavior sequence; The filtering module is used to filter out target operations from a preset action space based on the operation behavior sequence; An execution module is used to perform the target operation on the operation sequence to obtain the target behavior sequence; The generation module is used to generate target test cases based on the target behavior sequence.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 7.