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

By obtaining and analyzing data on user interaction behavior in the business system, the end-to-end test case code is automatically generated, which solves the problem of time-consuming, labor-intensive and incomplete coverage of manual test cases, improves testing efficiency and accuracy, and reduces maintenance costs.

CN119065985AInactive Publication Date: 2024-12-03SHENZHEN FENXIANG INTERNET TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411551268.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2024-12-03
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, software test cases are generally written manually, which leads to time-consuming and labor-intensive, easy to miss key operations, incomplete coverage, high maintenance costs, low testing efficiency, and especially obvious when frequent page updates.

Method used

By obtaining the behavior data of user interaction behavior in the business system, determining the interactive node and node data, generating operation flow information in the trigger order of the interactive nodes, and then automatically generating end-to-end test case codes, and using behavior simulation tools to analyze and combine interactive node data. , add assertions and timecode to generate accurate test cases.

Benefits of technology

Improves the efficiency and accuracy of test case generation, reduces the cost and errors of manual writing, ensures comprehensive test coverage, and reduces maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119065985A_ABST
    Figure CN119065985A_ABST
Patent Text Reader

Abstract

The invention provides a test case generation method and device, computer equipment and a storage medium, and is applied to the field of computers, and the method comprises the steps: obtaining behavior data of user interaction behaviors when a business process of a business system is executed; wherein the behavior data comprises event information of interaction events triggered by a user on an operation page of a business system for a business process; based on the behavior data of the user interaction behavior, determining an interaction node and node data corresponding to the interaction node; according to the triggering sequence of the interaction nodes, based on the interaction nodes and the node data, generating operation flow information corresponding to the business process; and generating an end-to-end test case code corresponding to the business process based on the operation flow information. According to the method, the test case code of the business process can be automatically generated according to the behavior data of the user interaction behavior, the cost problem caused by manual writing is relieved, and the generation efficiency of the test case is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a test case generation method, apparatus, computer equipment and storage medium. Background Art

[0002] With the development of technology, software testing has become a very important content in the computer field. In related technologies, test cases are generally manually written and generated. Specifically, test engineers can manually write test cases based on information such as page structure and business flow. However, the manual writing of test cases is not only time-consuming and laborious, but also easy to miss key operations, resulting in incomplete test case coverage and inaccurate test results. At the same time, when dealing with frequent page updates, the maintenance cost of manually written test cases is high and the test efficiency is low. Summary of the invention

[0003] The embodiments of the present disclosure at least provide a method, apparatus, computer equipment and storage medium for generating a test case.

[0004] In a first aspect, an embodiment of the present disclosure provides a method for generating a test case, comprising: Acquire behavior data of user interaction behavior when executing a business process of the business system; wherein the behavior data includes event information of each interaction event triggered by the user on the operation page of the business system for the business process; Determining an interactive node and node data corresponding to the interactive node based on the behavior data of the user interaction behavior; Generate operation flow information corresponding to the business process based on the interaction nodes and the node data according to the triggering order of each interaction node; Based on the operation flow information, an end-to-end test case code corresponding to the business process is generated.

[0005] In an optional implementation manner, the method further includes: After the system functions of the business system are updated, determining each business process including the system functions; The end-to-end test case codes corresponding to the business processes are used to determine the test results corresponding to the system functions.

[0006] In an optional implementation, generating end-to-end test case code corresponding to the business process based on the operation flow information includes: Utilizing a behavior simulation tool, parsing and reading node data of each of the interaction nodes in the operation flow information; and for each of the interaction nodes, generating a test code corresponding to the interaction node according to the node data of the interaction node; According to the triggering sequence of each of the interaction nodes, the test codes corresponding to each of the interaction nodes are combined to generate an end-to-end test case code corresponding to the business process.

[0007] In an optional implementation manner, after generating the end-to-end test case code corresponding to the business process, the method further includes: When the operation flow information includes a target interaction event, obtaining a first assertion for determining whether the target interaction event is triggerable; The first assertion is added before the test code corresponding to the target interaction event in the end-to-end test case code to obtain an updated end-to-end test case code.

[0008] In an optional implementation manner, the method further includes: Determining the interval time between adjacent interaction nodes in the operation flow information based on the behavior data of the user interaction behavior; Generate a time code based on the interval time between the adjacent interaction nodes; The step of combining the test codes corresponding to the interaction nodes according to the triggering order of the interaction nodes to generate an end-to-end test case code corresponding to the business process includes: According to the triggering order of each of the interactive nodes, the test codes corresponding to each of the interactive nodes are combined, and the corresponding time code is inserted between the test codes of adjacent interactive nodes to generate an end-to-end test case code corresponding to the business process.

