Test case generation method and apparatus

By monitoring the execution process of the target business, generating data links, and rearranging them, the problem of low test case generation efficiency in existing technologies is solved. This improves the efficiency and richness of generated test cases, and enhances the accuracy and robustness of business testing.

CN116126676BActive Publication Date: 2026-07-03MASHANG CONSUMER FINANCE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
MASHANG CONSUMER FINANCE CO LTD
Filing Date
2022-09-29
Publication Date
2026-07-03

Smart Images

  • Figure CN116126676B_ABST
    Figure CN116126676B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a kind of test case generation method and device, method includes: the execution process of target service is monitored, and target data is obtained, wherein, at least one target service subnode is contained in target data, and the service data inputted and the service data outputted of each target service subnode, at least one target service subnode is determined according to the service data inputted and the service data outputted of each target service subnode, and target data link, wherein, at least one link node is contained in target data link, at least one link node in target data link is rearranged and handled, and the multiple data links of different link node arrangement order are obtained, and corresponding target test case is generated according to the multiple data links of different link node arrangement order.This application is conducive to improving the richness and reliability of service test.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data testing technology, and in particular to a test case generation method and apparatus. Background Technology

[0002] With the development of network technology, the number of online services is increasing. Currently, to ensure the stable operation of online services, test cases can be used to test various online services. However, when generating test cases for specific services, test cases are usually generated based on traffic data obtained during service execution, replicating the data flow in the traffic data. This testing method is relatively simplistic and has low efficiency in generating test cases, thus affecting the accuracy of service testing. Summary of the Invention

[0003] This application provides a test case generation method and apparatus to improve the richness and reliability of business testing.

[0004] In a first aspect, embodiments of this application provide a test case generation method, including:

[0005] Monitor the execution process of the target business to obtain target data, wherein the target data includes at least one target business sub-node, as well as the business data input and output of each target business sub-node, each target business sub-node corresponds to a data processing flow, and the business data output by the first target business sub-node in two adjacent target business sub-nodes is the business data input by the second target business sub-node;

[0006] A target data link is determined based on the at least one target business sub-node and the business data input and output of each target business sub-node, wherein the target data link includes at least one link node, each link node includes multiple target business sub-nodes with the same data processing flow, and the business data input and output of the multiple target business sub-nodes with the same data processing flow;

[0007] At least one link node in the target data link is rearranged to obtain multiple data links with different link node arrangement orders, and corresponding target test cases are generated based on the multiple data links with different link node arrangement orders.

[0008] Secondly, embodiments of this application provide a test case generation apparatus, comprising:

[0009] The monitoring module is used to monitor the execution process of the target business and obtain target data. The target data includes at least one target business sub-node, as well as the business data input and output of each target business sub-node. Each target business sub-node corresponds to a data processing flow. The business data output by the first target business sub-node in two adjacent target business sub-nodes is the business data input by the second target business sub-node.

[0010] The processing module is configured to determine a target data link based on the at least one target business sub-node and the business data input and output of each target business sub-node, wherein the target data link includes at least one link node, each link node includes multiple target business sub-nodes with the same data processing flow, and the business data input and output of the multiple target business sub-nodes with the same data processing flow;

[0011] The processing module is further configured to rearrange at least one link node in the target data link to obtain multiple data links with different link node arrangement orders, and generate corresponding target test cases based on the multiple data links with different link node arrangement orders.

[0012] Thirdly, embodiments of this application provide an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0013] The memory stores computer-executed instructions;

[0014] The processor executes computer execution instructions stored in the memory to implement the test case generation method described in the first aspect and various possible designs of the first aspect.

