Distributed use case execution method and use case execution system based on use case dependency
By introducing message queues and distributed execution systems in automated testing, the problem of inefficient concurrent execution caused by use case dependencies is solved, and efficient use case execution and dependency management is achieved.
Patent Information
- Application Number
- CN202411639839.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-04-15
AI Technical Summary
In automated testing, the existence of dependencies between use cases leads to inefficient concurrent execution, and the prior art requires manual adjustment of use case allocation, increasing management costs and testing time.
By introducing a message queue as middleware in the use case execution system, the use case is built as a message, and the predependence of the use case is considered in the execution node, distributed parallel execution is realized.
It effectively improves the execution efficiency of large-scale automation use cases, ensures the correct compliance of use case dependencies, and reduces manual intervention and management costs.
Smart Images

Figure CN119829417A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of interface automated testing, and in particular to a distributed use case execution method and a use case execution system based on use case dependency. Background Art
[0002] As product functions expand and become more complex, the number of use cases in the automated testing process also increases. If a single node is used for full execution, the execution time required is unbearable for testers.
[0003] In related technologies, the method of concurrently executing automated use cases is usually used to improve the efficiency of use case execution. However, this method requires that there is no dependency between automated use cases. When use cases with dependencies need to be executed concurrently, it is usually necessary to manually adjust the use case allocation and send the related use cases to the same node in sequence for execution, resulting in the inability to achieve the effect of multi-node concurrent execution in automated testing, thereby affecting the efficiency of testing. How to improve the execution efficiency of automated projects while satisfying use case dependencies has become a problem that needs to be solved. Summary of the invention
[0004] In view of this, the present disclosure provides a distributed use case execution method and a use case execution system based on use case dependencies to solve the problem of how to improve the execution efficiency of automation projects while satisfying use case dependencies.
[0005] On the one hand, the present disclosure provides a distributed use case execution method based on use case dependency, the method comprising: initializing the use cases in the test plan, and storing the use cases in a database according to a preset format; constructing a message corresponding to the use case based on the use cases in the test plan in the database, and sending the message to a message queue so that the message queue sends the message to an execution node; the message includes a pre-dependency relationship of the use case, and the pre-dependency relationship is used to characterize the pre-use case on which the use case depends; obtaining the execution result of the execution node for the message, and updating the database based on the execution result; the execution result is determined by the execution node based on the pre-dependency relationship, or the pre-dependency relationship and the pre-use case.
[0006] On the other hand, the present disclosure also provides a use case execution system, the system includes a main control node, a database and a message queue, wherein: the main control node is used to initialize the use cases in the test plan, and the use cases are stored in the database according to a preset format; the main control node is used to build messages corresponding to the use cases based on the use cases in the test plan in the database, and send the messages to the message queue; the messages include the pre-dependencies of the use cases, and the pre-dependencies are used to characterize the pre-use cases on which the use cases depend; the message queue is used to send the messages to the execution nodes; the main control node is used to obtain the execution results of the execution nodes for the messages, and update the database based on the execution results; the execution results are determined by the execution nodes based on the pre-dependencies, or the pre-dependencies and the pre-use cases.
[0007] On the other hand, the present disclosure further provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to implement the above-mentioned distributed use case execution method based on use case dependency.
[0008] On the other hand, the present disclosure further provides a computer program product, including computer instructions, where the computer instructions are used to enable a computer to execute the above-mentioned distributed use case execution method based on use case dependency.
[0009] Through the distributed use case execution method and use case execution system based on use case dependency of the above-mentioned embodiments of the present invention, a message queue is set as middleware, the use case is constructed as a message, the message queue is used to distribute the message, and the predecessor use cases that the use case depends on are considered in the process of executing the use case on the execution node. The use cases in the test plan can be divided and allocated to different execution nodes according to their dependency relationships, thereby realizing distributed parallel execution and improving the execution efficiency of large-scale automated use cases.
[0010] The distributed use case execution method and use case execution system based on use case dependency provided by the embodiments of the present disclosure are particularly suitable for processing automated testing processes with a large number of use cases and complex dependencies in systems with large business scales. The embodiments of the present disclosure utilize a distributed architecture to distribute different test cases to multiple execution nodes for parallel processing, ensuring that the dependencies of the use cases can be correctly followed. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0012] Figure 1aAn exemplary schematic diagram showing the architecture of a use case execution system applied by the distributed use case execution method based on use case dependency according to an embodiment of the present disclosure;
[0013] Figure 1b It is a flowchart of a distributed use case execution method based on use case dependency provided by an embodiment of the present disclosure;
[0014] Figure 2 It is a specific flow chart of a distributed use case execution method based on use case dependency provided by an embodiment of the present disclosure;
[0015] Figure 3 is a structural diagram of a use case execution system provided by an embodiment of the present disclosure;
[0016] Figure 4 It is a structural diagram of another use case execution system provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0017] With the rapid development of information-based services, the functions of various systems and applications have become increasingly complex, and the importance of automated testing has become increasingly prominent. Automated testing has significant advantages in ensuring system stability, accelerating iterative updates, and reducing manual testing costs. However, with the gradual expansion of system functions and the increase in business complexity, the number of automated test cases has also increased dramatically. For a mature and complex product, the number of interface automation cases may reach thousands or even tens of thousands. Such a large-scale set of use cases faces significant challenges when executing. For example, if all automated use cases are executed one by one on a single node, even if the interface response time is controlled within 300 milliseconds, it will take about half an hour to execute 6,000 use cases. For some special business scenarios, the interface response time may be longer, and there is a failure retry mechanism, resulting in the execution time of a single node being unable to meet business needs.
[0018] At present, the related technologies generally use concurrent execution to improve the execution speed of use cases. However, this method usually assumes that use cases are independent of each other and have no execution order dependency. In practical applications, the following problems often exist:
[0019] 1. The complex dependencies between many use cases make concurrent execution difficult. If use cases are randomly assigned to different execution nodes and the order of their dependencies is not met, execution failure or inaccurate results will often occur.
[0020] 2. In order to meet the dependency requirements, the relevant solution is to manually adjust the use case allocation method and arrange the use cases with dependencies on the same node for sequential execution. This manual adjustment method not only increases the cost of use case management and maintenance, but also places higher demands on the energy of testers. At the same time, manual allocation is also difficult to fully utilize the advantages of multiple nodes. Due to the uneven distribution of use cases, some node resources may not be fully utilized, affecting the overall execution efficiency.
[0021] To solve the above problems, various embodiments of the present disclosure provide a distributed use case execution method based on use case dependency, the method is applied to a use case execution system, the system includes a master node, a database and a message queue, the method includes: initializing the use cases in the test plan, and storing the use cases in the database according to a preset format; based on the use cases in the test plan in the database, constructing messages corresponding to the use cases, and sending the messages to the message queue so that the message queue sends the messages to the execution node; the messages include the predecessor dependency of the use case, and the predecessor dependency is used to characterize the predecessor use case on which the use case depends; obtaining the execution result of the execution node for the message, and updating the database based on the execution result; the execution result is determined by the execution node based on the predecessor dependency, or the predecessor dependency and the predecessor use case.
[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution 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 part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0023] Please refer to Figure 1a , Figure 1a An exemplary schematic diagram of the architecture of a use case execution system applied by the distributed use case execution method based on use case dependency according to an embodiment of the present disclosure is shown. Figure 1a As shown, the use case execution system may include: a master control node, a database, and a message queue.
[0024] The use case execution system can be an execution framework or platform for automated testing, which can be used to coordinate and control the concurrent execution, dependency management and result feedback of use cases, thereby realizing the execution of large-scale distributed concurrent tests.
[0025] The master node can be the control core of the test case execution system and can be responsible for managing the distribution of test plans and tasks. The database can be a preset data structure for storing test cases and execution status and can be used to record relevant information and status of all test cases. The message queue can be a component for coordinating task distribution and acts as a communication medium between the execution node and the master node.
[0026] Furthermore, the execution node can refer to the computing unit that actually executes the use case and returns the execution result in the distributed use case execution system. The master node and the execution node do not communicate directly, but are asynchronously transmitted and decoupled through message queues, which can avoid the performance bottleneck caused by direct interaction.
[0027] Among them, the master control node, database, message queue and execution node can be pre-set according to the actual application scenario or the experience of those skilled in the art, and can be equipment or devices in the existing technology or future development technology, and the present disclosure does not limit this. For example, the master control node can include but is not limited to: a server, a virtual machine, a cloud computing instance, the database can include but is not limited to: a relational database, a distributed database cluster, a cloud database service, and the message queue can include but is not limited to: a dedicated message queue server, a cloud message service.
[0028] like Figure 1a As shown, the master control node is deployed in the use case execution system, interacts with the database and the message queue, enables the database to obtain the execution results of the execution node, and enables the message queue to send messages to the execution node.
[0029] Further references Figure 1b , Figure 1b is a flow chart of a distributed use case execution method based on use case dependency provided by an embodiment of the present disclosure, which is applied to the above Figure 1a The use case execution system shown in , the process of the method may include the following steps:
[0030] Step S101, initialize the use cases in the test plan, and store the use cases in a database according to a preset format.
[0031] In this embodiment, the master control node can obtain the test plan through the database, or obtain the test plan from the use case execution system through an interface request. For example, the master control node can periodically query the database to obtain the test plan whose status is represented as to be executed, or periodically obtain the test plan to be executed from the use case execution system through an application programming interface (Application Programming Interface, API).
[0032] Here, the test plan can be used to define a set of test cases to be executed for a specific test goal or test requirement. The test plan can be used to determine the scope, methods, goals and time of automated testing.
[0033] For example, the test plan may include: Use Case 1: Registration Interface Test, Use Case 2: Login Interface Test, Test Time January 1, Completion Condition: All use cases are executed and the pass rate is greater than 80%.
[0034] A use case can refer to the smallest execution unit in automated testing, which is used to verify whether the specific functions of a system or application meet expectations. A use case may include but is not limited to: input data, execution steps, expected results, and execution status. The preset format of a use case when it is stored in a database may include but is not limited to a table or document.
[0035] Step S102, based on the use case in the test plan in the database, construct a message corresponding to the use case, and send the message to the message queue, so that the message queue sends the message to the execution node.
[0036] In this embodiment, the message includes a pre-dependency relationship of the use case, and the pre-dependency relationship is used to characterize the pre-use case on which the use case depends.
[0037] Here, a message can be an information unit used to describe the use case information in a test plan, and the relationship between a message and a use case is one-to-one. A message queue can be a message-based communication mechanism that can decouple modules by storing messages and delivering them to consumers (i.e., execution nodes) in sequence. A message queue can be used for asynchronous messaging and can support multiple producers and multiple consumers.
[0038] As an example, the producer of a message may refer to a master node, that is, the master node constructs a message and puts the message into a message queue, and the consumer of a message may refer to an execution node, that is, the execution node takes the message from the message queue and executes the use case corresponding to the message.
[0039] Furthermore, the message queue can temporarily store the messages corresponding to the use case and pass the messages to the execution nodes in sequence in a first-in-first-out manner.
[0040] Furthermore, when a use case has a pre-dependency, the message queue can send the use case to the corresponding execution node after the pre-dependency condition is met to ensure the execution order.
[0041] As an example, test plan A includes two use cases, a and b, where use case a is a test case for interface 1, and the message of use case a is the first message; use case b is a test case for interface 2, and the message of use case b is the second message depending on the execution result of use case a. Here, the message queue of test plan A may include the first message and the second message, and the master control node sends a control instruction to the message queue so that the message queue first sends the first message to the first execution node, and then sends the second message to the second execution node.
[0042] Step S103, obtaining the execution result of the execution node for the message, and updating the database based on the execution result.
[0043] In this embodiment, the execution result may refer to the status feedback of the execution node after processing and executing the test case message received from the message queue. The status feedback may include but is not limited to: case execution status, error information, request parameters and response results.
[0044] The test case execution status may refer to the current status of the test case during execution. For example, the test case execution status may include one of the following: success (or pass, hereinafter collectively referred to as pass), failure (or failure, hereinafter collectively referred to as fail), skip (or not executed, hereinafter collectively referred to as skip), waiting (or ready, hereinafter collectively referred to as ready).
[0045] Here, pass can indicate that the use case is executed successfully, that is, the use case is executed as expected and all assertions are met; fail can indicate that the use case fails to execute, that is, an error occurs during the execution of the use case or the expected result is not achieved; skip can indicate that the use case is skipped, that is, the use case is not executed due to preset reasons; ready can indicate that the use case is in a ready state and has not yet been executed, waiting for its dependent use cases or other conditions to be met before execution.
[0046] Furthermore, the error information may indicate some detailed error information or failure reasons provided by the execution node if the execution result is a failure; the request parameters may refer to the request call parameters of the interface in the use case, and the response result may refer to the return result of the interface response request parameters in the use case.
[0047] As a possible implementation of the above embodiment, the execution result can be determined by the execution node based on the predecessor dependency, or the predecessor dependency and the predecessor use case. When the predecessor dependency represents a use case without a predecessor use case, the execution result is determined by the execution node based on the predecessor dependency; when the predecessor dependency represents a use case with a predecessor use case, the execution result is determined by the execution node based on the predecessor dependency and the predecessor use case.
[0048] In the distributed use case execution method and use case execution system based on use case dependency in the above-mentioned embodiment of the present disclosure, by dividing the use cases in the test plan according to their dependency relationships and allocating them to different execution nodes, distributed parallel execution is effectively achieved, thereby greatly improving the execution efficiency of large-scale automated use cases; when the use case is initialized, the dependency relationships are set in advance and recorded in the database, and through the coordinated control of the message queue and the dependency relationships, there is no need to manually adjust the use case allocation method, thereby avoiding the complexity of human intervention and reducing the use case management and maintenance costs; during the execution process, the pre-dependency relationship of each use case is clearly represented in the message queue and the database, ensuring that the use cases with the dependency relationships are executed in the correct order, and even if the use cases are distributed to different nodes, the dependency check and status update mechanism can still ensure that the execution order of the use cases is correct, avoiding execution failures due to sequential dependency problems.
[0049] In a possible implementation of the above step S101, initializing the use cases in the test plan and storing the use cases in a database according to a preset format includes:
[0050] Generate a test plan identifier corresponding to the test plan and a use case identifier corresponding to at least one use case in the test plan;
[0051] Each use case in at least one use case is stored in a database according to a preset format, where the preset format includes at least one item: a test plan identifier, a use case identifier, a use case execution status, a request parameter, and a response result.
[0052] In this embodiment, the main control unit generates a corresponding test plan identifier for the test task executed by this automated test. Here, the test plan identifier can specifically be a test plan identity (Identity, ID), and the test plan ID is a unique identifier of the test plan. The use case identifier can refer to the use case ID.
[0053] Storing each use case in at least one use case in a database in a preset format may include:
[0054] A database table is defined based on a preset format to store all use cases in a test plan corresponding to a test plan ID.
[0055] Here, each use case can be stored in a table of the database based on the preset format of {test plan ID}|{use case ID}|{use case execution status}|{request parameters}|{response results}. Among them, {test plan ID}, {use case ID}, {use case execution status}, {request parameters} and {response results} are the first column header, the second column header, the third column header, the fourth column header and the fifth column header of the table of the database respectively.
[0056] In the distributed use case execution method and use case execution system based on use case dependency of the above-mentioned embodiment of the present disclosure, by defining the database table structure based on a preset format to store use case information, it is ensured that all use case data is stored according to consistent standards, so that the management, query and update of use cases become more orderly, and the data inconsistency problems caused by storage in different formats are reduced, thereby improving the efficiency of the automated testing process; for large-scale automated testing tasks, especially test plans that need to execute tens of thousands of use cases, the unified design of the database structure can effectively support the storage and processing of large amounts of data, so that this embodiment is particularly used to process automated testing processes with a large number of use cases and complex dependencies in systems with large business scales.
[0057] In a possible implementation of step S103, obtaining the execution result of the execution node for the message and updating the database based on the execution result includes:
[0058] When it is determined that the use case has no predecessor use case based on the predecessor dependency in the message corresponding to the use case, the execution node corresponding to the use case is used to execute the use case, obtain the first execution state and the first execution result corresponding to the use case, and update the first execution state and the first execution result to the database based on the test plan identifier and the use case identifier of the use case;
[0059] When it is determined that a use case has a predecessor use case based on the predecessor dependency in the corresponding message of the use case, query the use case execution status of the predecessor use case;
[0060] Based on the use case execution status of the preceding use case, the second execution status and the second execution result of the use case are obtained, and based on the test plan identifier and the use case identifier of the use case, the second execution status and the second execution result are updated to the database.
[0061] In this embodiment, when it is determined that the use case has no predecessor use case based on the predecessor dependency relationship in the message corresponding to the use case, the execution node corresponding to the use case is used to execute the use case, and the first execution state and the first execution result corresponding to the use case are obtained, including:
[0062] When the predecessor dependency in the message is empty, it is determined that the use case has no predecessor use case, and an execution is sent to the execution node corresponding to the use case, so that the execution node directly executes the use case, calls the corresponding interface based on the request parameters in the use case, and obtains the first execution status and the first execution result corresponding to the use case.
[0063] Here, the form of the predecessor dependency may include but is not limited to: an array, a dictionary, or a data structure combining a state and an execution order.
[0064] As an example, when the predecessor dependency is an array, the predecessor dependency in the message of use case ID3 may include: ["use case ID1", "use case ID2"], which can indicate that use case ID3 depends on the predecessor use cases ID1 and ID2. When the array is [], that is, the array is empty, it can indicate that use case ID3 has no predecessor use case.
[0065] When the preceding dependency is a dictionary, the preceding dependency in the message of use case ID3 may include:
[0066] {
[0067] "Use Case ID1":"pass",
[0068] "Use Case ID2":"fail"
[0069] }
[0070] At this time, it can be represented that use case ID3 depends on the preceding use cases ID1 and ID2, and the use case execution status of use case ID1 is pass, and the use case execution status of use case ID2 is fail; when the dictionary is {}, that is, the dictionary is NULL, it can be represented that use case ID3 has no preceding use case.
[0071] In a possible implementation of the above embodiment, obtaining the second execution state and the second execution result of the use case based on the use case execution state of the preceding use case may include:
[0072] Query the use case execution status of the previous use case. When the use case execution status of the previous use case is pass, execute the current use case, modify the use case execution status in the database table to the second execution status, and obtain the second execution result;
[0073] When the use case execution status of the current use case is not pass, the current use case is not executed, and the use case execution status in the database table is modified to the second execution status.
[0074] In a possible implementation manner of the above embodiment, the message includes at least one of the following: a use case name, a use case identifier, a pre-dependency relationship, a request interface, and a request interface parameter.
[0075] The request interface refers to the interface uniform resource identifier (URI) tested in the use case, which can be used to identify the interface address of the specific server to be tested, and the request interface parameter can be the input data required to be carried when sending a request to the interface.
[0076] In the distributed use case execution method and use case execution system based on use case dependency of the above-mentioned embodiment of the present disclosure, when a use case has a predecessor dependency, the execution status of the predecessor use case is first queried, and the current use case is executed only when the execution status of the predecessor use case is pass, thereby ensuring the order and dependency of the use case execution, and avoiding execution failure or logical inconsistency caused by concurrent execution or dependency order errors; by associating the execution status and results of each use case with the test plan and use case identification, a large number of automated use cases can be effectively tracked and managed, reducing manual intervention and maintenance costs; execution based on dependency guarantees the correct execution order of the use case and the satisfaction of the dependency, thereby improving execution efficiency and system stability; the explicit inclusion of the request interface and request interface parameters enables each use case to accurately locate the interface to be called during execution, and ensures that the parameters of the interface call are correct, thereby reducing manual intervention and improving testing efficiency.
[0077] In a possible implementation manner of the above embodiment, the first execution status includes success or failure; and
[0078] Based on the test plan identifier and the use case identifier of the use case, updating the first execution state and the first execution result into the database includes:
[0079] Determine in the database a test plan that matches the test plan identifier, and determine in the test plan a use case that matches the use case identifier;
[0080] The use case execution state of the use case is updated to the first execution state, and the request parameters and response results of the use case are updated to the first execution result.
[0081] In this embodiment, the first execution state includes pass or fail.
[0082] When it is determined based on the predecessor dependency in the message corresponding to the use case that the use case has no predecessor use case, executing the use case using the execution node corresponding to the use case, and obtaining the first execution state and the first execution result corresponding to the use case may include:
[0083] When a use case has no preceding use case, the execution node is directly made to execute the use case, and the first execution status corresponding to the use case is obtained, which is pass or fail, and the first execution result corresponding to the use case including request parameters and response data.
[0084] Here, when the first execution status is fail, the first execution result may further include error information.
[0085] Based on the test plan identifier and the use case identifier of the use case, updating the first execution state and the first execution result into the database may include:
[0086] When the first execution status is pass, update pass to the use case execution status of the use case in the database table, update the request parameters to {request parameters} of the use case in the database table, and update the response data to {response result} of the use case in the database table;
[0087] When the first execution result is fail, fail is updated to the use case execution status of the use case in the database table, the request parameters are updated to the {request parameters} of the use case in the database table, and the response data is updated to the {response result} of the use case in the database table.
[0088] In the distributed use case execution method and use case execution system based on use case dependency of the above-mentioned embodiments of the present disclosure, the first execution state and the first execution result of the use case are associated with the test plan identifier and the use case identifier, which can conveniently trace the specific execution status of each use case, thereby improving the efficiency of auditing and backtracking in the automated testing process; matching the test plan identifier and the use case identifier in the database helps to accurately find the corresponding test case and update its execution status, which can avoid manual maintenance errors and omissions, and can also efficiently manage the execution status of each use case in a large-scale use case library, especially when it comes to test plans for multiple use cases, which significantly improves management efficiency and accuracy.
[0089] In a possible implementation of the above embodiment, the use case execution status of the preceding use case includes one of the following: success, failure, waiting, or skipping; and
[0090] Based on the use case execution status of the preceding use case, obtaining a second execution status and a second execution result of the use case, and based on the test plan identifier and the use case identifier of the use case, updating the second execution status and the second execution result into a database, including:
[0091] When the use case execution status of the preceding use case is successful, the execution node is caused to execute the use case to determine a second execution status and a second execution result; the second execution status includes success or failure;
[0092] Determine in the database a test plan that matches the test plan identifier, and determine in the test plan a use case that matches the use case identifier;
[0093] Update the use case execution status of the use case in the database to success or failure, and update the request parameters and response results of the use case to the second execution result;
[0094] When the use case execution status of the preceding use case is failure or skip, the execution node skips the use case, determines that the second execution status of the use case is skip, and updates the use case execution status of the use case in the database to skip;
[0095] When the use case execution state of the current use case is waiting, the message corresponding to the use case is rewritten back to the message queue, the second execution state of the use case is determined to be waiting, and the use case execution state of the use case in the database is updated to waiting.
[0096] In this embodiment, the use case execution status of the preceding use case includes one of the following: pass, fail, ready, or skip.
[0097] When the use case execution status of the preceding use case is successful, causing the execution node to execute the use case and determining the second execution status and the second execution result may include:
[0098] When the use case execution status of the preceding use case is pass, it indicates that the preceding use case has been successfully executed, so that the execution node of the current use case directly executes the use case, and determines a second execution status including pass or fail, and a second execution result including a request command and response data.
[0099] Here, when the second execution status is fail, the second execution result also includes error information.
[0100] Updating the use case execution status of the use case in the database to success or failure, and updating the request parameters and response result of the use case to the second execution result may include:
[0101] Make the execution node execute the use case. When the use case execution result is pass, update the use case execution status of the use case in the database to pass; when the use case execution result is fail, update the use case execution status of the use case in the database to fail.
[0102] When the use case execution status of the preceding use case is failure or skip, causing the execution node to skip the use case, determining that the second execution status of the use case is skip, and updating the use case execution status of the use case in the database to skip, may include:
[0103] When the use case execution status of the current use case is fail or pass, the execution node does not execute the current use case, and directly updates the use case execution status of the use case in the database to pass.
[0104] Here, when the use case execution status of the previous use case is fail or pass, it can indicate that the current use case is not suitable for execution by the execution node.
[0105] When the use case execution state of the current use case is waiting, rewriting the message corresponding to the use case back to the message queue, determining that the second execution state of the use case is waiting, and updating the use case execution state of the use case in the database to waiting may include:
[0106] When the use case execution state of the preceding use case is ready, the execution node rewrites the acquired use case into the message queue, and updates the second execution state of the use case to ready.
[0107] Here, the use case execution status of the predecessor use case is ready, which indicates that the predecessor use case of the current use case has not been executed yet. As the current use case depends on the predecessor use case, it cannot be executed either. The current use case needs to wait for the predecessor use case to be executed before it can be executed.
[0108] In the distributed use case execution method and use case execution system based on use case dependency of the above-mentioned embodiment of the present disclosure, the execution of subsequent use cases is dynamically processed through the execution status of the predecessor use case to ensure that the dependency relationship is correctly executed, and the execution status of the current use case is determined by judging the execution result of the predecessor use case, thereby realizing the automatic processing of complex dependency relationships between multiple use cases and improving the execution efficiency of automated testing; when the predecessor use case succeeds, the execution node can be allowed to continue to execute the current use case to ensure the consistency of the execution order and logic; when the predecessor use case fails or is skipped, the current use case is automatically skipped, thereby reducing invalid operations and ensuring the accuracy of the test results; if the predecessor use case is in a waiting state, the current use case is put back into the message queue so that it can be retried to execute at an appropriate time to avoid erroneous execution when the prerequisite is not met; this scheme greatly reduces manual intervention by automatically detecting and making corresponding operations of execution, skipping or waiting based on different dependency states, and further improves the technical effect of automated testing.
[0109] In a specific embodiment, the method further comprises:
[0110] Based on the test plan identifier, traverse the corresponding test plan in the database, and determine whether there is a target use case whose use case execution status is waiting in at least one use case in the test plan;
[0111] When a target use case exists, execute the target use case until the use case execution status of the target use case is updated to success or failure;
[0112] When there are no remaining use cases, obtain the request parameters and response results corresponding to each use case in at least one use case in the database.
[0113] In this embodiment, based on the test plan identifier, the corresponding test plan in the database is traversed, and it is determined whether there is a target use case with a use case execution status of waiting in at least one use case in the test plan. This can include: according to the specified test plan identifier, finding a test plan matching the identifier from the database, and checking whether there is a target use case with an execution status of ready among all use cases in the test plan.
[0114] When a target use case exists, the target use case is executed until the use case execution status of the target use case is updated to success or failure, which may include: if there is a waiting target use case (indicating that the use case has not yet met its prerequisite dependency conditions, or its prerequisite conditions have been met but the use case has not yet started execution), the use case is sent to the corresponding execution node, so that the execution node starts to execute the above use case after the use case meets all prerequisite dependencies, and generates the use case execution status and the use case execution result; the use case execution status of the above use case is updated to pass or fail, and the corresponding request parameters and response results are stored in the database.
[0115] When there are no remaining use cases, obtaining the request parameters and response results corresponding to each use case in at least one use case in the database may include: when there are no use cases in the ready state in the test plan, determining that all use cases have been executed, obtaining the request parameters and response results of all use cases under the test plan from the database, and ensuring that the execution results of each use case have been saved; and summarizing the execution results of all use cases for subsequent analysis.
[0116] In the distributed use case execution method and use case execution system based on use case dependency of the above embodiment of the present disclosure, the above traversal and judgment method ensures that all use cases in the test plan can be executed step by step according to the dependency relationship, that is, when the dependency conditions of all use cases are met, the system will automatically start execution, avoiding manual intervention, thereby improving the efficiency and accuracy of use case execution. In addition, after the execution is completed, all request parameters and response results are uniformly obtained, which facilitates the unified management of test analysis and test data.
[0117] In one embodiment, Figure 2 is a specific flow chart of a distributed use case execution method based on use case dependency provided by an embodiment of the present disclosure, such as Figure 2 As shown, the specific steps include:
[0118] Step S201, the information queue sends information to the execution node;
[0119] Here, set up the message queue so that the message queue sends messages corresponding to the use cases to the execution nodes;
[0120] Step S202, determine whether the use case has a predecessor use case; if so, proceed to step S303, if not, proceed to step S204;
[0121] Here, it is determined whether the use case has a predecessor use case based on the predecessor dependency contained in the message;
[0122] Step S203, determine whether the preceding use case has been executed; if so, proceed to step S305, if not, proceed to step S206;
[0123] Here, determine whether the use case execution status of the predecessor use case is ready;
[0124] Step S204, enabling the execution node to execute the current use case;
[0125] Here, when there is no preceding use case for a use case, the execution node is directly made to execute the current use case;
[0126] Step S205, determine whether the preceding use case fails to execute, if so, proceed to step S207, if not, proceed to step S204;
[0127] Here, determine whether the use case execution status of the predecessor use case is fail or pass;
[0128] Step S206, causing the execution node to write the message back to the message queue;
[0129] Here, when the node execution state of the preceding node is ready, the execution node is made to rewrite the received message back to the message queue;
[0130] Step S207, causing the execution node to skip the use case;
[0131] Here, when the use case execution status of the preceding use case is fail or pass, the execution node is made to skip the use case and the use case execution status of the use case is updated to skip;
[0132] Step S208, determining whether there are any use cases in the test plan whose execution status is ready, if so, proceeding to step S310, if not, proceeding to step S311;
[0133] Here, determine whether there are any use cases whose execution status is ready among all the use cases corresponding to the test plan ID;
[0134] Step S209, updating the use case execution results of the use case;
[0135] Here, the execution node is made to update the use case execution results of the use case into the database;
[0136] Step S210, ending the execution of this use case, and continuing to enable the execution node to obtain messages;
[0137] Step S211, obtaining the execution results corresponding to all use cases under the test plan.
[0138] In one embodiment, a use case execution system 30 is provided, which corresponds one-to-one to the distributed use case execution method based on use case dependency in the above embodiment. Figure 3As shown, the use case execution system 30 includes a main control node 31, a database 32, a message queue 33 and an execution node 34, wherein each functional module is described in detail as follows:
[0139] The master control node 31 is used to initialize the use cases in the test plan and store the use cases in the database according to a preset format;
[0140] The master control node 31 is used to construct a message corresponding to the use case based on the use case in the test plan in the database 32, and send the message to the message queue 34; the message includes a pre-dependency relationship of the use case, and the pre-dependency relationship is used to characterize the pre-use case on which the use case depends;
[0141] A message queue 33, used to send messages to an execution node 34;
[0142] The main control node 31 is used to obtain the execution result of the execution node 34 for the message, and update the database 32 based on the execution result; the execution result is determined by the execution node 34 based on the pre-dependency, or the pre-dependency and the pre-use case.
[0143] In a specific embodiment, the master control node 31 is specifically used to generate a test plan identifier corresponding to the test plan, and a use case identifier corresponding to at least one use case in the test plan;
[0144] Each use case in at least one use case is stored in a database according to a preset format, where the preset format includes at least one item: a test plan identifier, a use case identifier, a use case execution status, a request parameter, and a response result.
[0145] In a specific embodiment, the main control node 31 is specifically used to execute the use case using the execution node corresponding to the use case when it is determined that the use case has no predecessor use case based on the predecessor dependency relationship in the message corresponding to the use case, obtain the first execution state and the first execution result corresponding to the use case, and update the first execution state and the first execution result to the database based on the test plan identifier and the use case identifier of the use case;
[0146] When it is determined that a use case has a predecessor use case based on the predecessor dependency in the corresponding message of the use case, query the use case execution status of the predecessor use case;
[0147] Based on the use case execution status of the preceding use case, the second execution status and the second execution result of the use case are obtained, and based on the test plan identifier and the use case identifier of the use case, the second execution status and the second execution result are updated to the database.
[0148] In a specific embodiment, the first execution status includes success or failure; and
[0149] The master control node 31 is specifically used to determine the test plan matching the test plan identifier in the database, and determine the use case matching the use case identifier in the test plan;
[0150] The use case execution state of the use case is updated to the first execution state, and the request parameters and response results of the use case are updated to the first execution result.
[0151] In a specific embodiment, the use case execution status of the predecessor use case includes one of the following: success, failure, waiting, or skipping; and
[0152] The main control node 31 is specifically used to make the execution node execute the use case when the use case execution status of the current use case is successful, and determine the second execution status and the second execution result; the second execution status includes success or failure;
[0153] Determine in the database a test plan that matches the test plan identifier, and determine in the test plan a use case that matches the use case identifier;
[0154] Update the use case execution status of the use case in the database to success or failure, and update the request parameters and response results of the use case to the second execution result;
[0155] When the use case execution status of the preceding use case is failure or skip, the execution node skips the use case, determines that the second execution status of the use case is skip, and updates the use case execution status of the use case in the database to skip;
[0156] When the use case execution state of the current use case is waiting, the message corresponding to the use case is rewritten back to the message queue, the second execution state of the use case is determined to be waiting, and the use case execution state of the use case in the database is updated to waiting.
[0157] In a specific embodiment, the master control node 31 is further used to traverse the corresponding test plan in the database based on the test plan identifier, and determine whether there is a target use case whose use case execution status is waiting in at least one use case in the test plan;
[0158] When a target use case exists, execute the target use case until the use case execution status of the target use case is updated to success or failure;
[0159] When there are no remaining use cases, obtain the request parameters and response results corresponding to each use case in at least one use case in the database.
[0160] In a specific embodiment, the message includes at least one of the following: a use case name, a use case identifier, a pre-dependency, a request interface, and a request interface parameter.
[0161] It should be noted that: the use case execution system provided in the above embodiment only uses the division of the above program modules as an example to illustrate when implementing the corresponding distributed use case execution method based on use case dependency. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the above system can be divided into different program modules to complete all or part of the above-described processing. Figure 1b The embodiments of the method shown belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0162] The present disclosure also provides a computer device having the above Figure 3 The use case execution system shown.
[0163] See also Figure 3 , Figure 4 is a structural diagram of another use case execution system provided by an embodiment of the present disclosure, such as Figure 4 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 10 is taken as an example.
[0164] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0165] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0166] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0167] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0168] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 4 The example of connecting through bus is taken in the following.
[0169] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0170] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0171] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0172] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0173] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A distributed use case execution method based on use case dependency, characterized in that: The method comprises: Initialize the test cases in the test plan so that the test cases are stored in the database according to a preset format; Based on the use case in the test plan in the database, construct a message corresponding to the use case, and send the message to a message queue so that the message queue sends the message to an execution node; the message includes a pre-dependency relationship of the use case, and the pre-dependency relationship is used to characterize a pre-use case on which the use case depends; Obtain the execution result of the execution node for the message, and update the database based on the execution result; the execution result is determined by the execution node based on the pre-dependency, or the pre-dependency and the pre-use case.
2. The method according to claim 1, characterized in that The initialization of the test case in the test plan so that the test case is stored in the database according to a preset format includes: Generate a test plan identifier corresponding to the test plan and a use case identifier corresponding to at least one use case in the test plan; Each of the at least one use case is stored in a database according to a preset format, wherein the preset format includes at least one item: the test plan identifier, the use case identifier, the use case execution status, the request parameters and the response result.
3. The method according to claim 2, characterized in that The obtaining the execution result of the execution node for the message, and updating the database based on the execution result, comprises: When it is determined that the use case has no predecessor use case based on the predecessor dependency relationship in the message corresponding to the use case, the execution node corresponding to the use case is made to execute the use case, a first execution state and a first execution result corresponding to the use case are obtained, and the first execution state and the first execution result are updated to a database based on the test plan identifier and the use case identifier of the use case; When it is determined that the use case has a predecessor use case based on the predecessor dependency relationship in the message corresponding to the use case, querying the use case execution status of the predecessor use case; Based on the use case execution status of the predecessor use case, obtain the second execution status and the second execution result of the use case; based on the test plan identifier and the use case identifier of the use case, update the second execution status and the second execution result to the database.
4. The method according to claim 3, characterized in that The first execution status includes success or failure; and The updating the first execution status and the first execution result into a database based on the test plan identifier and the use case identifier of the use case includes: Determine in a database a test plan that matches the test plan identifier, and determine in the test plan a use case that matches the use case identifier; The use case execution state of the use case is updated to the first execution state, and the request parameters and response results of the use case are updated to the first execution result.
5. The method according to claim 3, characterized in that: The use case execution status of the preceding use case includes one of the following: success, failure, waiting or skipping; as well as The acquiring a second execution state and a second execution result of the use case based on the use case execution state of the preceding use case, and updating the second execution state and the second execution result to the database based on the test plan identifier and the use case identifier of the use case, comprises: When the use case execution status of the preceding use case is successful, the execution node is caused to execute the use case, and a second execution status and a second execution result are determined; the second execution status includes success or failure; Determine in a database a test plan that matches the test plan identifier, and determine in the test plan a use case that matches the use case identifier; Update the use case execution status of the use case in the database to success or failure, and update the request parameters and response result of the use case to the second execution result; When the use case execution status of the preceding use case is failure or skip, causing the execution node to skip the use case, determining that the second execution status of the use case is skip, and updating the use case execution status of the use case in the database to skip; When the use case execution status of the preceding use case is waiting, the message corresponding to the use case is rewritten into the message queue, the second execution status of the use case is determined to be waiting, and the use case execution status of the use case in the database is updated to waiting.
6. The method according to any one of claims 4-5, characterized in that: The method further comprises: Based on the test plan identifier, traverse the corresponding test plan in the database, and determine whether there is a target use case with a use case execution status of waiting in at least one use case in the test plan; When the target use case exists, executing the target use case until the use case execution status of the target use case is updated to success or failure; When there are no remaining use cases, the request parameters and response results corresponding to each use case in the at least one use case in the database are obtained.
7. The method according to any one of claims 1, characterized in that The message includes at least one of the following: use case name, use case identifier, pre-dependency, request interface, and request interface parameters.
8. A use case execution system, characterized in that: The use case execution system includes a master control node, a database and a message queue, wherein: The master control node is used to initialize the test cases in the test plan so that the test cases are stored in the database according to a preset format; The master control node is used to construct a message corresponding to the use case based on the use case in the test plan in the database, and send the message to the message queue; the message includes a pre-dependency relationship of the use case, and the pre-dependency relationship is used to characterize the pre-use case on which the use case depends; The message queue is used to send the message to the execution node; The master control node is used to obtain the execution result of the execution node for the message, and update the database based on the execution result; the execution result is determined by the execution node based on the prerequisite dependency, or the prerequisite dependency and the prerequisite use case.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the distributed use case execution method based on use case dependency described in claims 1-7.
10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the distributed use case execution method based on use case dependency as described in any one of claims 1 to 7.