[0009] In an optional implementation manner, when the behavior data includes event information of a network request event, after generating the test code corresponding to the interactive node, the method further includes: Get the network request interception code; Generate a second assertion corresponding to the network request event based on the network request state value included in the event information of the network request event; The network request interception code and the second assertion are added to the test code of the interactive node corresponding to the network request event to generate an updated test code corresponding to the interactive node, wherein the updated test code is used to generate the end-to-end test case code.

[0010] In an optional implementation manner, after generating the operation flow information corresponding to the business process, the method further includes: Verifying the operation flow information; When it is determined through verification that the operation flow information is abnormal, the operation flow information is adjusted to generate adjusted operation flow information.

[0011] In an optional implementation manner, the obtaining of behavior data of user interaction behavior when executing a business process of the business system includes: Using a page monitoring script to monitor various interaction events triggered by users on the business system; When a first interaction event that starts the business process is monitored, event information of the first interaction event and event information of each interaction event after the first interaction event are collected until a second interaction event that ends the business process is monitored; Based on the collected event information of each interaction event, behavior data of the user interaction behavior corresponding to the business process is generated.

[0012] In an optional implementation manner, the interaction event includes one or more of the following: Click events, input events, mouse movement events, drag events, scroll events, context menu events, form submission events, network request events.

[0013] In a second aspect, the present disclosure also provides a test case generation device, including: An acquisition module, used to acquire behavior data of user interaction behavior when executing a business process of a business system; wherein the behavior data includes event information of each interaction event triggered by the user on an operation page of the business system for the business process; A determination module, configured to determine an interaction node and node data corresponding to the interaction node based on the behavior data of the user interaction behavior; A first generating module, configured to generate operation flow information corresponding to the business process based on the interaction nodes and the node data according to the triggering order of each interaction node; The second generating module is used to generate end-to-end test case code corresponding to the business process based on the operation flow information.

[0014] In an optional implementation, the device further includes: a testing module, configured to: After the system functions of the business system are updated, determining each business process including the system functions; The end-to-end test case codes corresponding to the business processes are used to determine the test results corresponding to the system functions.

[0015] In an optional implementation manner, the second generating module, when generating the end-to-end test case code corresponding to the business process based on the operation flow information, is used to: Utilizing a behavior simulation tool, parsing and reading node data of each of the interaction nodes in the operation flow information; and for each of the interaction nodes, generating a test code corresponding to the interaction node according to the node data of the interaction node; According to the triggering sequence of each of the interaction nodes, the test codes corresponding to each of the interaction nodes are combined to generate an end-to-end test case code corresponding to the business process.

[0016] In an optional implementation manner, the second generating module, after generating the end-to-end test case code corresponding to the business process, is further used to: When the operation flow information includes a target interaction event, obtaining a first assertion for determining whether the target interaction event is triggerable; The first assertion is added before the test code corresponding to the target interaction event in the end-to-end test case code to obtain an updated end-to-end test case code.

[0017] In an optional implementation manner, the second generating module is further used to: Determining the interval time between adjacent interaction nodes in the operation flow information based on the behavior data of the user interaction behavior; Generate a time code based on the interval time between the adjacent interaction nodes; The second generating module is used to combine the test codes corresponding to the interaction nodes according to the triggering order of the interaction nodes to generate the end-to-end test case code corresponding to the business process: According to the triggering order of each of the interactive nodes, the test codes corresponding to each of the interactive nodes are combined, and the corresponding time code is inserted between the test codes of adjacent interactive nodes to generate an end-to-end test case code corresponding to the business process.

[0018] In an optional implementation manner, when the behavior data includes event information of a network request event, the second generating module, after generating the test code corresponding to the interactive node, is further configured to: Get the network request interception code; Generate a second assertion corresponding to the network request event based on the network request state value included in the event information of the network request event; The network request interception code and the second assertion are added to the test code of the interactive node corresponding to the network request event to generate an updated test code corresponding to the interactive node, wherein the updated test code is used to generate the end-to-end test case code.

[0019] In an optional implementation, after the operation flow information corresponding to the business process is generated, it further includes: a verification module, which is used to: Verifying the operation flow information; When it is determined through verification that the operation flow information is abnormal, the operation flow information is adjusted to generate adjusted operation flow information.

[0020] In an optional implementation, the acquisition module, when acquiring the behavior data of the user interaction behavior when executing the business process of the business system, is used to: Using a page monitoring script to monitor various interaction events triggered by users on the business system; When a first interaction event that starts the business process is monitored, event information of the first interaction event and event information of each interaction event after the first interaction event are collected until a second interaction event that ends the business process is monitored; Based on the collected event information of each interaction event, behavior data of the user interaction behavior corresponding to the business process is generated.

[0021] In an optional implementation manner, the interaction event includes one or more of the following: Click events, input events, mouse movement events, drag events, scroll events, context menu events, form submission events, network request events.