[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, it implements the test case generation method described in the first aspect and various possible designs of the first aspect.

[0016] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the test case generation method described in the first aspect and various possible designs of the first aspect.

[0017] This application provides a test case generation method and apparatus. Using the above scheme, the execution process of a target service can be monitored first to obtain target data containing at least one target service sub-node, and the input and output business data of each target service sub-node. Then, a target data link can be determined based on the at least one target service sub-node and the input and output business data of each target service sub-node. Furthermore, at least one link node in the target data link can be rearranged to obtain multiple data links with different link node arrangements. Corresponding target test cases are then generated based on these multiple data links with different link node arrangements. By first generating target data links with the same execution order as the target service sub-nodes in the original target service, and then rearranging at least one link node in the target data link to obtain multiple data links with different link node arrangements, and generating target test cases corresponding to these multiple data links with different link node arrangements, this method is no longer limited to generating test cases with the same initial execution order as the target service. This improves the efficiency of test case generation, as well as the comprehensiveness and richness of the generated test cases. Moreover, by testing the same service using test cases corresponding to data links with different link node arrangements, the accuracy and robustness of service testing are improved. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This application provides an architecture diagram of a test case generation method provided in an embodiment of the present application.

[0020] Figure 2 A flowchart illustrating a test case generation method provided in an embodiment of this application;

[0021] Figure 3 A schematic diagram illustrating the principle of another test case generation method provided in this application embodiment;

[0022] Figure 4 A schematic diagram illustrating the principle of another test case generation method provided in this application embodiment;

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

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

[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0026] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, 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 also include other sequential examples besides those illustrated or described. 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.

[0027] In related technologies, the number of online services that can be implemented is increasing, and these services can be implemented through applications or web pages. To ensure the stable operation of online services, testing can be conducted to determine whether each online service is functioning correctly. However, testing whether a service is functioning correctly requires end-to-end testing (i.e., testing from the requester to the responder). The entire testing process involves numerous interfaces and a long testing chain, requiring significant manual intervention and increasing maintenance costs. Therefore, automated testing of each service can be achieved by generating test cases. This involves obtaining real user requests and responses through methods such as coloring and recording online traffic, and then generating test cases. However, when generating test cases, only one test case can be generated based on the traffic data obtained during service execution, and this generated test case must be identical to the execution logic of the service. This reduces the efficiency of test case generation and the coverage of test scenarios, thus affecting the accuracy of service testing.

[0028] Based on the aforementioned technical issues, this application addresses the problem by first generating target data links with the same execution order as the target business sub-nodes in the original target business, and then rearranging at least one link node in the target data links to obtain multiple data links with different link node arrangements. It then generates target test cases corresponding to these multiple data links with different link node arrangements. This approach is no longer limited to generating test cases with the same initial execution order as the target business, thus improving both the efficiency and comprehensiveness of test case generation. Furthermore, by testing the same business using test cases corresponding to data links with different link node arrangements, the accuracy and robustness of business testing are improved.

[0029] Figure 1 A schematic diagram of the application system architecture for the test case generation method provided in the embodiments of this application is shown below. Figure 1 As shown, this application system may include terminal devices and electronic devices. The terminal device may be a computer device with network access capabilities. Specifically, for example, the terminal device may be a desktop computer, tablet computer, laptop computer, smartphone, digital assistant, smart wearable device, shopping guide terminal, television, smart speaker, microphone, etc. Among them, smart wearable devices include, but are not limited to, smart bracelets, smartwatches, smart glasses, smart helmets, smart necklaces, etc. Alternatively, the terminal device may also be software capable of running on the computer device. The electronic device may be a server, which may be a computer device with certain computing power. It may have a network communication module, processor, and memory, etc. Of course, a server may also refer to software running on a computer device. The server may be a distributed server, which may be a system with multiple processors, memory, network communication modules, etc., operating collaboratively. Alternatively, the server may also be a server cluster formed by several servers. Alternatively, with the development of science and technology, the server may also be a new technical means capable of realizing the corresponding functions of the embodiments described in the specification. For example, it may be a new form of "server" based on quantum computing.

[0030] There can be one or more terminal devices, and each terminal device can deploy one or more target services. During the execution of the target service, the electronic device can monitor the execution process of the target service, obtain target data, determine the target data link based on the target data, and then rearrange at least one link node in the target data link to obtain multiple data links with different link node arrangements. Corresponding target test cases are then generated based on the target data link and the data links with different link node arrangements. Alternatively, the terminal device can monitor the execution process of the target service, obtain target data, and send the target data to the electronic device. After receiving the target data, the electronic device can determine the target data link based on the target data, and then rearrange at least one link node in the target data link to obtain multiple data links with different link node arrangements. Corresponding target test cases are then generated based on the multiple data links with different link node arrangements.

[0031] Furthermore, the application system may also contain only electronic devices, where the electronic devices generate target test cases for the target services deployed on them. Alternatively, the application system may contain only terminal devices, where a test environment is deployed on the terminal devices. After the terminal devices obtain the target data corresponding to the target services, they can generate target data links based on the target data, and then process at least one node in the target data link to finally obtain the target test cases.

[0032] In addition, after obtaining the target data, it can be processed in real time; or the target data can be stored in a database, and the target data can be retrieved from the database every preset time interval or whenever the data volume reaches a preset threshold, and the retrieved target data can be processed.

[0033] Furthermore, after obtaining the target test cases, they can be run on the local server or on other servers with pre-deployed test environments, thereby enabling the testing of the target business.

[0034] The technical solutions of this application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0035] Figure 2 This is a flowchart illustrating the test case generation method provided in an embodiment of this application. The method in this embodiment can be executed by an electronic device. Figure 2 As shown, the method in this embodiment may include:

[0036] S201: Monitor the execution process of the target business and obtain target data. The target data includes at least one target business sub-node, as well as the business data input and output of each target business sub-node. Each target business sub-node corresponds to a data processing flow. The business data output by the first target business sub-node in two adjacent target business sub-nodes is the business data input by the second target business sub-node.

