Test execution method and apparatus, storage medium, and electronic device
By searching for target scenario test conditions in the test scenario condition cache pool and dynamically matching the mutated nodes of the target call chain, the problem of low test execution efficiency in existing technologies is solved, and efficient test execution is achieved.
Patent Information
- Application Number
- CN202210648692.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-09
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-06-09
AI Technical Summary
In existing technologies, constructing test scenarios requires modifying the call address of the project under test and deploying it to an external MockServer, resulting in low efficiency in the test execution process.
By searching for the target scenario test conditions in the test scenario condition cache pool, dynamically matching the mutated nodes of the target call chain, and executing the test operations after the changed operation configuration, the switching of the call address of the tested scenario is avoided.
It improves the efficiency of the test execution process, can dynamically match scenario test conditions in complex and ever-changing test scenarios, reduces the reliance on external fake service interfaces, and improves test efficiency.
Smart Images

Figure CN115048294B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a test execution method and device, a storage medium, and an electronic device. Background Art
[0002] In the process of application development, testing is an important link, and the construction of test scenarios is an important part of the testing process. In the prior art, the traditional way to construct test scenarios is to provide an independent MockServer service externally, forge a service interface with the same protocol, and switch the call address of the system under test to the MockServer. The service interface in the MockServer can be specified to return a fixed forged value. However, the traditional MockServer service construction of test scenarios has at least the following problems: connecting to the external MockServer requires modifying the call address of the project under test and resubmitting the code to deploy the test environment. The entire switching process is complicated and time-consuming, making the test execution process less efficient.
[0003] That is, in the test execution method provided in the related art, since the calling address of the project under test needs to be modified according to the external MockServer during the test process, the test execution process is less efficient.
[0004] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0005] The embodiments of the present application provide a test execution method and apparatus, a storage medium, and an electronic device to at least solve the technical problem of low efficiency in the test execution process.
[0006] According to one aspect of an embodiment of the present application, a test execution method is provided, including: receiving a data test request, wherein the data test request is used to request execution of a test operation indicated by each node on a target call chain, and the data test request includes a data test request message; in response to the data test request, searching a test scenario condition cache pool for a target scenario test condition corresponding to a target scenario where the target call chain is located, wherein the test scenario condition cache pool is used to store scenario test conditions corresponding to a test scenario where a reference call chain containing a variant node is located, and the test operation indicated by the variant node has been changed in operation configuration based on the scenario characteristics of the test scenario; when the target scenario test condition is found in the test scenario condition cache pool, executing the test operation with the changed operation configuration on the variant node of the target call chain according to the target scenario test condition.
[0007] According to another aspect of an embodiment of the present application, a test execution device is also provided, including: a receiving unit, used to receive a data test request, wherein the above-mentioned data test request is used to request the execution of the test operation indicated by each node on the target call chain, and the above-mentioned data test request includes a data test request message; a search unit, used to respond to the above-mentioned data test request, and search for the target scenario test condition corresponding to the target scenario where the above-mentioned target call chain is located in the test scenario condition cache pool, wherein the above-mentioned test scenario condition cache pool is used to store the scenario test condition corresponding to the test scenario where the reference call chain containing the mutation node is located, and the test operation indicated by the above-mentioned mutation node has been changed in operation configuration based on the scenario characteristics of the above-mentioned test scenario; an execution unit, used to execute the test operation with the changed operation configuration on the mutation node of the above-mentioned target call chain according to the above-mentioned target scenario test condition when the above-mentioned target scenario test condition is found in the above-mentioned test scenario condition cache pool.
[0008] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned test execution method when running.
[0009] According to another aspect of an embodiment of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the test execution method described above.
[0010] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the test execution method through the computer program.
[0011] In an embodiment of the present application, after receiving a data test request, in response to the data test request, a target scenario test condition corresponding to the target scenario where the target call chain is located is searched in the test scenario condition cache pool, wherein the test scenario condition cache pool is used to store the scenario test condition corresponding to the test scenario where the reference call chain containing the variant node is located, and the test operation indicated by the variant node has been changed based on the scenario characteristics of the test scenario. When the target scenario test condition is found in the test scenario condition cache pool, the test operation after the changed operation configuration is executed on the variant node of the target call chain according to the target scenario test condition. In the above method, when the target scenario test condition is found in the test scenario condition cache pool, the test operation after the changed operation configuration is executed on the variant node of the target call chain according to the target scenario test condition. Thus, during the execution of the test, when it is necessary to test complex and changeable scenarios, when the target scenario test condition matching the target call chain is found, the test operation after the changed operation configuration is executed based on the scenario characteristics of the test scenario. It is no longer limited to forging a service interface of the same protocol externally and then switching the call address of the tested scenario to the address of the external service interface. Dynamically matching scenario test conditions to target scenarios without modifying the call address of the tested scenario based on the switching of the tested scenario improves the efficiency of the test execution process and solves the technical problem of low test execution efficiency in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0013] Figure 1 is a schematic diagram of an application environment of an optional test execution method according to an embodiment of the present application;
[0014] Figure 2 is a flowchart of an optional test execution method according to an embodiment of the present invention;
[0015] Figure 3 is a flowchart of another optional test execution method according to an embodiment of the present invention;
[0016] Figure 4 is a schematic diagram of an optional test execution method according to an embodiment of the present invention;
[0017] Figure 5 is a schematic diagram of another optional test execution method according to an embodiment of the present invention;
[0018] Figure 6is a schematic diagram of another optional test execution method according to an embodiment of the present invention;
[0019] Figure 7 is a schematic diagram of another optional test execution method according to an embodiment of the present invention;
[0020] Figure 8 is a schematic diagram of another optional test execution method according to an embodiment of the present invention;
[0021] Figure 9 is a schematic diagram of another optional test execution method according to an embodiment of the present invention;
[0022] Figure 10 is a schematic diagram of another optional test execution method according to an embodiment of the present invention;
[0023] Figure 11 is a schematic diagram of another optional test execution method according to an embodiment of the present invention;
[0024] Figure 12 is an architectural diagram of an optional test execution method according to an embodiment of the present invention;
[0025] Figure 13 is a schematic structural diagram of an optional test execution device according to an embodiment of the present application;
[0026] Figure 14 It is a schematic structural diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following interpretations:
[0030] Bytecode enhancement: After Java code is compiled, it generates fixed-format bytecode (.class files) for use by the JVM. Bytecode enhancement essentially involves instrumenting the bytecode at compile time or runtime to influence the program's execution behavior at runtime.
[0031] According to one aspect of the embodiments of the present application, a test execution method is provided. Optionally, as an optional implementation, the test execution method can be applied to, but is not limited to, Figure 1 Test execution system in the environment shown.
[0032] The test execution system may include, but is not limited to, a terminal device 102, a network 104, a server 106, and a database 108. The terminal device 102 runs a target client. The terminal device 102 includes a human-computer interaction screen, a processor, and memory. The human-computer interaction screen is used to display data test requests and test results; it also provides a human-computer interaction interface for receiving human-computer interaction operations. The processor is used to generate interaction instructions in response to the human-computer interaction operations and send the interaction instructions to the server. The memory is used to store relevant data, such as individual data test requests and test results for each data test request.
[0033] In addition, the server 106 includes a processing engine, which is used to perform storage or reading operations on the database 108. Specifically, the processing engine reads the scenario test conditions corresponding to the test scenario where the reference call chain containing the mutation node is located, which are stored in the test scenario condition cache pool, from the database 108, to find the target scenario test conditions corresponding to the target scenario where the target call chain is located. When the target scenario test conditions are found in the test scenario condition cache pool, the test operation with the changed operation configuration is performed on the mutation node of the target call chain according to the target scenario test conditions. The execution result of the test operation is then returned to the terminal device 102, thereby displaying the execution result of the test operation in the terminal device 102, for example, the test passed. Then, the server 106 will also obtain the acquisition result of the execution result of the test operation returned by the terminal device and store it in the database 108.
[0034] Optionally, in this embodiment, the terminal device may be a terminal device configured with a target client, which may include but is not limited to at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, a MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc. The target client may be a video client, an instant messaging client, a browser client, an education client, etc. The network may include but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network and a wide area network, and the wireless network includes: Bluetooth, WIFI and other networks that realize wireless communication. The server may be a single server, or a server cluster consisting of multiple servers, or a cloud server.
[0035] The specific process includes the following steps: In step S100, a data test request is received, wherein the data test request is used to request the execution of test operations indicated by each node in the target call chain, and the data test request includes a data test request message. Then, in step S102, the data test request is sent to server 106 via network 104. Steps S104 to S106 are executed on server 106: In response to the data test request, a target scenario test condition corresponding to the target scenario of the target call chain is searched in a test scenario condition cache pool. The test scenario condition cache pool is used to store scenario test conditions corresponding to the test scenario of the reference call chain containing a variant node, wherein the test operation indicated by the variant node has been modified based on the scenario characteristics of the test scenario; if the target scenario test condition is found in the test scenario condition cache pool, the modified test operation is executed on the variant node of the target call chain according to the target scenario test condition. Then, in step S108, the execution result of the test operation is sent to terminal device 102 via network 104. Furthermore, the terminal device 102 sends the acquired result of the execution result of the test operation to the server 106 via the network 104 to be stored in the database 108. The above is only an example and is not limited in this embodiment.
[0036] It should be noted that in this embodiment, after receiving a data test request, in response to the data test request, a target scenario test condition corresponding to the target scenario in the target call chain is searched in the test scenario condition cache pool, wherein the test scenario condition cache pool is used to store the scenario test conditions corresponding to the test scenario in the reference call chain containing the variant node, and the test operation indicated by the variant node has been modified based on the scenario characteristics of the test scenario. When the target scenario test condition is found in the test scenario condition cache pool, the test operation with the modified operation configuration is executed on the variant node of the target call chain according to the target scenario test condition. In the above method, when the target scenario test condition is found in the test scenario condition cache pool, the test operation with the modified operation configuration is executed on the variant node of the target call chain according to the target scenario test condition. Thus, during the test execution process, when it is necessary to test complex and changeable scenarios, when the target scenario test condition matching the target call chain is found, the test operation with the modified operation configuration is executed based on the scenario characteristics of the test scenario. This is no longer limited to forging a service interface of the same protocol externally and then switching the call address of the tested scenario to the address of the external service interface. Dynamically matching scenario test conditions to target scenarios without modifying the call address of the tested scenario based on the switching of the tested scenario improves the efficiency of the test execution process and solves the technical problem of low test execution efficiency in related technologies.
[0037] Alternatively, as an optional implementation, Figure 2 As shown, the above test execution method includes:
[0038] S202, receiving a data test request, wherein the data test request is used to request execution of a test operation indicated by each node on the target call chain, and the data test request includes a data test request message;
[0039] Optionally, in this embodiment, the data test request may be, but is not limited to, an HTTP request. The data test request message may be, but is not limited to, an HTTP request message. The HTTP request message may include, but is not limited to, a request line, a request header, and a request body corresponding to the HTTP request. The data test request may, but is not limited to, call multiple nodes. Each node in the target call chain may include, but is not limited to, a root node or an intermediate node in the target call chain.
[0040] S204: In response to the data test request, searching a test scenario condition cache pool for a target scenario test condition corresponding to the target scenario where the target call chain is located, wherein the test scenario condition cache pool is used to store scenario test conditions corresponding to the test scenario where the reference call chain containing the mutation node is located, and the test operation indicated by the mutation node has its operation configuration changed based on the scenario characteristics of the test scenario;
[0041] Optionally, in an embodiment of the present application, the above-mentioned test scenario condition cache pool may be, but is not limited to, obtained through HTTP communication. The above-mentioned reference call chain may be, but is not limited to, obtained by recording the node information of the executed use case. The above-mentioned test scenario condition cache pool may be, but is not limited to, storing a number of scenario test conditions or rules corresponding to the test scenario where the reference call chain is located. The above-mentioned method of searching the test scenario condition cache pool for the target scenario test condition corresponding to the target scenario where the target call chain is located may include, but is not limited to: determining whether the target scenario test condition corresponding to the target scenario is found in the test scenario condition cache pool based on whether the URL of the data test request meets a certain condition or whether the parameters of the communication protocol corresponding to the data test request meet a certain regularity. The root node contained in the above-mentioned target call chain may be, but is not limited to, corresponding to the external protocol layer of the data test request. The intermediate node contained in the above-mentioned target call chain may be, but is not limited to, calling the corresponding method.
[0042] S206, when the target scenario test condition is found in the test scenario condition cache pool, the test operation with the changed operation configuration is executed on the mutated node of the target call chain according to the target scenario test condition;
[0043] Optionally, in this embodiment, the target scenario test condition may be, but is not limited to, configured on the platform web page. The target scenario test condition may be, but is not limited to, instructing how to call a corresponding processor to tamper with the mutated node.
[0044] It should be noted that, in this embodiment, the data test request is taken as an HTTP request, the test scenario condition cache pool is taken as an example of a scenario rule pool, and the processing subject of the data test request is taken as an example of a JAVAAgent end.
[0045] Combine Figure 3 As shown, the test execution process is specifically described: after receiving the HTTP request, as shown in step S302, the main call of the HTTP request starts. Then, as shown in step S304, the JAVA Agent side will traverse the scenario rule pool, and traverse the scenario test conditions corresponding to the test scenario where the reference call chain containing the mutation node is located in the scenario rule pool. As shown in step S306, it is checked whether the received HTTP request meets a certain scenario test condition stored in the scenario rule pool, that is, it is determined whether the scenario where the call chain corresponding to the HTTP request is located is a fission scenario. For example, according to whether the parameters of the HTTP protocol indicated by the request line in the HTTP request message contained in the HTTP request meet a certain regularity, it is determined whether the scenario where the call chain corresponding to the HTTP request is located is a fission scenario. If it is not a fission scenario, as shown in step S320, the main call of the HTTP request ends. If it is a fission scenario, as shown in step S308, the complete rule is read, that is, the target scenario test condition corresponding to the scenario where the call chain corresponding to the HTTP request is located is read, that is, the scenario test condition corresponding to the HTTP request is read. Next, as shown in step S310, the rule context is initialized, that is, the scenario test condition context is initialized. Then, as shown in step S312, node invocation begins for each intermediate node called by the HTTP request. As shown in step S314, a determination is first made as to whether the current intermediate node is a variant node. If not, the node invocation ends as shown in step S318. If it is a variant node, the relevant node mutation processing is performed as shown in step S316. That is, the corresponding processor is called based on the mutation method corresponding to the current intermediate node to modify the node method. After the node method is modified, the current intermediate node invocation ends as shown in step S318. Then, the process is looped for one or more subsequent intermediate nodes until the main invocation ends as shown in step S320. A web platform can also be provided to testers for visual operation and interaction. Project access requires registration on the platform and installation of the platform-provided JAVA Agent on the server where the test data under test is requested.
[0046] above Figure 3 This is an optional example. The embodiment of the present application does not impose any restrictions on the type of data test request involved in the test execution method, the method of obtaining the reference call chain containing the mutation node, etc.
[0047] Through the embodiment provided by the present application, in the above method, after receiving a data test request, in response to the data test request, the target scenario test condition corresponding to the target scenario where the target call chain is located is searched in the test scenario condition cache pool, wherein the test scenario condition cache pool is used to store the scenario test condition corresponding to the test scenario where the reference call chain containing the mutation node is located, and the test operation indicated by the mutation node has been changed based on the scenario characteristics of the test scenario. When the target scenario test condition is found in the test scenario condition cache pool, the test operation after the changed operation configuration is executed on the mutation node of the target call chain according to the target scenario test condition. In the above method, when the target scenario test condition is found in the test scenario condition cache pool, the test operation after the changed operation configuration is executed on the mutation node of the target call chain according to the target scenario test condition. Thus, during the execution of the test, when it is necessary to test complex and changeable scenarios, when the target scenario test condition matching the target call chain is found, the test operation after the changed operation configuration is executed based on the scenario characteristics of the test scenario. It is no longer limited to forging a service interface of the same protocol externally and then switching the call address of the tested scenario to the address of the external service interface. Dynamically matching scenario test conditions to target scenarios without modifying the call address of the tested scenario based on the switching of the tested scenario improves the efficiency of the test execution process and solves the technical problem of low test execution efficiency in related technologies.
[0048] As an optional solution, executing the changed test operation configuration on the mutation node of the target call chain according to the target scenario test conditions includes:
[0049] S1, take each node on the target call chain as the current node and perform the following operations respectively;
[0050] S2, when the current node is determined to be a mutated node based on the target scenario test condition, changing the operation configuration according to the mutation mode indicated by the target scenario test condition and matching the current node, and performing the test operation after the current node has been mutated;
[0051] S3: When it is determined that the current node is not a mutated node based on the target scenario test condition, the original test operation of the current node is executed.
[0052] It should be noted that the above method for determining whether the current node is a variant node based on the target scenario test conditions may include, but is not limited to, determining whether the method name corresponding to the current node meets certain rules, or whether the method parameter passing meets certain rules. The above process of determining whether the current node is a variant node may be, but is not limited to, method-level identification.
[0053] For example, Figure 4 As shown in , a data test request is used to request the execution of the test operations indicated by each node on the target call chain 402. The target call chain 402 includes an entry node (root node), node A, and node B. Each node on the target call chain is used as the current node. When node A is the current node 404, if the current node 404 is determined to be a mutated node based on the target scenario test conditions, the operation configuration is changed according to the mutation method 406 that matches the current node indicated by the target scenario test conditions. In other words, the execution path of the scenario in the original test operation 408 is changed by the mutation of node A, and the test operation 410 after the execution path of node A is changed is executed. In the test operation 410 after the execution path is changed, the next node of node A is no longer node B, but node C. If the current node 404 is determined to be a non-mutated node based on the target scenario test conditions, the original test operation 408 is executed.
[0054] It's important to note that constructing test scenarios consumes a significant amount of time in software engineering project testing. Many scenarios are "high-cost" and "untestable." "High-cost" test scenarios involve long construction processes that require cross-business collaboration, as well as demanding pre-conditions and complex pre-processing. "Untestable" test scenarios include abnormal scenarios such as downstream timeouts, inaccessibility, and business errors, as well as scenarios where valid data objectively lacks in the test environment, such as ad exposure and consumption.
[0055] Through the embodiment provided by the present application, each node on the target call chain is respectively used as the current node, and the following operations are performed respectively; when the current node is determined to be a variant node based on the target scenario test condition, the operation configuration is changed in accordance with the variation method that matches the current node indicated by the target scenario test condition, and the test operation after the current node is changed in the operation configuration is executed; when the current node is determined to be not a variant node based on the target scenario test condition, the original test operation of the current node is executed. It is realized that the operation configuration is changed in accordance with the variation method that matches the current variant node indicated by the target scenario test condition, and the test operation after the current variant node is changed in the operation configuration is executed. As a result, a new test scenario is fissioned in the test scenario corresponding to the current call chain, which is also universal for complex and variable scenario test scenarios, thereby further improving the test efficiency of high-cost test scenarios.
[0056] As an optional solution, changing the operation configuration in a mutation manner that matches the current node as indicated by the target scenario test condition, and executing the test operation after the current node has the changed operation configuration includes:
[0057] S1, replace the request parameters carried in the data test request with forged parameters according to the mutation method that matches the current node;
[0058] S2, executing a test operation of the current node using forged parameters to obtain a first forged test result, wherein the first forged test result is used to indicate that the test data used in the current node test does not match the data outside the target call chain.
[0059] It should be noted that the request parameters carried in the above data test request may include but are not limited to the HTTP protocol version, request header, message body, and status line of the HTTP request. Figure 5 As shown in the example, before a node executes, the request parameters are tampered with and replaced. However, this replacement does not affect the node's subsequent normal execution. If it is an external node, a real call to the external dependency will still be made. This mutation capability is primarily used when the data of the external dependency does not match the data currently being tested. After replacing the request parameters carried in the data test request with forged parameters, the test operation of the current node is continued using the forged parameters, resulting in the first forged test result, i.e., the new return.
[0060] Through the embodiments provided by this application, the request parameters carried in the data test request are replaced with forged parameters in a mutation method that matches the current node; the test operation of the current node is executed using the forged parameters to obtain a first forged test result. This allows the test to be executed normally by tampering with the request when the externally dependent data does not match the data currently being tested.
[0061] As an optional solution, changing the operation configuration in a mutation manner that matches the current node as indicated by the target scenario test condition, and executing the test operation after the current node has the changed operation configuration includes:
[0062] S1, forging a second forged test result obtained after the current node executes a test operation according to a mutation method that matches the current node, wherein the second forged test result is used to indicate that data outside the target call chain to be called by the current node test does not exist;
[0063] S2: Use the second forged test result as the operation result of the test operation of the current node.
[0064] It should be noted that the above-mentioned forging of the current node to perform the test operation may be, but is not limited to, not executing the node's internal logic, not calling external dependencies, but directly tampering with the test results. Figure 6 As shown in , this method initializes a fake return value upon entering a node and returns it directly. The node's internal logic is not executed, and no actual calls are made to external dependencies. This mutation capability is primarily used in testing scenarios where the required external dependency data does not exist and is difficult to construct.
[0065] Through the embodiments provided by this application, a second forged test result obtained after the current node executes a test operation is forged according to a mutation method that matches the current node; the second forged test result is used as the operation result of the test operation of the current node. Therefore, even if the required external dependent data does not exist or is difficult to construct, the normal execution of the test can be ensured by directly forging the result obtained after the node executes the test operation.
[0066] As an optional solution, changing the operation configuration in a mutation manner that matches the current node as indicated by the target scenario test condition, and executing the test operation after the current node has the changed operation configuration includes:
[0067] S1, generates the target fault at the current node according to the mutation method that matches the current node;
[0068] S2, jumps to execute the processing logic for the target fault and obtains the processing result, wherein the processing result is used to indicate that an abnormality occurs in the target scenario where the current node is located.
[0069] It should be noted that the above-mentioned forging of the current node to perform the test operation may be, but is not limited to, not executing the node's internal logic, not calling external dependencies, but directly generating the target fault at the current node, and jumping to execute the processing logic for the target fault. Figure 7 As shown in , upon entering a node, the specified exception is thrown directly, without executing the node's internal logic or making any actual calls to external dependent pages. After the exception is thrown, the application's internal exception handling logic is directly redirected, and the node itself does not return. This mutation capability is primarily used to verify difficult-to-construct exception scenarios.
[0070] Through the embodiments provided by this application, a target fault is generated at the current node according to a variation method that matches the current node; the processing logic for the target fault is then executed to obtain a processing result, where the processing result indicates that an abnormality has occurred in the target scenario where the current node is located. This allows for testing and verifying abnormal scenarios that are difficult to construct by directly jumping to the processing logic for the target fault to obtain the processing result, thereby ensuring normal test execution.
[0071] As an optional solution, before receiving the data test request, the following is also included:
[0072] S1, recording the node information of each executed use case scenario, wherein the node information includes the position relationship of each node in the call chain and the test operation indicated by each node;
[0073] S2, constructs the test scenario where the reference call chain containing the mutated node is located based on the node information;
[0074] S3, stores the scenario test conditions corresponding to the test scenario in the test scenario condition cache pool.
[0075] It should be noted that the above-mentioned method of recording the node information of each executed use case scenario can be but is not limited to OpenTracing technology. The node information of the above-mentioned executed use case scenario may include but is not limited to the information of each node and the relationship between nodes. For example: before receiving the data test request, use OpenTracing technology to cache the complete call relationship of the methods at each level of concern in the executed use case scenario, that is, the reference call chain. It can not only clearly reflect the call sequence, but also fully visualize the call relationship. After recording the information of each node on the reference call chain and the relationship between the nodes, a test scenario containing the reference call chain of the mutated node is constructed based on the node information, and the scenario test conditions corresponding to the test scenario are stored in the test scenario condition cache pool.
[0076] Through the embodiments provided in this application, the node information of each executed use case scenario is recorded; based on the node information, a test scenario containing a reference call chain containing a mutated node is constructed; and the scenario test conditions corresponding to the test scenario are stored in a test scenario condition cache pool. This allows the node information of the executed use case scenario to be recorded before intervening and mutating each node on the target call chain to generate a new test scenario. This ensures that the scenario test conditions are precisely implemented according to the scenario.
[0077] As an optional solution, the test scenarios where a reference call chain containing mutated nodes is constructed based on node information include:
[0078] S1, configure the entry node and mutation node in the reference call chain, where the entry node is used to receive data test requests;
[0079] S2, configure the mutation mode and validation conditions matched by the mutation node;
[0080] S3, based on the configured entry nodes and mutation nodes, as well as the configured mutation methods and effectiveness conditions, obtains the constructed test scenario.
[0081] It should be noted that the test scenario constructed above can be but is not limited to being constructed by a number of scenario construction rules. The following takes the construction of a scenario construction rule as an example. Figure 8 As shown in , when configuring a scenario construction rule, three main items need to be configured: the entry node and mutation node in the recorded reference call chain, and the rule's effectiveness. Specifically, when configuring a scenario construction rule, the entry node in the reference call chain, also known as the root node in the reference call chain, is configured to specify the requested interface, parameters, and other effectiveness conditions. When configuring the mutation node in the intermediate node of the reference call chain, corresponding mutation rules can be specified for the mutation node or each of the multiple mutation nodes corresponding to this scenario construction rule. These mainly include three types of mutation rules: replacing the request parameters carried in the data test request with forged parameters; forging the forged test results obtained after executing the test operation at the current node; and generating a target fault at the current node and jumping to execute the processing logic for the target fault. Configuring the effectiveness of the scenario construction rule includes: configuring the effectiveness status, that is, configuring whether the scenario construction rule is effective upon execution; and configuring the effectiveness count, that is, configuring the number of times the scenario construction rule is effective upon execution.
[0082] Specifically, for example, Figure 9 As shown in , when constructing a test scenario where a reference call chain containing a mutation node is located, the construction of a scenario construction rule is taken as an example. When constructing a scenario construction rule, it is necessary to configure the rule 902 of the entry node in the reference call chain, the rule 904 of the mutation node, and the effective condition 906 of the rule respectively. When configuring the rule 904 of the mutation node, the judgment condition of the mutation node can be set, and the mutation method of the mutation node can be configured to: generate a target fault at the current mutation node, and jump to execute the processing logic for the target fault. When the number of effective times in the effective condition 906 of this scenario construction rule is configured to 2 times, this scenario construction rule will only take effect twice in the subsequent execution process. When it is detected that the test method is executed for the third time, the test operation after the mutation node is changed in the operation configuration is not executed, but this scenario construction rule is ignored and the original test operation of the mutation node is executed.
[0083] It should be noted that during the construction of abnormal test scenarios in business testing, the configuration of scenario construction rules can be completed on the platform web page. After the scenario construction rules take effect, the Agent side will intervene in the execution of the program and forge a test scenario that meets the requirements. Figure 10As shown in , the platform's webpage allows you to view the results of test execution and the test execution status of each node during the test of a data test request. For example, when viewing the test execution status of variant node 1002, you can view the node type of variant node 1002, its interception point information, the return information of variant node 1002, and the exception information of variant node 1002.
[0084] It should be noted that if Figure 11 As shown in the figure, the platform's agent uses bytecode enhancement technology to implement a universal, dynamic, and pluggable AOP approach at runtime. Bytecode enhancement requires a custom Java agent that implements the JVM's Instrumentation interface and bytecodes loaded classes. There are two ways to attach the agent to the Java process under test: loading it at startup via startup parameters or attaching it at runtime using the JVM's attach API. Using the attach method, you can dynamically attach an agent module (jar package) to a Java process with a specified process ID.
[0085] Through the embodiments provided in this application, the entry nodes and mutation nodes in the reference call chain are configured; the mutation mode and validation conditions matched by the mutation nodes are configured; and based on the configured entry nodes and mutation nodes, the configured mutation mode and validation conditions, a constructed test scenario is obtained. By constructing a method based on the configured entry nodes and mutation nodes, the configured mutation mode and validation conditions, a constructed test scenario is obtained, which has the advantages of no code intrusion, construction at any time, precise validation of the scenario, and low interference, greatly reducing pollution to the test environment. This effectively solves the "high cost" and "untestable" scenario construction problems in software testing, significantly improving software testability and testing efficiency.
[0086] Combine Figure 12 The following diagram illustrates the architecture of the test execution platform: The test execution platform consists of two parts: the agent and the server. The agent primarily handles scenario construction request identification, node tampering and variation, and scenario construction rule parsing and caching. The platform server primarily handles the configuration, activation, and state management of test scenario rules. It should be noted that this application can utilize the agent as the primary framework for executing the test method.
[0087] above Figure 12 This is just an example and is not limited in this embodiment.
[0088] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0089] According to another aspect of the embodiment of the present application, a test execution device for implementing the above test execution method is also provided. Figure 13 As shown in , the device includes:
[0090] The receiving unit 1302 is configured to receive a data test request, wherein the data test request is used to request execution of a test operation indicated by each node on the target call chain, and the data test request includes a data test request message;
[0091] A search unit 1304 is configured to respond to a data test request and search a test scenario condition cache pool for a target scenario test condition corresponding to a target scenario in which a target call chain resides, wherein the test scenario condition cache pool is configured to store scenario test conditions corresponding to a test scenario in which a reference call chain containing a mutation node resides, wherein the test operation indicated by the mutation node has its operation configuration modified based on scenario characteristics of the test scenario;
[0092] The execution unit 1306 is configured to execute the test operation with the changed operation configuration on the mutation node of the target call chain according to the target scenario test condition when the target scenario test condition is found in the test scenario condition cache pool.
[0093] Optionally, in this embodiment, the embodiments to be implemented by the above-mentioned various unit modules can refer to the above-mentioned various method embodiments, which will not be repeated here.
[0094] According to another aspect of the embodiment of the present application, an electronic device for implementing the above test execution method is also provided. The electronic device may be Figure 14 The terminal device or server shown in FIG. This embodiment is described by taking the electronic device as an example of a server. Figure 14 As shown, the electronic device includes a memory 1402 and a processor 1404. The memory 1402 stores a computer program, and the processor 1404 is configured to execute the steps in any of the above method embodiments through the computer program.
[0095] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0096] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0097] S1, receiving a data test request, wherein the data test request is used to request execution of a test operation indicated by each node on a target call chain, and the data test request includes a data test request message;
[0098] S2, in response to the data test request, searching the test scenario condition cache pool for a target scenario test condition corresponding to the target scenario where the target call chain is located, wherein the test scenario condition cache pool is used to store the scenario test condition corresponding to the test scenario where the reference call chain containing the mutation node is located, and the test operation indicated by the mutation node has its operation configuration changed based on the scenario characteristics of the test scenario;
[0099] S3: When the target scenario test condition is found in the test scenario condition cache pool, the test operation after the changed operation configuration is executed on the mutation node of the target call chain according to the target scenario test condition.
[0100] Alternatively, those skilled in the art will appreciate that Figure 14 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 14 It does not limit the structure of the above electronic device. For example, the electronic device may also include Figure 14 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 14 Different configurations shown.
[0101] Among them, the memory 1402 can be used to store software programs and modules, such as the program instructions / modules corresponding to the test execution method and device in the embodiment of the present application. The processor 1404 executes various functional applications and data processing by running the software programs and modules stored in the memory 1402, that is, realizing the above-mentioned test execution method. The memory 1402 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1402 may further include a memory remotely located relative to the processor 1404, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1402 can be used specifically but not limited to store relevant data, such as information such as each data test request and the test results of each data test request. As an example, if Figure 14 As shown, the memory 1402 may include, but is not limited to, the receiving unit 1302, the searching unit 1304, and the executing unit 1306 in the test execution apparatus. Furthermore, it may also include, but is not limited to, other module units in the test execution apparatus, which will not be described in detail in this example.
[0102] Optionally, the transmission device 1406 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1406 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1406 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0103] In addition, the electronic device further includes: a display 1408 for displaying data test requests and test results; and a connection bus 1410 for connecting various module components in the electronic device.
[0104] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes through network communication. The nodes may form a peer-to-peer (P2P) network, and any computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0105] According to one aspect of the present application, a computer program product is provided, comprising a computer program / instructions containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication component and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions provided in the embodiments of the present application are performed.
[0106] A computer system includes a central processing unit (CPU), which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) or programs loaded from the storage unit into random access memory (RAM). The RAM also stores various programs and data required for system operation. The CPU, the read-only memory, and the RAM are connected to each other via a bus. Input / output interfaces (I / O interfaces) are also connected to the bus.
[0107] The following components are connected to the input / output interface: an input section including a keyboard, mouse, etc.; an output section including a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section including a hard disk; and a communication section including a network interface card such as a local area network card and a modem. The communication section performs communication processing via a network such as the Internet. A drive is also connected to the input / output interface as needed. Removable media such as magnetic disks, optical disks, magneto-optical disks, semiconductor memories, etc. are installed in the drive as needed so that computer programs read from them can be installed into the storage section as needed.
[0108] In particular, according to an embodiment of the present application, the processes described in the various method flow charts can be implemented as computer software programs. For example, an embodiment of the present application includes a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods shown in the flow charts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication portion, and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions defined in the system of the present application are performed.
[0109] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0110] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the test execution method provided in the various optional implementations described above.
[0111] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0112] S1, receiving a data test request, wherein the data test request is used to request execution of a test operation indicated by each node on a target call chain, and the data test request includes a data test request message;
[0113] S2, in response to the data test request, searching the test scenario condition cache pool for a target scenario test condition corresponding to the target scenario where the target call chain is located, wherein the test scenario condition cache pool is used to store the scenario test condition corresponding to the test scenario where the reference call chain containing the mutation node is located, and the test operation indicated by the mutation node has its operation configuration changed based on the scenario characteristics of the test scenario;
[0114] S3: When the target scenario test condition is found in the test scenario condition cache pool, the test operation after the changed operation configuration is executed on the mutation node of the target call chain according to the target scenario test condition.
[0115] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0116] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application.
[0117] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0118] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, and can be electrical or other forms.
[0119] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0120] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0121] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A test execution method, characterized in that: include: Based on the node information obtained from recording each executed use case scenario, a test scenario containing a reference call chain containing a mutated node is constructed, wherein the node information includes the positional relationship of each node in the call chain and the test operation indicated by each node. The test operation indicated by the mutated node has been changed based on the scenario characteristics of the test scenario; Storing the scenario test conditions corresponding to the test scenario in a test scenario condition cache pool; In response to a data test request for requesting execution of a test operation indicated by each node on a target call chain, determining, in the test scenario condition cache pool, a target scenario test condition that matches a target scenario in the target call chain, wherein the target scenario test condition is used to indicate a mutation mode for performing a change operation on a mutated node; Each node on the target call chain is taken as the current node in turn; when the current node is determined to be a variant node based on the target scenario test condition, the operation configuration is changed from multiple variant modes based on the target scenario test condition to determine a current variant mode that matches the current node; the operation configuration is changed according to the current variant mode, and the test operation of the current node after the operation configuration is changed is executed.
2. The method according to claim 1, characterized in that After sequentially setting each node on the target call chain as the current node, the method further includes: When it is determined based on the target scenario test condition that the current node is not a mutated node, an original test operation of the current node is performed.
3. The method according to claim 1, characterized in that Changing the operation configuration according to the current variation mode and performing the test operation after the operation configuration of the current node is changed includes: According to the current variation method, the request parameters carried in the data test request are replaced with forged parameters; The test operation of the current node is performed using the forged parameter to obtain a first forged test result, wherein the first forged test result is used to indicate that the test data used in the current node test does not match the data outside the target call chain.
4. The method according to claim 1, wherein Changing the operation configuration according to the current variation mode and performing the test operation after the operation configuration of the current node is changed includes: Forging a second forged test result obtained after the current node performs a test operation according to the current variation mode, wherein the second forged test result is used to indicate that data outside the target call chain to be called by the current node test does not exist; The second forged test result is used as the operation result of the test operation of the current node.
5. The method according to claim 1, wherein Changing the operation configuration according to the current variation mode and performing the test operation after the operation configuration of the current node is changed includes: Generating a target fault at the current node according to the current variation mode; Jump to execute the processing logic for the target fault and obtain a processing result, wherein the processing result is used to indicate that an abnormality occurs in the target scenario where the current node is located.
6. The method according to claim 1, characterized in that The test scenario where the reference call chain containing the mutated node is constructed based on the node information obtained by recording each executed use case scenario includes: Configuring an entry node and a mutation node in the reference call chain, wherein the entry node is used to receive the data test request; Configure the mutation mode and effectiveness conditions matched by the mutation node; Based on the configured entry node and mutation node and the configured mutation mode and effectiveness conditions, the constructed test scenario is obtained.
7. A test execution device, characterized in that: include: a search unit, configured to respond to a data test request for requesting execution of a test operation indicated by each node on a target call chain, and determine, from a test scenario condition cache pool, a target scenario test condition that matches a target scenario in the target call chain, wherein the target scenario test condition is used to indicate a mutation mode for performing a change operation on a mutated node; an execution unit, configured to sequentially use each node on the target call chain as a current node; if the current node is determined to be a variant node based on the target scenario test condition, determine a current variant mode that matches the current node from among a plurality of variant modes of changing the operation configuration based on the target scenario test condition; change the operation configuration according to the current variant mode, and execute a test operation of the current node after the operation configuration is changed; The device is also used to: construct a test scenario where a reference call chain containing a mutated node is located based on node information obtained by recording each executed use case scenario, wherein the node information includes the positional relationship of each node on the call chain and the test operation indicated by each node, and the test operation indicated by the mutated node has been changed based on the scenario characteristics of the test scenario; and store the scenario test conditions corresponding to the test scenario in the test scenario condition cache pool.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program is executed by a processor to perform the method according to any one of claims 1 to 6.
9. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 6 through the computer program.
Citation Information
Patent Citations
Quick test method and device for third-party channel and electronic equipment
CN112052172A
Page test method and device, computer equipment and storage medium
CN113722225A