[0022] In a third aspect, an optional implementation of the present disclosure further provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory, and when the machine-readable instructions are executed by the processor, the machine-readable instructions perform the steps of the above-mentioned first aspect, or any possible implementation of the first aspect.

[0023] In a fourth aspect, an optional implementation of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are executed.

[0024] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present disclosure.

[0025] The test case generation method, device, computer equipment and storage medium provided by the embodiment of the present disclosure obtain the behavior data of the user interaction behavior when executing the business process of the business system; wherein the behavior data includes the event information of each interaction event triggered by the user on the operation page of the business system for the business process; based on the behavior data of the user interaction behavior, the interaction node and the node data corresponding to the interaction node are determined; according to the triggering order of each interaction node, based on the interaction node and the node data, the operation flow information corresponding to the business process is generated, the operation flow information in the present disclosure is generated based on the event information of each interaction event, the generation of the operation flow information is relatively simple and efficient, and then based on the operation flow information, the end-to-end test case code corresponding to the business process can be automatically generated, which alleviates the cost and efficiency problems caused by manual writing and improves the generation efficiency of the end-to-end test case code. And, the operation flow in the present disclosure includes each interaction event of executing the business process, so that the operation flow information can more accurately reflect the execution process of the business process, the interaction events in the business process are more comprehensive, and the accuracy of the end-to-end test case code is guaranteed.

[0026] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0028] Figure 1 A flowchart of a method for generating a test case provided by some embodiments of the present disclosure is shown; Figure 2 A flowchart showing a method for generating a test case provided by other embodiments of the present disclosure is shown; Figure 3 A flowchart of generating end-to-end test case code in a test case generation method provided in some embodiments of the present disclosure is shown; Figure 4 A schematic diagram showing a test case generation device provided by some embodiments of the present disclosure; Figure 5 A schematic diagram of a computer device provided by some embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the present disclosure claimed for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0030] In the related art, test cases are generally manually written and generated. Specifically, test engineers can manually write test cases based on information such as page structure and business flow. However, the manual writing of test cases is not only time-consuming and laborious, but also prone to missing key operations, resulting in incomplete test case coverage and inaccurate test results. At the same time, when dealing with frequent page updates, the maintenance cost of manually written test cases is high and the test efficiency is low.

[0031] Based on the above research, the present disclosure provides a method, device, computer equipment and storage medium for generating test cases, by acquiring the behavior data of user interaction behavior when executing the business process of the business system; wherein the behavior data includes the event information of each interaction event triggered by the user for the business process on the operation page of the business system; based on the behavior data of the user interaction behavior, determining the interaction node and the node data corresponding to the interaction node; according to the triggering order of each interaction node, based on the interaction node and the node data, generating the operation flow information corresponding to the business process, the operation flow information in the present disclosure is generated based on the event information of each interaction event, the generation of the operation flow information is relatively simple and efficient, and then based on the operation flow information, the end-to-end test case code corresponding to the business process can be automatically generated, which alleviates the cost and efficiency problems caused by manual writing, and improves the generation efficiency of the end-to-end test case code. And, the operation flow in the present disclosure includes each interaction event of executing the business process, so that the operation flow information can more accurately reflect the execution process of the business process, the interaction events in the business process are more comprehensive, which alleviates the situation where the business process omits key operations, and ensures the accuracy of the end-to-end test case code.

[0032] The above contents are all the results obtained by the inventor after practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.

[0033] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0034] To facilitate understanding of this embodiment, a test case generation method disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the test case generation method provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, etc. In some possible implementations, the test case generation method can be implemented by a processor calling a computer-readable instruction stored in a memory.

[0035] The following describes the method for generating a test case provided by an embodiment of the present disclosure by taking a terminal device as an example in which the execution subject is an example.

[0036] See also Figure 1 FIG. 1 is a flowchart of a method for generating a test case provided by an embodiment of the present disclosure, wherein the method comprises steps S101 to S104, wherein: S101. Obtaining behavior data of user interaction behavior when executing a business process of a business system; wherein the behavior data includes event information of each interaction event triggered by the user on the operation page of the business system in response to the business process.

[0037] When users execute business processes on the business system, they can obtain the behavior data of user interaction behaviors in real time. The behavior data includes the event information of each interaction event triggered by the user on the operation page of the business system for the business process. A general business system can be set up with multiple business functions, and different business functions correspond to different business processes. The specific content of the business function can be determined according to the business scenario, and is not specifically limited here.

[0038] Interaction events include one or more of the following: click events, input events, mouse movement events, drag events, scroll events, context menu events, form submission events, and network request events. Click events can record the user's click behavior on the operation page, input events can record the content entered by the user in the input box or text area, mouse movement events can record the movement path of the mouse on the operation page, drag events can record the start, movement, and end of the dragged element, scroll events can record the scroll position of the operation page or container, context menu events can record the user's right-click event, form submission events can record the user's form submission event, and network request events can record the network request status in the user's interactive behavior.