[0037] In this embodiment, the target service can be a service included in an application or a service included in a webpage, and generally refers to a service that has been developed and deployed. For example, the target service can be a call service (such as video call, voice call, text communication, etc.), a playback service (such as video playback, music playback, etc.), a navigation and positioning service, or a financial service (such as money transfer, credit limit increase, application for related products, etc.). The implementation of a complete target service may require multiple sub-services (i.e., multiple data processing flows) to complete, and each sub-service can correspond to a target service sub-node. Furthermore, the target service sub-node can be a service node shared with other services (e.g., a third-party interface), or it can be a service node independently developed for the target service.

[0038] This process involves testing the target service at preset intervals to determine if it is operating normally. During testing, the execution process of the target service is monitored to obtain target data. This involves recording traffic during the execution of the target service, which can be traffic data generated during its operation. After parsing the target data, the target service sub-nodes (one or more) within the target data are identified, along with the input and output business data of each sub-node. Optionally, different target service sub-nodes can have different business node identifiers. After obtaining the target data, these identifiers can be used to identify the relevant target service sub-nodes.

[0039] In this application, the target business can be represented by an application. Different types and application scenarios of applications correspond to different businesses. The traffic data generated during the operation of the application corresponds to the target data. The flow of traffic data will go through multiple application data processing flows, and each application data processing flow corresponds to a target business sub-node. Taking a video playback application as an example, the target business is video playback, and the target data is the traffic data generated during the operation of the video playback application, such as video audio data, video image data, and video cache data. When processing different data, multiple data processing nodes will be generated, corresponding to the target business sub-nodes. Compared with the existing technology that only collects traffic data and generates test cases for a single application, this application can obtain traffic data generated by multiple applications running in a certain type of application or a certain scenario and generate target test cases.

[0040] The target business application has multiple target business sub-nodes. When each target business sub-node performs different data processing, the multiple target business sub-nodes can be serial, parallel, or multiple serial branches in parallel.

[0041] In one possible example, monitoring the execution process of the target service to obtain target data may specifically include: monitoring the execution process of the target service to obtain initial target data; preprocessing the initial target data to obtain target data, wherein the preprocessing includes de-identification processing and / or deduplication processing.

[0042] Specifically, after obtaining initial target data during the monitoring of the target business's execution process, the initial target data can be preprocessed to obtain target data that conforms to the specifications. Optionally, preprocessing can be data anonymization or deduplication. Correspondingly, data anonymization can remove sensitive words (such as user basic information, account information, address information, etc.) from the initial target data, and can also remove duplicate target data, thereby reducing the amount of data processing.

[0043] S202: Determine a target data link based on at least one target business sub-node and the business data input and output of each target business sub-node. The target data link contains at least one link node, and each link node contains multiple target business sub-nodes with the same data processing flow, as well as the business data input and output of the multiple target business sub-nodes with the same data processing flow.

[0044] In this embodiment, after obtaining the target data, the target data can be parsed to determine the target business sub-nodes contained within the target data, as well as the input and output business data of each target business sub-node. Then, the execution order of each target business sub-node can be determined based on the input and output business data, and a target data link can be generated based on the execution order of the target business sub-nodes. Optionally, each link node in the target data link can contain multiple target business sub-nodes with the same data processing flow. Furthermore, if there is only one target business sub-node for a certain data processing flow, the corresponding link node can also contain only one target business sub-node. In addition, the target data link can be represented in various ways; for example, it can be a DAG (Directed Acyclic Graph) topology graph.

[0045] For example, if the target business is to transfer 1,000 yuan from account A to account B, the target business can be broken down into four sub-nodes: determining the sending account A and the receiving account B, determining the transfer amount (1,000 yuan), executing the transfer operation (reducing the balance of account A by 1,000 yuan and increasing the balance of account B by 1,000 yuan), and the receiving account B sending a success receipt to the sending account A.

[0046] S203: Rearrange at least one link node in the target data link to obtain multiple data links with different link node arrangement orders, and generate corresponding target test cases based on the multiple data links with different link node arrangement orders.

[0047] In this embodiment, after obtaining the target data link, one or more link nodes in the target data link can be rearranged to obtain multiple data links with different node ordering. Then, corresponding target test cases can be generated based on the multiple data links with different node ordering. The target test cases may or may not include test cases corresponding to the target data link; the specific settings can be customized according to the actual application scenario.

[0048] When rearranging the link nodes in the target data link, all link nodes in the target data link can be rearranged, or only some link nodes in the target data link can be rearranged. That is, the number of link nodes in the resulting data link can be the same as or different from the number of link nodes in the target data link.

[0049] Existing methods can be used to generate corresponding test cases through each link node in the data link, which will not be discussed in detail here.

[0050] As can be seen, in this embodiment, the execution process of the target service can be monitored first to obtain target data containing at least one target service sub-node, as well as the input and output business data of each target service sub-node. Then, the target data link can be determined based on the at least one target service sub-node and the input and output business data of each target service sub-node. Furthermore, at least one link node in the target data link can be rearranged to obtain multiple data links with different link node arrangements. Corresponding target test cases are then generated based on these multiple data links with different link node arrangements. By first generating target data links with the same execution order as the target service sub-nodes in the original target service, and then rearranging at least one link node in the target data link to obtain multiple data links with different link node arrangements, and generating target test cases corresponding to these multiple data links with different link node arrangements, this approach is no longer limited to generating test cases with the same initial execution order as the target service. This improves the efficiency of test case generation, as well as the comprehensiveness and richness of the generated test cases. Moreover, by testing the same service using test cases corresponding to data links with different link node arrangements, the accuracy and robustness of service testing are improved.

[0051] based on Figure 2 In addition to the method described herein, this specification also provides some specific implementation schemes of the method, which will be described below.

[0052] In one possible example, the rearrangement of at least one link node in the target data link to obtain multiple data links with different link node arrangements may specifically include: performing a full permutation on at least one link node in the target data link to obtain multiple sets of link nodes with different arrangements; and splicing the link nodes according to the arrangement order of each link node in each set to obtain multiple data links with different link node arrangements.

[0053] In this embodiment, the target data link may contain one or more link nodes. The different order of the link nodes indicates that the execution order of the target business sub-nodes corresponding to the link nodes is different. Therefore, link nodes with different order can correspond to different test cases, and the execution order of each target business sub-node in each test case is different.

[0054] There are several ways to sort the link nodes in the target data link. Optionally, to ensure the comprehensiveness of the link node sorting, a full permutation process can be used to sort the link nodes in the target data link, resulting in multiple sets of link nodes with different permutation orders. Then, the corresponding data link can be generated based on the multiple sets of link nodes with different permutation orders.

[0055] Optionally, when sorting the link nodes in the target data link by full permutation processing, full permutation processing can be performed on all link nodes in the target data link, or a portion of link nodes can be selected from all link nodes in the target data link first, and then full permutation processing can be performed on the selected portion of link nodes.

[0056] For example, if there are three link nodes in the target data link, namely link node E, link node F and link node G, then link nodes E, link node F and link node G can be sorted to obtain six groups of link nodes with different arrangements: link nodes E, link node F and link node G, link nodes E, link node G and link node F, link nodes F, link node E and link node G, link nodes F, link node G and link node E, link nodes G, link node F and link node E, and link nodes G, link node E and link node F. Then, the corresponding data link can be generated based on the six groups of link nodes with different arrangements.

[0057] In one possible example, after performing a full permutation process on at least one link node in the target data link to obtain link nodes with different permutation orders, the process may further include: filtering the multiple groups of link nodes with different permutation orders to obtain multiple groups of target link nodes that conform to the business execution rules; and concatenating the link nodes according to the permutation order of each link node in each group to obtain multiple data links with different permutation orders. This includes: concatenating the link nodes according to the permutation order of each link node in each group of target link nodes that conform to the business execution rules to obtain multiple data links with different permutation orders.

[0058] Specifically, after performing full permutation and combination processing on the link nodes, multiple sets of link nodes with different permutation orders can be obtained. These sets can then be filtered according to preset conditions to obtain multiple sets of target link nodes that conform to the business execution rules. Subsequently, corresponding data links can be generated based on these target link nodes that meet the business execution rules. The preset conditions can be customized according to the actual application scenario. Furthermore, when filtering multiple sets of link nodes with different permutation orders according to preset conditions, it is possible to obtain one or zero sets of target link nodes that conform to the business execution rules. In this case, a link node filtering anomaly alert can be generated to remind operations and maintenance personnel to modify the business execution rules or check the full permutation operation status. Alternatively, a link node filtering anomaly alert can be generated only when zero sets of target link nodes conform to the business execution rules are obtained.

[0059] Optionally, the target business can contain different target business sub-nodes. Different target business sub-nodes can correspond to different data processing flows, and different target business sub-nodes have different execution priorities. Some target business sub-nodes have lower execution priorities and can be executed before or after other target business sub-nodes; others have higher execution priorities and must be executed first, last, or before other target business sub-nodes. Therefore, business execution rules can be pre-built based on the target business sub-nodes contained in the target business. Then, multiple groups of target link nodes can be filtered based on the business execution rules to obtain multiple filtered groups of target link nodes.

[0060] For example, continuing with the previous example, after obtaining six groups of link nodes with different orderings, a business execution rule can be obtained. This business execution rule indicates that link node G must be executed last. Therefore, the six groups of link nodes with different orderings can be filtered using this business execution rule to obtain the link node group that link node G will execute last, namely, the link node group corresponding to link node E, link node F, and link node G, and the link node group corresponding to link node F, link node E, and link node G. Then, the corresponding data link can be generated based on the filtered link node groups. Furthermore, this application only lists a few examples of business execution rules; other business execution rules are also within the scope of protection of this application.