[0039] Exemplary event information of interactive events includes, but is not limited to: event text content or input value, event tag name, trigger time (i.e., timestamp of interactive action), event type (such as click event, input event, etc.), additional data value (such as input box content), selector (used to identify event), Uniform Resource Locator (URL) of current page, vertical scroll bar position, horizontal scroll bar position, mouse movement path, etc. Event information of network request events may also include: network request interface address, interface description, network request status value, status description, etc.

[0040] Optionally, the obtaining of behavior data of user interaction behavior when executing a business process of the business system specifically includes: Step a1: using a page monitoring script to monitor various interaction events triggered by users on the business system; Step a2: when a first interaction event that starts the business process is monitored, event information of the first interaction event and event information of each interaction event after the first interaction event are collected until a second interaction event that ends the business process is monitored; Step a3: Based on the collected event information of each interaction event, generate behavior data of the user interaction behavior corresponding to the business process.

[0041] During implementation, a page monitoring script can be used to monitor various interactive events triggered by users on the business system. For example, a JavaScript script can be used to monitor all interactive events on the operation page of the business system to obtain the user's interactive behavior on the operation page.

[0042] After monitoring the click event, determine whether the monitored click event belongs to the first interactive event that starts the business process. If it does not belong to the first interactive event, there is no need to collect the event information of the click event. If the first interactive event is monitored, the event information collection process is started, that is, the event information of the first interactive event is collected, and the event information of each interactive event after the first interactive event is collected until the second interactive event that ends the business process is monitored. Through the above process, the event information of the first interactive event, the event information of the second interactive event, and the event information of other interactive events between the first interactive event and the second interactive event are collected. Then, based on the event information of each interactive event collected above, the behavior data of the user interaction behavior corresponding to the business process is generated.

[0043] The first interaction event and the second interaction event can be set according to the actual situation of the business process. For example, the first interaction event can be: clicking the new function button, edit function button, etc. on the page, and the second interaction event can be: clicking the complete function button, end function button, submit function button, etc. on the page.

[0044] Through the above process, event information of multiple interactive events for business processes can be collected more accurately and comprehensively, so that the behavior data of user interaction behavior is more accurate.

[0045] The method further includes: S102, determining an interactive node and node data corresponding to the interactive node based on the behavior data of the user interaction behavior.

[0046] After collecting the behavioral data of the user's interactive behavior, the interactive nodes and node data can also be determined based on the behavioral data of the user's interactive behavior. For example, each interactive event belongs to an interactive node, and the event information of the interactive event can be determined as the node data of the interactive node, and then multiple interactive nodes and the node data corresponding to the interactive nodes can be obtained.

[0047] The method further includes: S103, generating operation flow information corresponding to the business process based on the interaction nodes and the node data according to the triggering order of each of the interaction nodes.

[0048] During implementation, the event execution order, i.e., the triggering order of each interactive node, can be determined according to the triggering time of multiple interactive events. Then, according to the triggering order, the interactive nodes and node data corresponding to the multiple interactive events are combined to obtain the operation flow information. For example, the operation flow information may include: interactive node 1 (i.e., the interactive node that starts the business process) and the associated node data 1 → interactive node 2 and the associated node data 2 → ... interactive node n (i.e., the interactive node that ends the business process) and the associated node data n. Where n is a positive integer greater than 1.

[0049] For example, in order to more accurately obtain the operation flow information of the business process, the operation template corresponding to the business process can be set so that the user triggers each interactive event on the operation page according to the operation target. Alternatively, the behavior data triggered by multiple users for the business process can be obtained, and the behavior data that meets the test requirements can be extracted from the behavior data triggered by multiple users, so as to generate the operation flow information of the business process according to the extracted behavior data. The test requirements can include, for example, the operation steps of the business process, the triggering sequence between the operation steps, etc.

[0050] In order to ensure the accuracy of the operation flow information and to ensure the accuracy of the end-to-end test case code obtained subsequently, after generating the operation flow information corresponding to the business process, the method also includes: verifying the operation flow information; when the verification determines that there is an abnormality in the operation flow information, adjusting the operation flow information to generate adjusted operation flow information.

[0051] For example, manual review can be used to verify the operation flow information. Alternatively, a verification template can be set to verify the operation flow information. For example, the verification template can include the interaction nodes that must exist in the business process, the triggering sequence between multiple interaction nodes, and the content that must be included in the node data.

[0052] When the operation flow information is verified to be free of anomalies, the operation flow information can be used to generate end-to-end test case code. When the operation flow information is verified to be free of anomalies, the operation flow information is adjusted to generate adjusted operation flow information, so that the end-to-end test case code can be generated using the adjusted operation flow information.