[0061] In addition, this application can also use existing discreteness algorithms to filter multiple groups of target link nodes to obtain target link nodes with a discreteness degree less than the discreteness threshold, and the discreteness degree is mainly determined based on the input value of the target service sub-node.

[0062] In one possible example, generating corresponding target test cases based on multiple data links with different link node arrangements may specifically include: generating multiple initial test cases based on the multiple data links with different link node arrangements; obtaining recommended test cases from a database based on the multiple initial test cases, wherein the database pre-stores multiple test cases related to the target service, and the recommended test cases are those that have a correlation with the multiple initial test cases; and determining target test cases that conform to preset correction rules from the recommended test cases and the multiple initial test cases.

[0063] In this embodiment, after obtaining the target data link and data links with different node arrangements, multiple initial test cases can be generated based on these data links. Then, recommended test cases are determined from the database based on these initial test cases. Furthermore, the recommended test cases and the multiple initial test cases can be filtered according to preset correction rules to obtain target test cases that conform to the preset correction rules. The database can pre-store multiple test cases related to the target business, and the recommended test cases are those that are related to the multiple initial test cases. The number of recommended test cases can be one or more.

[0064] Furthermore, when generating multiple initial test cases based on multiple data links with different link node arrangements, the data links can be data links generated based on multiple sets of target link nodes that conform to business execution rules, or they can be data links generated based on the full permutation process without being filtered.

[0065] In one possible example, obtaining recommended test cases from the database based on the plurality of initial test cases may specifically include: determining a first recommended test case from a plurality of pre-stored test cases related to the target business that has a first correlation degree higher than a first preset threshold with respect to the plurality of initial test cases, wherein the first correlation degree represents the degree of association between business objects involved in the test case; determining a second recommended test case from a plurality of pre-stored test cases related to the target business that has a second correlation degree higher than a second preset threshold with respect to the plurality of initial test cases, wherein the second correlation degree represents the degree of association between business data involved in the test case; and obtaining the recommended test cases based on the first recommended test case and the second recommended test case.

[0066] Specifically, after obtaining multiple initial test cases, the number of initial test cases may be small, or the application scenarios covered by the initial test cases may be limited. In order to improve the richness of test cases, recommended test cases can be determined based on the initial test cases. Subsequently, the target business can be tested together based on the initial test cases and the recommended test cases.

[0067] Optionally, recommended test cases can be determined based on two dimensions: a first degree of relevance and a second degree of relevance. A higher degree of relevance indicates a greater likelihood of being recommended. Correspondingly, a first recommended test case with a first degree of relevance exceeding a first preset threshold can be determined from pre-stored test cases. A second recommended test case with a second degree of relevance exceeding a second preset threshold can be determined from pre-stored test cases. Here, the first degree of relevance can represent the degree of relevance between business objects involved in the test case, and the second degree of relevance can represent the degree of relevance between business data involved in the test case. For example, if a test case is used to test a shopping transaction, the business objects involved in the test case might include merchant accounts, buyer accounts, and shopping carts. The business data involved in the test case might include shopping cart-related data (e.g., adding products to the cart) or transaction data (e.g., buyer account A purchasing products from merchant account B).

[0068] Optionally, existing correlation algorithms can be used to determine the first and second recommended test cases; further details are not provided here. The first and second preset thresholds can be the same or different, and can be customized according to the actual application scenario.

[0069] In addition, the database can store multiple test cases related to the target business. These test cases can be pre-defined existing test cases, which can be customized according to the actual application scenario. The test cases can also be adjusted in real time (e.g., adding or deleting test cases).

[0070] As can be seen, enriching the test case pool by adding recommended test cases improves both the comprehensiveness and accuracy of business testing. Furthermore, after obtaining recommended test cases and multiple initial test cases, these can be further filtered according to preset correction rules to obtain at least one test case that conforms to the rules. These correction rules can be implemented by setting assertions and can be based on the business data output by the target business sub-node. Specifically, the output data of the target business sub-node is compared with the output data set in the assertion; if the accuracy is lower than a preset accuracy threshold, the test case is discarded. Thus, by correcting test cases, the accuracy of the test cases can be improved, thereby improving the accuracy of business testing.

[0071] For example, Figure 3 This is a schematic diagram illustrating the principle of the test case generation method provided in the embodiments of this application, as shown below. Figure 3 As shown, it may include:

[0072] S301: Monitor the execution process of the target business and obtain the target data.

[0073] S302: Determine at least one target business sub-node contained in the target data, as well as the business data input and output of each target business sub-node.

[0074] S303: Determine the target data link based on at least one target service sub-node, and the service data input and output of each target service sub-node.

[0075] S304: Rearrange at least one link node in the target data link to obtain multiple sets of link nodes with different arrangement orders.

[0076] S305: Filter multiple sets of link nodes with different ordering to obtain multiple sets of target link nodes that conform to the business execution rules, and generate corresponding data links based on the multiple sets of target link nodes that conform to the business execution rules.