[0053] The method further includes: S104, generating end-to-end test case code corresponding to the business process based on the operation flow information.

[0054] During implementation, the operation flow information can be traversed, simulation operations can be performed based on the traversed content, and end-to-end test case code corresponding to the business process can be generated.

[0055] Optionally, generating end-to-end test case code corresponding to the business process based on the operation flow information includes: Step b1, using a behavior simulation tool to parse and read the node data of each of the interactive nodes in the operation flow information; and for each of the interactive nodes, generating a test code corresponding to the interactive node according to the node data of the interactive node; Step b2: According to the triggering order of each of the interaction nodes, the test codes corresponding to each of the interaction nodes are combined to generate an end-to-end test case code corresponding to the business process.

[0056] The behavior simulation tool may be, for example, a Cypress tool. The behavior simulation tool is used to parse and read the node data of each interaction node in the operation flow information. For each interaction node, the behavior simulation tool is used to generate the test code corresponding to the interaction node according to the node data of the interaction node. Furthermore, the test codes corresponding to each interaction node may be combined according to the triggering order of each interaction node to generate the end-to-end test case code corresponding to the business process.

[0057] Through the above process, the automatic generation of end-to-end test case codes can be achieved, thereby improving the generation efficiency of test cases.

[0058] Optionally, when the behavior data includes event information of a network request event, after generating the test code corresponding to the interactive node in step b1, the following further includes: Step c1, obtaining the network request interception code; Step c2: generating a second assertion corresponding to the network request event based on the network request state value included in the event information of the network request event; Step c3: add the network request interception code and the second assertion to the test code of the interactive node corresponding to the network request event, and generate an updated test code corresponding to the interactive node, wherein the updated test code is used to generate the end-to-end test case code.

[0059] The network request interception code is used to intercept network requests, and the network request interception code can be generated and stored in advance.

[0060] And based on the network request state value included in the event information of the network request event, a second assertion corresponding to the network request event can be generated, and the second assertion is used to verify the accuracy of the initiated network request during the test process.

[0061] Then, the network request interception code and the second assertion can be added to the test code of the interactive node corresponding to the network request event to generate updated test code corresponding to the interactive node, wherein the adding position of the network request interception code and the second assertion can be determined according to the code generation rule. The updated test code can be used to generate end-to-end test case code later.

[0062] Through the above process, end-to-end test case code with high accuracy can be generated to ensure the accuracy of the test.

[0063] In one method, a reference interval time can be set, such as 5 seconds, 10 seconds, etc., and a reference time code is generated according to the reference interval time, so that the test codes corresponding to each interaction node can be combined according to the triggering order of each interaction node, and the reference time code is inserted between the test codes of adjacent interaction nodes to generate the end-to-end test case code corresponding to the business process. The reference time code can control the simulation time interval between adjacent interaction nodes during the test process, that is, after the simulation of the interaction node is completed, the simulation operation of the next interaction node is performed after the reference interval time.

[0064] In another embodiment, in order to improve the authenticity and accuracy of the test, optionally, the method also includes: determining the interval time between adjacent interaction nodes in the operation flow information based on the behavioral data of the user interaction behavior; and generating a time code based on the interval time between the adjacent interaction nodes.

[0065] During implementation, the interval time between adjacent interactive nodes in the operation flow information is determined based on the behavioral data of the user's interactive behavior. The event information of the interactive event includes the event trigger time, so the node data includes the trigger time corresponding to the interactive node. According to the trigger time of the adjacent interactive node, the interval time between the adjacent interactive nodes can be determined. For example, if there are 5 interactive nodes, 4 interval times can be determined, namely, the interval time 1 between interactive node 1 and interactive node 2, the interval time 2 between interactive node 2 and interactive node 3, the interval time 3 between interactive node 3 and interactive node 4, and the interval time 4 between interactive node 4 and interactive node 5. Then, a time code is generated for each interval time.

[0066] Subsequently, according to the triggering order of each of the interaction nodes, the test codes corresponding to each of the interaction nodes are combined to generate an end-to-end test case code corresponding to the business process, which may include: according to the triggering order of each of the interaction nodes, the test codes corresponding to each of the interaction nodes are combined, and the corresponding time code is inserted between the test codes of adjacent interaction nodes to generate an end-to-end test case code corresponding to the business process.

[0067] For example, the test codes corresponding to interaction node 1, interaction node 2, interaction node 3, interaction node 4 and interaction node 5 can be combined according to the triggering order of each interaction node, and then time code 1 corresponding to interval time 1 is inserted between the test code of interaction node 1 and the test code of interaction node 2, and the same insertion operation is performed on time code 2, time code 3 and time code 4 to generate end-to-end test case code corresponding to the business process.

[0068] Optionally, after generating the end-to-end test case code corresponding to the business process, it also includes: when the target interaction event is included in the operation flow information, obtaining a first assertion for determining whether the target interaction event can be triggered; adding the first assertion to the end-to-end test case code before the test code corresponding to the target interaction event, to obtain an updated end-to-end test case code.

[0069] The target interaction event is an event that requires a click operation on the operation page, such as a click event, an input event, a drag event, a context menu event, etc.

[0070] When the target interaction event is included in the operation flow information, a first assertion is obtained; wherein the first assertion can be generated and stored in advance. The first assertion is used to determine whether the target interaction event can be triggered in advance during the test process. If it is determined during the test process that the target interaction event cannot be triggered, there is no need to perform subsequent simulation operations. Therefore, the first assertion can be added before the test code corresponding to the target interaction event in the end-to-end test case code to obtain an updated end-to-end test case code, so that the first assertion can be used to determine whether the target interaction event can be triggered in the subsequent test process, and a simulation test can be performed according to the test code if it can be triggered.

[0071] Here, the first assertion is updated to the end-to-end test case code, so that more accurate testing can be performed using the updated end-to-end test case code, thereby improving test accuracy.

[0072] The method may optionally further include: after the system functions of the business system are updated, determining each business process including the system functions; and determining the test results corresponding to the system functions using the end-to-end test case codes corresponding to each business process.

[0073] During implementation, if the system function of the business system is updated, in order to more accurately verify the updated system function, the various business processes including the system function can be determined. For example, if the system function is a creation function, the various business processes including the creation function can be determined. Then, the end-to-end test case codes corresponding to each business process are used to determine the test results corresponding to the system function. The present disclosure implements testing of system functions from the overall dimension of the business process and the user operation dimension. The test process matches the user operation behavior, thereby improving the accuracy of the test.

[0074] The following combination Figure 2 , an exemplary method for generating an end-to-end test case is described. The method includes: S201: Create a user operation flow instance.

[0075] S202: Monitor user interaction events.

[0076] That is, monitor each interaction event triggered by the user on the business system.

[0077] S203: Collect key information on the triggered process source node.

[0078] That is, when the first interactive event that starts the business process is monitored, the event information of the interactive event is collected. When the interactive event is a network request event, information such as interface request records and return status can also be collected.

[0079] S204: Whether it is the end node of the business process.

[0080] That is, it is determined whether the interaction event is the second interaction event that ends the business process. If not, it returns to step S202 to continue monitoring the user interaction event. If yes, it ends the current operation flow, that is, the event information corresponding to the multiple interaction events of the business process is obtained, and S205 is executed.

[0081] S205: Generate an operation flow.

[0082] That is, the operation flow information corresponding to the business process is generated.

[0083] S206: Manual inspection: Verify the operation flow information.

[0084] S207. Generate test case code.

[0085] Specifically, based on the operation flow information, end-to-end test case code corresponding to the business process can be generated. Figure 3 As shown in the figure, the process of generating end-to-end test case code includes: S301, parsing operation flow information.

[0086] That is, the node data of each interactive node in the operation flow information is parsed and read.

[0087] S302: Generate Cypress test code.

[0088] That is, for each interactive node, a test code corresponding to the interactive node is generated according to the node data of the interactive node.

[0089] S303: Whether the network request event is matched. If the network request event is matched, S304 is executed; if the network request event is not matched, S305 is executed.

[0090] S304: Insert network request interception code and the second assertion.

[0091] Specifically, when it is determined that the interactive node belongs to the interactive node matched by the network request event, a network request interception code is obtained; based on the network request status value included in the event information of the network request event, a second assertion corresponding to the network request event is generated; the network request interception code and the second assertion are added to the test code of the interactive node corresponding to the network request event, to generate an updated test code corresponding to the interactive node.

[0092] S305: Record the interval time.

[0093] That is, based on the behavior data of the user interaction behavior, the interval time between adjacent interaction nodes in the operation flow information is determined; and based on the interval time between adjacent interaction nodes, a time code is generated.

[0094] S306: Code combination.

[0095] According to the triggering order of each interaction node, the test codes corresponding to each interaction node are combined, and the corresponding time code is inserted between the test codes of adjacent interaction nodes to generate the end-to-end test case code corresponding to the business process.

[0096] S307: Insert the first assertion.

[0097] When the target interaction event is included in the operation flow information, a first assertion for determining whether the target interaction event can be triggered is obtained; the first assertion is added before the test code corresponding to the target interaction event in the end-to-end test case code to obtain an updated end-to-end test case code.