[0077] S306: After generating the corresponding data link, multiple initial test cases can be generated based on data links with different link node arrangements.

[0078] S307: Retrieve recommended test cases from the database based on multiple initial test cases.

[0079] S308: Determine the target test cases that conform to the preset correction rules from the recommended test cases and multiple initial test cases.

[0080] S309: After the target test cases are generated, store them in the database.

[0081] Subsequently, target test cases can be retrieved from the database and run to test the target business.

[0082] S3010: Store the generated target test cases in the backup database.

[0083] In cases where target test case scheduling issues arise (such as data loss or database failure), target test cases can be retrieved from the backup database to test the target business, thus improving test case security and consequently enhancing business testing effectiveness. Furthermore, the test environment can be integrated into CI / CD through integration, eliminating the need for repeated test environment configuration when running test cases, thereby improving the accuracy of business testing.

[0084] As can be seen, by performing link analysis on the data of the business implementation process and generating data links for the entire link, and then generating full-link test cases in the form of link node combinations based on the data links, the richness of test cases and the coverage of test scenarios are increased.

[0085] In one possible example, after generating corresponding target test cases for multiple data links with different link node arrangement orders, the method may further include: determining the coverage of the target test cases, wherein the coverage is used to represent the range of target code covered by the target test cases, and the target code is the code that implements the target service; if the coverage of the target test cases is greater than a preset coverage threshold, then the target test cases are run.

[0086] In this embodiment, after obtaining the target test case, it can be run directly to test the target business. Alternatively, the coverage of the target test case can be determined first. This coverage can represent the scope of the target code covered by the target test case. The target code is the code that implements the target business, and the scope can be the ratio of the amount of code corresponding to the target test case to the amount of code that implements the target business. Furthermore, coverage can also represent the proportion of sub-processes covered by the generated target test cases. This proportion can be the ratio of the number of sub-processes corresponding to the target test case to the number of sub-processes corresponding to the target business.

[0087] Optionally, after determining the coverage, the relationship between the coverage of the target test case and the preset coverage threshold can be determined. If the coverage of the test case is greater than the preset coverage threshold, it indicates that the target test case is rich enough to meet the testing requirements. Therefore, the target test case can be run directly to achieve the screening of the target business.

[0088] Furthermore, if the coverage of a test case is less than or equal to a preset coverage threshold, it indicates that there are too few target test cases to meet the testing requirements, and therefore, the test case can be discarded. Additionally, an exception message indicating that a test case cannot meet the coverage requirement can be generated, allowing operations personnel to adjust the target data processing logic based on this message, thereby obtaining test cases with coverage that meet the actual needs.

[0089] It is evident that by setting coverage, the accuracy and comprehensiveness of the generated test cases can be improved, thereby enhancing the accuracy of the target business testing.

[0090] Furthermore, running the target test cases requires a specific testing environment. This environment can be set up in real-time or pre-configured. Optionally, the test environment can be deployed via CICD (Continuous Integration). That is, after deploying the CICD system integration testing (SIT) or pre-release environment, a node for automatically generating test cases can be added. The generated test cases can then be automatically saved and subsequently scheduled to automate the testing of the target business logic.

[0091] In one possible example, before running the target test case, the process may further include: obtaining historical test cases corresponding to the target service; performing a union operation on the historical test cases and the target test case to obtain a test case after union processing; correspondingly, running the target test case includes: running the test case after union processing.

[0092] In this embodiment, after obtaining the target test cases, to enrich the target test cases, historical test cases corresponding to the target service can be obtained (which can be within a preset time period or a preset number). These historical test cases can be completely identical to the newly generated target test cases, partially identical to the newly generated target test cases, or completely different from the newly generated target test cases. Therefore, after obtaining the historical test cases, a union operation can be performed on the historical test cases and the target test cases to obtain the test cases after union processing. Then, the test cases after union processing are run to achieve the testing of the target service.

[0093] For example, Figure 4 A schematic diagram illustrating the principle of a test case generation method provided in another embodiment of this application, as shown below. Figure 4 As shown, it may include:

[0094] S401: Monitor the execution process of the target business and obtain the target data.

[0095] S402: Determine at least one target business sub-node contained in the target data, as well as the business data input and output of each target business sub-node.

[0096] S403: Determine the target data link based on at least one target service sub-node, and the service data input and output of each target service sub-node.

[0097] S404: Rearrange at least one link node in the target data link to obtain multiple sets of link nodes with different arrangement orders.

[0098] S405: Filter multiple sets of link nodes with different ordering to obtain multiple sets of target link nodes that conform to the business execution rules, and generate corresponding data links based on the multiple sets of target link nodes that conform to the business execution rules.

[0099] S406: After generating the corresponding data link, multiple initial test cases can be generated based on data links with different node arrangement orders.

[0100] S407: Retrieve recommended test cases from the database based on multiple initial test cases.