[0098] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0099] Based on the same inventive concept, the embodiment of the present disclosure also provides a test case generation device corresponding to the test case generation method. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned test case generation method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0100] Reference Figure 4 As shown, it is a schematic diagram of a test case generation device provided by an embodiment of the present disclosure, the device includes: an acquisition module 401, a determination module 402, a first generation module 403, and a second generation module 404; wherein, Acquisition module 401, used to acquire behavior data of user interaction behavior when executing a business process of a business system; wherein the behavior data includes event information of each interaction event triggered by the user on the operation page of the business system for the business process; A determination module 402, configured to determine an interaction node and node data corresponding to the interaction node based on the behavior data of the user interaction behavior; A first generating module 403, configured to generate operation flow information corresponding to the business process based on the interaction nodes and the node data according to the triggering order of each interaction node; The second generating module 404 is used to generate end-to-end test case codes corresponding to the business process based on the operation flow information.

[0101] In an optional implementation manner, the device further includes: a testing module 405, configured to: After the system functions of the business system are updated, determining each business process including the system functions; The end-to-end test case codes corresponding to the business processes are used to determine the test results corresponding to the system functions.

[0102] In an optional implementation, the second generating module 404, when generating the end-to-end test case code corresponding to the business process based on the operation flow information, is used to: Utilizing a behavior simulation tool, parsing and reading node data of each of the interaction nodes in the operation flow information; and for each of the interaction nodes, generating a test code corresponding to the interaction node according to the node data of the interaction node; According to the triggering sequence of each of the interaction nodes, the test codes corresponding to each of the interaction nodes are combined to generate an end-to-end test case code corresponding to the business process.

[0103] In an optional implementation manner, the second generating module 404, after generating the end-to-end test case code corresponding to the business process, is further used to: When the operation flow information includes a target interaction event, obtaining a first assertion for determining whether the target interaction event is triggerable; The first assertion is added before the test code corresponding to the target interaction event in the end-to-end test case code to obtain an updated end-to-end test case code.

[0104] In an optional implementation manner, the second generating module 404 is further configured to: Determining the interval time between adjacent interaction nodes in the operation flow information based on the behavior data of the user interaction behavior; Generate a time code based on the interval time between the adjacent interaction nodes; The second generating module 404 is used to combine the test codes corresponding to the interaction nodes according to the triggering order of the interaction nodes to generate the end-to-end test case code corresponding to the business process: According to the triggering order of each of the interactive nodes, the test codes corresponding to each of the interactive nodes are combined, and the corresponding time code is inserted between the test codes of adjacent interactive nodes to generate an end-to-end test case code corresponding to the business process.

[0105] In an optional implementation, when the behavior data includes event information of a network request event, after generating the test code corresponding to the interactive node, the second generating module 404 is further configured to: Get the network request interception code; Generate a second assertion corresponding to the network request event based on the network request state value included in the event information of the network request event; The network request interception code and the second assertion are added to the test code of the interactive node corresponding to the network request event to generate an updated test code corresponding to the interactive node, wherein the updated test code is used to generate the end-to-end test case code.

[0106] In an optional implementation, after the operation flow information corresponding to the business process is generated, the system further includes: a verification module 406, which is used to: Verifying the operation flow information; When it is determined through verification that the operation flow information is abnormal, the operation flow information is adjusted to generate adjusted operation flow information.

[0107] In an optional implementation, the acquisition module 401, when acquiring the behavior data of the user interaction behavior when executing the business process of the business system, is used to: Using a page monitoring script to monitor various interaction events triggered by users on the business system; When a first interaction event that starts the business process is monitored, event information of the first interaction event and event information of each interaction event after the first interaction event are collected until a second interaction event that ends the business process is monitored; Based on the collected event information of each interaction event, behavior data of the user interaction behavior corresponding to the business process is generated.

[0108] In an optional implementation manner, the interaction event includes one or more of the following: Click events, input events, mouse movement events, drag events, scroll events, context menu events, form submission events, network request events.

[0109] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0110] The present disclosure also provides a computer device, such as Figure 5 FIG. 1 is a schematic diagram of a computer device structure provided in an embodiment of the present disclosure, including: A processor 51 and a memory 52; the memory 52 stores machine-readable instructions executable by the processor 51, and the processor 51 is used to execute the machine-readable instructions stored in the memory 52. ​​When the machine-readable instructions are executed by the processor 51, the processor 51 performs the following steps: Acquire event information corresponding to multiple element click events of the function to be tested on the business system, wherein the event information includes event content information of the element click event and network request information triggered by the element click event; Based on the event information respectively corresponding to the multiple element click events, generating operation flow information for the function to be tested; Based on the operation flow information, a test case code corresponding to the function to be tested is generated.

[0111] The above-mentioned memory 52 includes an internal memory 521 and an external memory 522; the internal memory 521 here is also called an internal memory, which is used to temporarily store the calculation data in the processor 51, as well as the data exchanged with the external memory 522 such as a hard disk. The processor 51 exchanges data with the external memory 522 through the internal memory 521.