[0101] S408: Determine the target test cases that conform to the preset correction rules from the recommended test cases and multiple initial test cases.

[0102] S409: After obtaining the target test cases, retrieve the historical test cases corresponding to the target business from the backup database, and perform a union operation on the historical test cases and the target test cases to obtain the test cases after union processing.

[0103] S4010: Store the test cases after union processing to the database.

[0104] Subsequently, test cases processed by the union can be retrieved from the database and run to test the target business.

[0105] S4011: Store the test cases after union processing to the backup database.

[0106] If a problem occurs with the scheduling of target test cases (such as data loss or database failure), test cases after union processing can be obtained from the backup database, thereby enabling testing of the target business and improving the security of test cases.

[0107] Furthermore, if the historical test cases are exactly the same as the newly generated target test cases, the newly generated target test cases can be directly stored in the database. Subsequently, the newly generated target test cases can be retrieved from the database and run to test the target business.

[0108] It is evident that by taking the union of historical test cases and newly generated test cases for the same target business, and then testing the target business based on the test cases obtained from the union operation, the richness of test cases is further improved, thereby enhancing the testing effectiveness of the target business.

[0109] The embodiments in this specification also provide the apparatus corresponding to the above method. Figure 5 This is a schematic diagram of the structure of the test case generation device 50 provided in the embodiments of this application, as shown below. Figure 5As shown, the apparatus provided in this embodiment may include:

[0110] The monitoring module 501 is used to monitor the execution process of the target service and obtain target data. The target data includes at least one target service sub-node, as well as the input and output service data of each target service sub-node. Each target service sub-node corresponds to a data processing flow. The service data output by the first target service sub-node in two adjacent target service sub-nodes is the service data input by the second target service sub-node.

[0111] The processing module 502 is used to determine a target data link based on the at least one target service sub-node and the service data input and output of each target service sub-node, wherein the target data link includes at least one link node, each link node includes multiple target service sub-nodes with the same data processing flow, and the service data input and output of the multiple target service sub-nodes with the same data processing flow.

[0112] The processing module 502 is used to rearrange at least one link node in the target data link to obtain multiple data links with different link node arrangement orders, and generate corresponding target test cases based on the multiple data links with different link node arrangement orders.

[0113] Furthermore, the processing module 502 is also used to: perform a full permutation process on at least one link node in the target data link to obtain multiple sets of link nodes with different permutation orders; and perform splicing processing on each link node according to the permutation order of each link node in each set to obtain multiple data links with different permutation orders of link nodes.

[0114] Furthermore, the processing module 502 is also used to: filter the multiple groups of link nodes with different arrangement orders to obtain multiple groups of target link nodes that conform to the business execution rules; and perform splicing processing on each link node according to the arrangement order of each link node in each group of target link nodes that conform to the business execution rules to obtain multiple data links with different arrangement orders of link nodes.

[0115] Furthermore, the processing module 502 is also configured to: generate multiple initial test cases based on multiple data links with different link node arrangement orders; obtain recommended test cases from a database based on the multiple initial test cases, wherein the database pre-stores multiple test cases related to the target business, and the recommended test cases are test cases that have a correlation with the multiple initial test cases; and determine target test cases that conform to preset correction rules from the recommended test cases and the multiple initial test cases.

[0116] Furthermore, the processing module 502 is also configured to: determine, from a plurality of test cases pre-stored in the database that are related to the target business, a first recommended test case whose first correlation with the plurality of initial test cases is higher than a first preset threshold, wherein the first correlation represents the degree of association between business objects involved in the test case; determine, from a plurality of test cases pre-stored in the database that are related to the target business, a second recommended test case whose second correlation with the plurality of initial test cases is higher than a second preset threshold, wherein the second correlation represents the degree of association between business data involved in the test case; and obtain the recommended test case based on the first recommended test case and the second recommended test case.

[0117] Furthermore, the processing module 502 is also used to: determine the coverage of the target test case, wherein the coverage is used to represent the range of target code covered by the target test case, and the target code is the code that implements the target business; if the coverage of the target test case is greater than a preset coverage threshold, then the target test case is run.

[0118] Furthermore, the processing module 502 is also configured to: obtain historical test cases corresponding to the target service; perform a union operation on the historical test cases and the target test cases to obtain test cases after union processing; and run the test cases after union processing.

[0119] The apparatus provided in this application embodiment can achieve the above-mentioned... Figure 2 The methods in the embodiments shown are similar in principle and technical effect, and will not be described again here.

[0120] Figure 6 A schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application, such as... Figure 6 As shown, the electronic device 600 provided in this embodiment includes: a processor 601 and a memory communicatively connected to the processor. The processor 601 and the memory 602 are connected via a bus 603.

[0121] In a specific implementation, the processor 601 executes the computer execution instructions stored in the memory 602, causing the processor 601 to execute the method in the above method embodiment.

[0122] The specific implementation process of processor 601 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0123] In the above Figure 6In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0124] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage.

[0125] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0126] This application also provides a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, it implements the test case generation method of the above method embodiments.

[0127] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the test case generation method described above.

[0128] The aforementioned computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0129] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0130] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A test case generation method characterized by, include: Monitor the execution process of the target service to obtain target data, wherein the target data includes at least one target service sub-node, as well as the input and output service data of each target service sub-node, each target service sub-node corresponds to a data processing flow, and the service data output by the first target service sub-node in two adjacent target service sub-nodes is the service data input by the second target service sub-node; Based on the at least one target business sub-node and the business data input and output of each target business sub-node, a target data link is determined, wherein the target data link includes at least one link node, and each link node includes one or more target business sub-nodes with the same data processing flow and the business data input and output of the one or more target business sub-nodes with the same data processing flow; At least one link node in the target data link is rearranged to obtain multiple data links with different link node arrangement orders. Multiple initial test cases are generated based on multiple data links with different node arrangement orders. Based on the multiple initial test cases and recommended test cases, target test cases are determined; the recommended test cases are test cases that are related to the multiple initial test cases, and the target test cases are test cases that conform to preset correction rules.

2. The method of claim 1, wherein, The step of rearranging at least one link node in the target data link to obtain multiple data links with different link node arrangements includes: Perform a full permutation process on at least one link node in the target data link to obtain multiple sets of link nodes with different permutation orders; According to the arrangement order of each link node in each group, the link nodes are spliced ​​together to obtain multiple data links with different link node arrangement orders.

3. The method of claim 2, wherein, After performing a full permutation process on at least one link node in the target data link to obtain multiple sets of link nodes with different permutation orders, the method further includes: By filtering the multiple groups of link nodes with different arrangement orders, multiple groups of target link nodes that conform to the business execution rules are obtained. The step involves concatenating the link nodes according to their arrangement order within each group to obtain multiple data links with different link node arrangements, including: According to the arrangement order of each link node in the target link node that conforms to the business execution rules in each group, the link nodes are spliced ​​together to obtain multiple data links with different link node arrangement orders.

4. The method of claim 1, wherein, The step of determining the target test case based on the plurality of initial test cases and recommended test cases includes: Recommended test cases are obtained from the database based on the multiple initial test cases. The database contains multiple test cases related to the target business. The recommended test cases are those that are related to the multiple initial test cases. Target test cases that conform to preset correction rules are determined from the recommended test cases and the plurality of initial test cases.

5. The method of claim 4, wherein, The step of obtaining recommended test cases from the database based on the multiple initial test cases includes: From the multiple test cases pre-stored in the database that are related to the target business, a first recommended test case is determined whose first relevance to the multiple initial test cases is higher than a first preset threshold, wherein the first relevance represents the degree of association between the business objects involved in the test case; From a plurality of test cases pre-stored in the database that are related to the target business, a second recommended test case is determined that has a second correlation degree higher than a second preset threshold with respect to the plurality of initial test cases, wherein the second correlation degree represents the degree of correlation between the business data involved in the test case; The recommended test cases are obtained based on the first recommended test cases and the second recommended test cases.

6. The method according to any one of claims 1 to 5, characterized in that, After generating corresponding target test cases based on multiple data links with different link node arrangements, the method further includes: Determine the coverage of the target test cases, wherein the coverage is used to represent the scope of the target code covered by the target test cases, and the target code is the code that implements the target business; If the coverage of the target test case is greater than the preset coverage threshold, then the target test case is run.

7. The method of claim 6, wherein, Before running the target test case, the following is also included: Obtain the historical test cases corresponding to the target service; Perform a union operation on the historical test cases and the target test cases to obtain the test cases after union processing; Run the test cases after the union processing.

8. A test case generation apparatus characterized by comprising: include: The monitoring module is used to monitor the execution process of the target business and obtain target data. The target data includes at least one target business sub-node, as well as the business data input and output of each target business sub-node. Each target business sub-node corresponds to a data processing flow. The business data output by the first target business sub-node in two adjacent target business sub-nodes is the business data input by the second target business sub-node. The processing module is used to determine a target data link based on the at least one target business sub-node and the business data input and output of each target business sub-node, wherein the target data link includes at least one link node, and each link node includes one or more target business sub-nodes with the same data processing flow and the business data input and output of the one or more target business sub-nodes with the same data processing flow; The processing module is further configured to rearrange at least one link node in the target data link to obtain multiple data links with different link node arrangement orders; generate multiple initial test cases based on the multiple data links with different link node arrangement orders; determine target test cases based on the multiple initial test cases and recommended test cases; the recommended test cases are test cases that have a correlation with the multiple initial test cases, and the target test cases are test cases that conform to preset correction rules.

9. An electronic device, comprising: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the test case generation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the test case generation method according to any one of claims 1 to 7 is implemented.