[0112] The specific execution process of the above instructions can refer to the steps of the test case generation method described in the embodiment of the present disclosure, which will not be repeated here.

[0113] The embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the test case generation method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0114] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the test case generation method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0115] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0116] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

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

[0118] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0119] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0120] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for generating a test case, characterized in that: include: Obtain behavioral data on user interaction behaviors when executing business processes of business systems; The behavior data includes event information of each interaction event triggered by the user on the operation page of the business system for the business process; Determining an interactive node and node data corresponding to the interactive node based on the behavior data of the user interaction behavior; Generate operation flow information corresponding to the business process based on the interaction nodes and the node data according to the triggering order of each interaction node; Based on the operation flow information, an end-to-end test case code corresponding to the business process is generated.

2. The method according to claim 1, characterized in that The method further comprises: After the system functions of the business system are updated, determining each business process including the system functions; The end-to-end test case codes corresponding to the business processes are used to determine the test results corresponding to the system functions.

3. The method according to claim 1, characterized in that The step of generating end-to-end test case code corresponding to the business process based on the operation flow information includes: Utilizing a behavior simulation tool, parsing and reading the node data of each of the interaction nodes in the operation flow information; and for each of the interaction nodes, generating a test code corresponding to the interaction node according to the node data of the interaction node; According to the triggering sequence of each of the interaction nodes, the test codes corresponding to each of the interaction nodes are combined to generate an end-to-end test case code corresponding to the business process.

4. The method according to claim 3, characterized in that After generating the end-to-end test case code corresponding to the business process, the method further includes: When the operation flow information includes a target interaction event, obtaining a first assertion for determining whether the target interaction event is triggerable; The first assertion is added before the test code corresponding to the target interaction event in the end-to-end test case code to obtain an updated end-to-end test case code.

5. The method according to claim 3, characterized in that: The method further comprises: Determining the interval time between adjacent interaction nodes in the operation flow information based on the behavior data of the user interaction behavior; Generate a time code based on the interval time between the adjacent interaction nodes; The step of combining the test codes corresponding to the interaction nodes according to the triggering order of the interaction nodes to generate an end-to-end test case code corresponding to the business process includes: According to the triggering order of each of the interactive nodes, the test codes corresponding to each of the interactive nodes are combined, and the corresponding time code is inserted between the test codes of adjacent interactive nodes to generate an end-to-end test case code corresponding to the business process.

6. The method according to claim 3, characterized in that When the behavior data includes event information of a network request event, after generating the test code corresponding to the interactive node, the method further includes: Get the network request interception code; Generate a second assertion corresponding to the network request event based on the network request state value included in the event information of the network request event; The network request interception code and the second assertion are added to the test code of the interactive node corresponding to the network request event to generate an updated test code corresponding to the interactive node, wherein the updated test code is used to generate the end-to-end test case code.

7. The method according to claim 1, characterized in that After generating the operation flow information corresponding to the business process, the method further includes: Verifying the operation flow information; When it is determined through verification that the operation flow information is abnormal, the operation flow information is adjusted to generate adjusted operation flow information.

8. The method according to any one of claims 1 to 7, characterized in that: The obtaining of behavior data of user interaction behavior when executing the business process of the business system includes: Using a page monitoring script to monitor various interaction events triggered by users on the business system; When a first interaction event that starts the business process is monitored, event information of the first interaction event and event information of each interaction event after the first interaction event are collected until a second interaction event that ends the business process is monitored; Based on the collected event information of each interaction event, behavior data of the user interaction behavior corresponding to the business process is generated.

9. The method according to claim 1, characterized in that: The interaction event includes one or more of the following: Click events, input events, mouse movement events, drag events, scroll events, context menu events, form submission events, network request events.

10. A test case generation device, characterized in that: include: An acquisition module is used to acquire behavior data of user interaction behaviors when executing business processes of a business system; The behavior data includes event information of each interaction event triggered by the user on the operation page of the business system for the business process; A determination module, configured to determine an interaction node and node data corresponding to the interaction node based on the behavior data of the user interaction behavior; A first generating module, configured to generate operation flow information corresponding to the business process based on the interaction nodes and the node data according to the triggering order of each interaction node; The second generating module is used to generate end-to-end test case code corresponding to the business process based on the operation flow information.

11. A computer device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the processor executes the steps of the test case generation method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program. When the computer program is executed by a computer device, the computer device executes the steps of the test case generation method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Development method and terminal equipment of automated test cases

    CN109062780A

  • Business data automatic generation method and system, electronic equipment and computer storage medium

    CN110618778A

  • Test case generation method, device and equipment

    CN113254338A

  • Test case generation method and device, equipment, storage medium and product

    CN114490408A

  • Game test case generation method and device, electronic equipment and storage medium

    CN116244192A