Automated testing method, device, electronic device and storage medium
By receiving the running status information of the client to be tested and generating operation instructions based on the target behavior tree test cases, the problems of low flexibility and high modification cost in the prior art test cases are solved, and the flexibility and efficient update of automated testing are achieved.
Patent Information
- Application Number
- CN202210059715.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-19
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2042-01-19
AI Technical Summary
In the prior art, test cases based on game scenarios cannot effectively deal with frequent content changes, and the modification of test cases requires the construction of game project versions, resulting in low flexibility and high modification costs.
Provide an automated test method, by receiving the current running status information of the client to be tested, making operation decisions based on the target behavior tree test case, generating matching target operation instructions, independent of the client version, implementing hot updates, and improving the test case Flexibility and update efficiency.
It improves the flexibility and applicability of test cases, reduces modification costs, realizes the independence and efficient update of test cases, and adapts to the needs of complex scenarios.
Smart Images

Figure CN114398286B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automated testing technology, and in particular to an automated testing method, device, electronic device and storage medium. Background Art
[0002] Game scenes have complex contexts. Game projects also have short iteration cycles and frequent content changes, which greatly increases the difficulty of maintaining automated test cases.
[0003] In the prior art, test cases based on game scenarios cannot effectively cope with frequent content changes, and the modification of test cases needs to rely on the construction of the game project version, which makes the test cases low in flexibility and high in modification cost. Summary of the invention
[0004] The technical problem to be solved by the present application is to provide an automated testing method, device, electronic device and storage medium, which can improve the flexibility of test cases and reduce the cost of modifying test cases.
[0005] In order to solve the above technical problems, on the one hand, an automated testing method is provided, comprising:
[0006] Receiving a test trigger request sent by a client to be tested; the test trigger request includes current running status information of the client to be tested;
[0007] An operation decision is made based on a target behavior tree test case to obtain a target operation matching the current running state information; the target behavior tree test case is determined based on a target execution logic of the client to be tested, and the target execution logic matches a test target of the client to be tested;
[0008] An operation instruction including the target operation is returned to the client to be tested; the operation instruction is used to instruct the client to be tested to perform the target operation based on the current running state information to obtain a target test result corresponding to the current running state information.
[0009] On the other hand, an automated testing device is provided, comprising:
[0010] A test trigger request receiving module, used to receive a test trigger request sent by a client to be tested; the test trigger request includes current running status information of the client to be tested;
[0011] A target operation determination module, configured to make an operation decision based on a target behavior tree test case to obtain a target operation matching the current running state information; the target behavior tree test case is determined based on a target execution logic of the client to be tested, and the target execution logic matches a test target of the client to be tested;
[0012] The operation instruction returning module is used to return the operation instruction containing the target operation to the client under test; the operation instruction is used to instruct the client under test to perform the target operation based on the current running state information to obtain the target test result corresponding to the current running state information.
[0013] On the other hand, the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the automated testing method as described above.
[0014] On the other hand, the present application provides a computer storage medium, wherein the storage medium stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded by a processor and executes the above-mentioned automated testing method.
[0015] Implementing the embodiments of the present application has the following beneficial effects:
[0016] The present application receives a test trigger request sent by a client to be tested, the test trigger request includes the current running status information of the client to be tested, and then makes an operation decision based on the target behavior tree test case according to the current running status information to obtain a target operation that matches the current running status information; returns an operation instruction containing the target operation to the client to be tested; the operation instruction can be used to instruct the client to be tested to perform the target operation in the current running state to obtain a corresponding target test result. Since the target behavior tree test case is determined based on the target execution logic of the client to be tested, and the target execution logic matches the test target of the client to be tested, the target behavior tree test case can be used to test the client to be tested, and the behavior tree is an artificial intelligence component, so that the test case based on the behavior tree has strong flexibility and applicability, and can adapt to various complex scenarios; further, the target behavior tree test case is independent of the client to be tested, so that the target behavior tree test case does not need to rely on the client to be tested, and when modifying the target behavior tree test case, there is no need to repackage the client to be tested, which is convenient for testing and then development separation, thereby improving the flexibility of the target behavior tree test case, reducing the modification cost of the target behavior tree test case, improving the update efficiency of the target behavior tree test case, and realizing the update of the test case by the target behavior tree test case in a hot update manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 It is a schematic diagram of the implementation environment provided by the embodiment of the present application;
[0019] Figure 2 This is a flow chart of an automated testing method provided in an embodiment of the present application;
[0020] Figure 3 is a flow chart of a method for determining a target operation in a multi-user scenario provided by an embodiment of the present application;
[0021] Figure 4 is a flow chart of a target operation determination method provided in an embodiment of the present application;
[0022] Figure 5 is a flow chart of another target operation determination method provided in an embodiment of the present application;
[0023] Figure 6 It is a tick timing diagram in the game scene provided by an embodiment of the present application;
[0024] Figure 7 It is a flow chart of a target operation data processing method provided by an embodiment of the present application;
[0025] Figure 8 is a schematic diagram of the execution flow of the behavior tree provided in the embodiment of the present application;
[0026] Fig. 9 This is a flow chart of a method for generating an operation instruction provided in an embodiment of the present application;
[0027] Fig.10 is a flow chart of a method for generating a target behavior tree test case provided in an embodiment of the present application;
[0028] Fig.11 is a flow chart of the asynchronous branch function provided by an embodiment of the present application;
[0029] Fig.12 is a schematic diagram of an automated testing device provided in an embodiment of the present application;
[0030] Fig.13 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] To make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0032] 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 sequence. 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 an order 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 server that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] First, the relevant terms involved in the embodiments of this specification are explained as follows:
[0034] Behavior Tree: An AI component used to control decision-making behavior. Its data structure is generally a tree structure containing hierarchical nodes. It is widely used in AI implementations of various games.
[0035] Unity: It is the current mainstream game development engine, which can be cross-platform and run on Windows, Mac, iPhone, Windows Phone 8 and Android platforms.
[0036] See also Figure 1 , which shows a schematic diagram of an implementation environment provided by an embodiment of the present application, the implementation environment may include: at least one client to be tested 110 and a test execution terminal 120, and the client to be tested 110 and the test execution terminal 120 can communicate data through a network.
[0037] Specifically, the client to be tested 110 can send a test trigger request to the test execution terminal 120; when the test execution terminal 120 receives the test trigger request, it uses the target behavior tree test case to make an operation decision and obtains the target operation; then the target operation is returned to the client to be tested 110; the client to be tested 110 executes the target operation and obtains the corresponding target test result.
[0038] The client 110 to be tested can communicate with the test execution end 120 based on the browser / server mode (Browser / Server, B / S) or the client / server mode (Client / Server, C / S). The client 110 to be tested may include: physical devices of the type of smart phones, tablet computers, laptops, digital assistants, smart wearable devices, vehicle terminals, servers, etc., and may also include software running in physical devices, such as applications, etc. The operating system running on the client 110 to be tested in the embodiment of the present application may include but is not limited to Android system, IOS system, Linux, Windows, etc.
[0039] The test execution end 120 can establish a communication connection with the client to be tested 110 via wired or wireless communication. The test execution end 120 can include an independently running server, or a distributed server, or a server cluster composed of multiple servers, wherein the server can be a cloud server.
[0040] In order to solve the problems of low flexibility and high modification cost of test cases in the prior art, the present application embodiment provides an automated testing method, the execution subject of which can be the above-mentioned test execution end, see Figure 2 , the method may include:
[0041] S210. Receive a test trigger request sent by a client to be tested; the test trigger request includes current running status information of the client to be tested.
[0042] Compared with the client to be tested, the test execution end is a remote end, that is, the client to be tested and the test execution end can be different terminals; during the test process, the client to be tested initiates a test trigger request, and the test execution end calls the corresponding target behavior tree test case based on the test trigger request to make an operation decision, thereby realizing the testing work on the client to be tested through the information interaction between the client to be tested and the test execution end.
[0043] Further, the running process of the client to be tested may include multiple running nodes. When the client to be tested runs to each running node, the client to be tested will automatically trigger the generation of a corresponding test trigger request to realize the automated test of each running node. When the test trigger request is sent for the first time, the test trigger request may include the current running state information of the client to be tested, and the current running state information may include the node data information of the current execution node of the client to be tested, the current global information, etc. Taking the client to be tested of the UI (User Interface, user interface) type as an example, the node data information of the current execution node may specifically be the execution UI node data, and the current global information may be the interface data information currently involved. When the test trigger request is not sent for the first time, the test trigger request may also include the target test result corresponding to the last test trigger request, and the last target test result is sent to the test execution end together, so that the test execution end can make an operation decision based on the last target test result received, the current global information, etc., and make an operation decision based on comprehensive data information, which can improve the accuracy of the operation decision.
[0044] In addition, a toolkit SDK can be integrated into the client to be tested. The toolkit SDK can drive the client to be tested to send a test trigger request at a preset time interval through the client to be tested. Each test trigger request is equivalent to a tick, which can include multiple ticks per second. A tick can be an interaction between the client to be tested and the test execution end. The SDK can start a separate thread to interact with the remote test execution end, drive the uplink packet of the client to be tested tick, and the uplink packet refers to the protocol packet sent by the client to be tested to the test execution end in each tick, and receive the operation commands from the test execution end, and execute these operation commands in the main thread; at the same time, the execution results and subscription data are packaged in the next tick and sent to the test execution end through the uplink packet. The SDK determines whether to start driving and the driving frequency by configuration items. In the specific implementation process, the relevant driving parameters can be configured through the built-in configuration items of the project.
[0045] S220. Make an operation decision based on the target behavior tree test case to obtain a target operation that matches the current running state information; the target behavior tree test case is determined based on the target execution logic of the client to be tested, and the target execution logic matches the test target of the client to be tested.
[0046] The target behavior tree test case may include conditional judgment logic and execution logic under corresponding conditions, so that the target behavior tree test case can determine the conditions it meets based on the current state information and make corresponding operation decisions, that is, the target operation obtained matches the current running state information. The target operation can be a UI operation, a click operation, a function execution operation, etc. For example, if the current running state information is state information 1, the decision operation made by the corresponding target behavior tree test case is operation 1; if the current running state information is state information 2, the decision operation made by the corresponding target behavior tree test case is operation 2.
[0047] Different clients to be tested have different execution logics, so corresponding target behavior tree test cases can be created based on the execution logic. When creating a target behavior tree test case, based on the working principle of the behavior tree, write the case in the behavior tree editor. The main steps may include dragging nodes, filling in node parameters, linking nodes, etc., and exporting the behavior tree into a resource file for use in the test process. The test execution end integrates the behavior tree parser, which can parse the logic of the behavior tree and determine the corresponding target operation in combination with the test trigger request to instruct the client to be tested to execute.
[0048] You can also create behavior tree node types. Through the provided behavior tree editor and behavior tree components, you can add new custom node types to enrich the capabilities of the behavior tree. Behavior tree node types are divided into combination nodes, decoration nodes, behavior nodes, and conditional nodes. When creating a new node type, you need to add a new node to the editor's node list, configure the node name, type, comment, and parameters, etc., and then implement the new node's function in the behavior tree component. Currently, nodes such as basic processes, asynchronous branches, weight randomization, loops, timers, mathematics, UI operations, error handling, subtrees, string operations, robot data access, and custom interface calls have been integrated.
[0049] Node type introduction:
[0050] Composite
[0051] Used to manage and organize subnodes, and determine the remaining execution content and execution results based on the return results of the subnodes. Number of subnodes: 1-N
[0052] Node returns: Success, Failure, Error, Running
[0053] Decorator
[0054] Further modify the execution results of the child nodes. Number of child nodes: 1
[0055] Node returns: Success, Failure, Error, Running
[0056] Condition Node
[0057] Number of child nodes of the node used as the judgment condition: 0
[0058] Node returns: Success, Failure
[0059] Action
[0060] Execute the node. The life cycle can span multiple ticks. Returning Running means that the node is still executing and will continue to execute the node in the next tick. Number of child nodes: 0
[0061] The node returns: Success, Failure, Error, Running.
[0062] S230. Return an operation instruction including the target operation to the client to be tested; the operation instruction is used to instruct the client to be tested to perform the target operation based on the current running state information to obtain a target test result corresponding to the current running state information.
[0063] The test execution end can further process the target operation obtained by the decision, such as encapsulation operation, compression operation, or both encapsulation and compression operation; encapsulation operation of the target operation to obtain the corresponding operation instruction can avoid the loss of the operation data of the target operation, ensure that the client to be tested receives accurate target operation data, thereby improving the accuracy of data transmission. Compression operation of the target operation can reduce the network bandwidth resources occupied by the target operation data during network transmission, thereby improving data transmission efficiency.
[0064] In the present application, since the target behavior tree test case is determined based on the execution logic of the client to be tested, the target behavior tree test case can be used to test the client to be tested. Furthermore, the target behavior tree test case is independent of the client to be tested, so that the target behavior tree test case does not need to rely on the client to be tested, that is, the target behavior tree test case is decoupled from the client to be tested, and when modifying the target behavior tree test case, there is no need to repackage the client to be tested, which is convenient for testing and then development separation, thereby improving the flexibility of the target behavior tree test case, reducing the modification cost of the target behavior tree test case, improving the update efficiency of the target behavior tree test case, and realizing the update of the target behavior tree test case by hot update.
[0065] Furthermore, the test execution end can simultaneously receive test trigger requests sent by multiple clients to be tested, and each test trigger request can correspond to one client to be tested; the test trigger request can also include an object identifier, where the object identifier can specifically be a user identifier, which can be determined by the user account information of the client to be tested. Thus, in a multi-user collaborative scenario, the target behavior tree test case can make joint operation decisions based on the current running status information of multiple clients to be tested; please refer to Figure 3 , which shows a method for determining a target operation in a multi-user scenario, the method may include:
[0066] S310. Traverse the test triggering requests sent by each of the multiple clients to be tested.
[0067] S320. Determine an associated trigger request of the current test trigger request; the object identifier of the current test trigger request is associated with the object identifier of the associated trigger request; the associated trigger request is at least one test trigger request other than the current test trigger request among the test trigger requests sent by each of the multiple clients to be tested.
[0068] S330. Based on the target behavior tree test case, the current running status information of the current test trigger request, and the current running status information of the associated trigger request, a joint operation decision is made to obtain a target operation corresponding to the current test trigger request.
[0069] The test execution end can traverse multiple test trigger requests received at the same time, and determine the associated trigger request of each test trigger request. The association relationship between the object identifier in the current test trigger request and the object identifier of the associated trigger request can be a collaborative relationship or a competitive relationship. The object corresponding to the object identifier with an associated relationship is the associated object.
[0070] Taking the collaborative relationship as an example, the object corresponding to the current test trigger request and the object corresponding to the associated trigger request are collaborative objects participating in the same activity scene. The operation of each object may affect the operation results of other collaborative objects. Therefore, the target behavior tree test case can make a joint operation decision based on the current execution status information in the current test trigger request and the current execution status information in the associated trigger request to obtain the target operation corresponding to the current test trigger request. Therefore, after traversing each associated trigger request, the target operation corresponding to each test trigger request can be determined. The description of the competitive relationship is similar to that of the collaborative relationship, which will not be repeated here.
[0071] Furthermore, when the client to be tested sends a test trigger request to the test execution end, the test trigger request may further include an object identifier of an associated object, so that the test execution end can determine the associated trigger request based on the object identifier of the associated object in multiple test trigger requests, thereby improving the convenience and efficiency of determining the associated trigger request.
[0072] Furthermore, when the client to be tested sends a test trigger request to the test execution end, the test trigger request may further include the scene identifier of each object, so that the test execution end can determine the test trigger requests with the same scene identifier as associated trigger requests based on the scene identifiers in multiple test trigger requests.
[0073] Therefore, when making an operation decision based on the current test trigger request, the associated trigger request associated with it can be further considered. Since the operation determined based on the associated trigger request may have an impact on the operation determined based on the current test trigger request, a joint decision is made through multiple test trigger requests to obtain the target operation corresponding to each test trigger request, which can improve the accuracy of determining the target operation.
[0074] See also Figure 4 , which shows a target operation determination method, which may include:
[0075] S410. Obtain node execution cache information corresponding to the target behavior tree test case; the node execution cache information includes the first interrupt node of the last run of the target behavior tree test case; the first interrupt node is any behavior tree node in the target behavior tree test case.
[0076] S420. Execute the target behavior tree test case starting from the first interrupt node to obtain the target operation.
[0077] The node execution cache information may specifically include the context information of the target behavior tree test case during execution, and the interruption node information when the execution is interrupted. Thus, when the target behavior tree test case is continued to be executed, the environment information at the end of the last execution can be restored based on the context information of the last execution of the target behavior tree test case and the terminal node information. This time, the execution can be continued directly from the interruption node based on the environment information at the end of the last execution, without the need to re-run the behavior tree from the root node of the target behavior tree test case. This improves the execution efficiency of the target behavior tree test case while ensuring the correct operation of the target behavior tree test case.
[0078] Furthermore, in order to improve data acquisition efficiency, the test execution end may store node execution cache information of a preset number of times in the local memory, and when the node execution cache information is needed, it can be directly obtained from the local memory.
[0079] Furthermore, the test trigger request may also include a trigger sequence number, which may be generated and sent by the client to be tested. The trigger sequence number may be a self-increasing integer. For example, if the trigger sequence number carried by the last test trigger request sent is 19, then the trigger sequence number carried by the test trigger request sent this time may be 20, and the trigger sequence number carried by the next test trigger request sent may be 21, and so on. Figure 5 , which shows another target operation determination method, which may include:
[0080] S510. When the trigger sequence number of the currently received test trigger request is consistent with the trigger sequence number of the last received test trigger request, determine the previous trigger sequence number of the current trigger sequence number.
[0081] S520. Obtain node execution cache information corresponding to the previous trigger sequence number from the public cache area, and determine a second interrupt node from the node execution cache information; the second interrupt node is any behavior tree node in the target behavior tree test case.
[0082] S530. Execute the target behavior tree test case starting from the second interrupt node to obtain the target operation.
[0083] When the trigger sequence number of the currently received test trigger request is consistent with the trigger sequence number of the last received test trigger request, it indicates that packet loss may have occurred at this time. In the case of packet loss, the test execution end returns the corresponding operation instruction based on the last received test trigger request, but due to unstable network connection or failure of the client to be tested, the client to be tested did not receive the operation instruction, so the client to be tested started the retry mechanism, that is, sending the same test trigger request as the last time again, and the trigger sequence number of the test trigger request is also the same as the trigger sequence number of the last test trigger request. At this time, the previous trigger sequence number of the current trigger sequence number can be determined, and the previous trigger sequence number here can be specifically the trigger sequence number obtained by subtracting one from the current trigger sequence number.
[0084] Since the test trigger request with the last trigger sequence number has been processed, the corresponding node execution cache information can be obtained from the public cache area to restore the environment information when the test trigger request with the last trigger sequence number is executed. This time, the execution can be continued from the interrupted node directly based on the environment information at the end of the last execution, without having to re-run the behavior tree from the root node of the target behavior tree test case, thereby improving the execution efficiency of the target behavior tree test case while ensuring the correct operation of the target behavior tree test case. In addition, the accuracy and adaptability of the test results are improved through the retry mechanism. For example, the test execution end executes tick20, but the client to be tested does not receive it due to network problems. Then the next uplink packet will have a retry mechanism, and the tick sequence number will still be 20. The test execution end knows that the tick20 packet is lost, so it only needs to restore the node execution information to tick19 and execute the target behavior tree test case again.
[0085] Furthermore, the test execution end can support distributed deployment, that is, the test execution end can be a distributed cluster, which includes multiple test servers, and the same target behavior tree test cases can be deployed on each test server, thereby improving the concurrency capability of automated testing. The node execution cache information is saved in the public cache area, so that different test servers in the distributed cluster can obtain the corresponding node execution cache information from the public cache area. For details, please refer to Figure 6Taking the game scenario as an example, the distributed cluster includes tool server 1 and tool server 2, which shows the tick timing diagram in the game scenario. The public cache caches the node execution cache information and tick sequence number. When the tick sequence number in the uplink packet of the client to be tested is different from the current expectation, that is, the current expected tick sequence number = the tick sequence number in the memory + 1, if it meets the expectation, there is no need to obtain data from the public cache area. The node execution cache information can be saved in the public cache area after serialization, and deserialization processing is required when it is taken out for use. The specific implementation process may include:
[0086] 1. The game client sends a request command seq.
[0087] 2. Tool Service 1 executes the behavior tree.
[0088] 3. Cache the context of sequence seq.
[0089] 4. The game client re-requests instruction seq, and network abnormalities cause packet loss.
[0090] 5. Restore the context of sequence seq-1.
[0091] 6. Tool service 1 executes the behavior tree based on the restored context environment.
[0092] 7. Cache the context of sequence seq.
[0093] 8. The game client sends a request instruction seq+1. If tool server 1 fails or is busy, the request will be routed to tool server 2.
[0094] 9. Tool server 2 restores the context of seq.
[0095] 10. Tool server 2 executes the behavior tree based on the context of seq.
[0096] In addition, the tool server provides a heartbeat mechanism to maintain the client's connection status. Generally, a timeout may be caused by a client crash.
[0097] See also Figure 7 , which shows a target operation data processing method, which may include:
[0098] S710. During the execution of the target behavior tree test case, determine a target node in a target state.
[0099] S720. Determine the preset operation corresponding to the target node as the target operation.
[0100] S730. Cache the node execution information of the target node into a public cache area.
[0101] Cache the node execution information in a public cache so that each test server in the distributed cluster can call it; in this application, the target behavior tree test case runs on the remote test execution end, and the uplink packet of the client to be tested drives the operation of the target behavior tree. Each uplink packet triggers a tick. When the behavior node returns to the running state, it means that the current tick execution is completed. The behavior tree will save the current execution context for the next tick. At the same time, the execution steps of the behavior node are serialized and transmitted to the client to be tested, which is converted into a test interface call by the client to be tested through reflection. For example, Unity's code is written in C#, so the function name, parameters and other information can be reflected into a specific function call (UI operation is actually also a function call, but it is a function defined by the SDK); similarly, the unlua component also has the same reflection capability. In this way, there is no need to write a test interface for each client behavior, and the developed code function can be used directly to help complete the execution of the test steps. Specifically, for the execution process of the behavior tree, please refer to Figure 8 , where op instruction is the abbreviation of execution step, which contains information such as the executed instruction label, instruction parameters, and the global parameter list that needs to be subscribed. For error status, error will cause the behavior tree to fail to execute (unless an exception handling node is defined, similar to exception handling in the code); for fail status, fail will determine whether the behavior tree can continue to execute according to the processing logic of its parent node (for example, some loop nodes use fail status to terminate the loop).
[0102] Furthermore, before returning the operation instruction to the client under test, the target operation can also be processed. Fig. 9 , which shows a method for generating an operation instruction, which may include:
[0103] S910. Serialize the target operation to obtain serialized operation information.
[0104] S920. Generate the operation instruction based on the serialized operation information.
[0105] The target operation obtained based on the target behavior tree test case may not be suitable for direct network transmission, so the target operation can be serialized to obtain serialized operation information; specifically, the target operation can be serialized into jason data, and then, based on the serialized operation information, instructions for instructing the client to be tested to perform the operation are added, so that the operation instruction can be generated. When the client to be tested receives the operation instruction, it can first perform a deserialization operation, and then perform corresponding operations based on the deserialized operation data. When transmitting data, the target operation data is first serialized to make the processed data suitable for network transmission, thereby improving the data transmission efficiency.
[0106] In order to further improve the flexibility and robustness of behavior tree test cases, the asynchronous branching function of behavior tree test cases can be implemented. For the method of generating target behavior tree test cases, please refer to Fig.10 , the method may include:
[0107] S1010. Pre-create multiple test subtrees corresponding to multiple test functions.
[0108] S1020. Based on the test target of the client to be tested, select a target subtree from the multiple test subtrees.
[0109] S1030. Generate the target behavior tree test case based on the target subtree.
[0110] Different test subtrees can realize different functions. Test subtrees with different functions can be pre-prepared. Test subtrees can be used as the minimum functional unit in the target behavior tree test case, that is, the minimum functional unit can realize a specific function. In the specific application process, the corresponding functions to be tested can be determined according to the test objectives of the client to be tested, and test subtrees with corresponding functions can be selected from multiple test subtrees. Then, the test subtrees are combined based on the implementation logic to obtain the corresponding target behavior tree test case.
[0111] The above test subtree functions can realize the asynchronous branch function of the behavior tree. The asynchronous branch function is similar to the coroutine mechanism, which provides the ability to handle transactions in multiple threads in the behavior tree. When the behavior tree executes asynchronous nodes, there will be a concept of primary and secondary branches. The secondary branch can trigger the conditional interrupt mechanism of the main branch by modifying the blackboard value, thereby changing the execution path of the main branch. The secondary branch is generally used to monitor some abnormal conditions (using timer nodes to reduce the execution frequency), and the main branch performs core logic processing. The two work together to realize the asynchronous processing capability of the behavior tree, thereby improving the flexibility of the use case. For example, users can put the abnormal pop-up boxes in the game into the secondary branch (encapsulated with the subtree function) for processing, so that all use cases only need to reference this subtree to have consistent exception handling capabilities. With the asynchronous capability, when writing test cases, there is no need to write a long string of logic similar to ifelse. The main branch handles the main logic, and some abnormal situations (such as error pop-up boxes) are handled by the asynchronous branch, which will greatly improve flexibility. Similarly, the existence of the subtree function is like function encapsulation. Some repeated common logic does not need to be written repeatedly. Some common branches can be abstracted into subtrees and applied to all use cases. Here is an example of a shooting game: if you want to implement a scene where a character keeps shooting, and continues shooting after reloading after the bullets are used up, then you can put the continuous shooting in the main branch and use a state to control the switch, and use asynchronous branch A to determine the number of bullets, turn off the shooting switch, and execute the reload; the advantage of this is that when a new requirement is added: when the character has no blood, use the blood pack and then shoot, you can directly use the new asynchronous branch B to handle it. Branches A and B do not interfere with each other, and there is no need to modify the use case of the main branch. For the flowchart of the asynchronous branch function, please refer to Fig.11 .
[0112] Furthermore, it is possible to implement highly reusable subtree functions. Specifically, it allows the behavior tree to establish its own data private domain, and the subtree can access its own local variables. At the same time, the subtree has the function of passing parameters, both of which improve the reusability of the subtree.
[0113] In addition, the embodiment of the present application provides a rich UI node fuzzy matching capability (path front and middle suffix, rule-compliant traversal, UI text content matching, etc.), which can customize rules according to its own needs, effectively reducing the use case maintenance cost caused by the game UI change. Specifically, through some similar wildcards, loop processing sub-nodes and other capabilities to help developers write more flexible use cases, such as a page with 5 buttons, you need to click them one by one, originally need to obtain 5 button paths and click 5 times, after optimization, directly click all its button sub-nodes. In addition, positioning UI by fuzzy path (wildcard) is also a very important function, which helps to deal with the situation where UI path changes frequently. For example, the UI node data originally uploaded from the client to be tested needs to use the absolute path of the UI node. Through fuzzy matching, it is possible to use relative paths to locate UI nodes, or locate UI nodes according to the text content of the UI, or the ability to batch operate UI nodes, etc.; because the UI node path is often changed, so when writing test cases, the method of UI node fuzzy matching is adopted, and the use of relative paths or text content to locate UI nodes can avoid modifying the test cases every time the UI node path changes, which can improve the robustness of the test cases.
[0114] This application effectively solves the hot update problem of test cases by adopting a remote control test method, so that the update of test cases is decoupled from the client; the target behavior tree test case has node concurrency capability, which is more suitable for automation scenarios with complex contexts such as games (such as abnormal interruptions, multi-terminal collaboration, conditional interruptions, etc.); the tick frequency depends on the frequency of the client's uplink packet, so that the frequency of the uplink packet can be flexibly adjusted according to the server resource situation to avoid waste of server resources.
[0115] This embodiment also provides an automated testing device. Fig.12 , the device may include:
[0116] The test trigger request receiving module 1210 is used to receive a test trigger request sent by a client to be tested; the test trigger request includes the current running status information of the client to be tested;
[0117] A target operation determination module 1220 is used to make an operation decision based on a target behavior tree test case to obtain a target operation that matches the current running state information; the target behavior tree test case is determined based on the target execution logic of the client to be tested, and the target execution logic matches the test target of the client to be tested;
[0118] The operation instruction returning module 1230 is used to return the operation instruction containing the target operation to the client under test; the operation instruction is used to instruct the client under test to perform the target operation based on the current running state information to obtain the target test result corresponding to the current running state information.
[0119] Furthermore, the test trigger request is a test trigger request sent by each of the multiple clients to be tested; the test trigger request sent by each of the multiple clients to be tested also carries an object identifier;
[0120] The target operation determination module 1220 includes:
[0121] A traversal module, used for traversing the test triggering requests respectively sent by the plurality of clients to be tested;
[0122] An associated trigger request determination module, used to determine an associated trigger request of a current test trigger request; the object identifier of the current test trigger request has an associated relationship with the object identifier of the associated trigger request; the associated trigger request is at least one test trigger request other than the current test trigger request among the test trigger requests respectively sent by the multiple clients to be tested;
[0123] A joint decision module is used to make a joint operation decision based on the target behavior tree test case, the current running status information of the current test trigger request, and the current running status information of the associated trigger request to obtain a target operation corresponding to the current test trigger request.
[0124] Furthermore, the device also includes:
[0125] A first acquisition module is used to acquire node execution cache information corresponding to the target behavior tree test case; the node execution cache information includes the first interrupt node of the last execution of the target behavior tree test case; the first interrupt node is any behavior tree node in the target behavior tree test case;
[0126] The target operation determination module 1220 includes:
[0127] The first execution module is used to execute the target behavior tree test case starting from the first interrupt node to obtain the target operation.
[0128] Further, the test trigger request includes a trigger sequence number;
[0129] The device also includes:
[0130] A first determining module, configured to determine a previous trigger sequence number of the current trigger sequence number when the trigger sequence number of the currently received test trigger request is consistent with the trigger sequence number of the last received test trigger request;
[0131] A second acquisition module is used to acquire node execution cache information corresponding to the previous trigger sequence number from a public cache area, and determine a second interrupt node from the node execution cache information; the second interrupt node is any behavior tree node in the target behavior tree test case;
[0132] The target operation determination module 1220 includes:
[0133] The second execution module is used to execute the target behavior tree test case starting from the second interrupt node to obtain the target operation.
[0134] Further, the target operation determination module 1220 includes:
[0135] A target node determination module, used to determine a target node in a target state during execution of the target behavior tree test case;
[0136] A second determining module, configured to determine a preset operation corresponding to the target node as the target operation;
[0137] The device also includes:
[0138] The information cache module is used to cache the node execution information of the target node into a public cache area.
[0139] Furthermore, the device also includes:
[0140] A serialization processing module, used for performing serialization processing on the target operation to obtain serialization operation information;
[0141] An operation instruction generating module is used to generate the operation instruction based on the serialized operation information.
[0142] Furthermore, the device also includes:
[0143] A test subtree creation module, used to pre-create multiple test subtrees corresponding to multiple test functions;
[0144] A target subtree selection module, configured to select a target subtree from the plurality of test subtrees based on a test target of the client to be tested;
[0145] A use case generation module is used to generate the target behavior tree test case based on the target subtree.
[0146] The device provided in the above embodiment can execute the method provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects of executing the method. For technical details not described in detail in the above embodiment, please refer to the method provided in any embodiment of the present application.
[0147] This embodiment further provides a computer-readable storage medium, in which at least one instruction or at least one program is stored. The at least one instruction or the at least one program is loaded by a processor and executed as any of the above methods of this embodiment.
[0148] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. 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 performs any of the above methods.
[0149] This embodiment also provides an electronic device, whose structure diagram is shown in FIG. Fig.13 The device 1300 may vary greatly due to different configurations or performances, and may include one or more central processing units (CPU) 1322 (e.g., one or more processors) and memory 1332, one or more storage media 1330 (e.g., one or more mass storage devices) storing application programs 1342 or data 1344. Among them, the memory 1332 and the storage medium 1330 may be short-term storage or persistent storage. The program stored in the storage medium 1330 may include one or more modules (not shown in the figure), each module may include a series of instruction operations on the device. Furthermore, the central processing unit 1322 may be configured to communicate with the storage medium 1330 and execute a series of instruction operations in the storage medium 1330 on the device 1300. The device 1300 may also include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input and output interfaces 1358, and / or, one or more operating systems 1341, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM Etc. Any of the above methods in this embodiment can be based on Fig.13 The device shown is implemented.
[0150] This specification provides method operation steps as described in the embodiments or flow charts, but more or fewer operation steps may be included based on conventional or non-creative labor. The steps and sequence listed in the embodiments are only one way of executing the sequence of many steps and do not represent the only execution sequence. When the actual system or interrupt product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, in a parallel processor or multi-threaded processing environment).
[0151] The structure shown in this embodiment is only a partial structure related to the scheme of the present application, and does not constitute a limitation on the device to which the scheme of the present application is applied. The specific device may include more or fewer components than shown, or combine certain components, or have different arrangements of components. It should be understood that the method, device, etc. disclosed in this embodiment can be implemented in other ways. For example, the device embodiment described above is only schematic. For example, the division of the modules is only a division of a logical function. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or unit modules.
[0152] Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the whole 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 a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., various media that can store program codes.
[0153] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0154] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An automated testing method, characterized in that: include: Receive a test trigger request sent by the client to be tested; The test trigger request includes the current running status information of the client to be tested; The test trigger request is a test trigger request sent by each of the multiple clients to be tested; The test triggering request sent by each of the multiple clients to be tested also carries an object identifier; An operation decision is made based on a target behavior tree test case to obtain a target operation matching the current running state information; the target behavior tree test case is determined based on a target execution logic of the client to be tested, and the target execution logic matches a test target of the client to be tested; The operation decision is made based on the target behavior tree test case to obtain the target operation matching the current running state information, including: traversing the test trigger requests sent by each of the multiple clients to be tested; determining the associated trigger request of the current test trigger request; the object identifier of the current test trigger request is associated with the object identifier of the associated trigger request; the associated trigger request is at least one test trigger request other than the current test trigger request among the test trigger requests sent by each of the multiple clients to be tested; based on the target behavior tree test case, the current running state information of the current test trigger request, and the current running state information of the associated trigger request, a joint operation decision is made to obtain the target operation corresponding to the current test trigger request; An operation instruction including the target operation is returned to the client to be tested; the operation instruction is used to instruct the client to be tested to perform the target operation based on the current running state information to obtain a target test result corresponding to the current running state information.
2. The method according to claim 1, characterized in that: The step of making an operation decision based on the target behavior tree test case to obtain a target operation matching the current running state information further includes: Obtain node execution cache information corresponding to the target behavior tree test case; the node execution cache information includes the first interrupt node of the last run of the target behavior tree test case; the first interrupt node is any behavior tree node in the target behavior tree test case; The making an operation decision based on the target behavior tree test case to obtain a target operation matching the current running state information includes: The target behavior tree test case is executed starting from the first interrupt node to obtain the target operation.
3. The method according to claim 1, characterized in that The test trigger request includes a trigger sequence number; The method further comprises: When the trigger sequence number of the currently received test trigger request is consistent with the trigger sequence number of the last received test trigger request, determining the previous trigger sequence number of the current trigger sequence number; Acquire node execution cache information corresponding to the previous trigger sequence number from a public cache area, and determine a second interrupt node from the node execution cache information; the second interrupt node is any behavior tree node in the target behavior tree test case; The making an operation decision based on the target behavior tree test case to obtain a target operation matching the current running state information includes: The target behavior tree test case is executed starting from the second interrupt node to obtain the target operation.
4. The method according to claim 1, characterized in that: The target behavior tree test case performs an operation decision to obtain a target operation matching the current running state information, including: During execution of the target behavior tree test case, determining a target node in a target state; Determine a preset operation corresponding to the target node as the target operation; The target behavior tree test case performs an operation decision to obtain a target operation matching the current running state information, and then further includes: The node execution information of the target node is cached in a public cache area.
5. The method according to claim 1, characterized in that The step of returning the operation instruction including the target operation to the client to be tested further comprises: Performing serialization processing on the target operation to obtain serialization operation information; Based on the serialized operation information, the operation instruction is generated.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Pre-create multiple test subtrees corresponding to multiple test functions; Based on the test target of the client to be tested, selecting a target subtree from the multiple test subtrees; The target behavior tree test case is generated based on the target subtree.
7. An automated testing device, characterized in that: include: A test trigger request receiving module is used to receive a test trigger request sent by a client to be tested; The test trigger request includes the current running status information of the client to be tested; The test trigger request is a test trigger request sent by each of the multiple clients to be tested; The test triggering request sent by each of the multiple clients to be tested also carries an object identifier; A target operation determination module, configured to make an operation decision based on a target behavior tree test case to obtain a target operation matching the current running state information; the target behavior tree test case is determined based on a target execution logic of the client to be tested, and the target execution logic matches a test target of the client to be tested; The target operation determination module includes: a traversal module, which is used to traverse the test trigger requests sent by each of the multiple clients to be tested; an associated trigger request determination module, which is used to determine the associated trigger request of the current test trigger request; the object identifier of the current test trigger request is associated with the object identifier of the associated trigger request; the associated trigger request is at least one test trigger request other than the current test trigger request among the test trigger requests sent by each of the multiple clients to be tested; a joint decision module, which is used to make a joint operation decision based on the target behavior tree test case, the current running status information of the current test trigger request, and the current running status information of the associated trigger request to obtain the target operation corresponding to the current test trigger request; The operation instruction returning module is used to return the operation instruction containing the target operation to the client under test; the operation instruction is used to instruct the client under test to perform the target operation based on the current running state information to obtain the target test result corresponding to the current running state information.
8. The device according to claim 7, characterized in that The device also includes: A first acquisition module is used to acquire node execution cache information corresponding to the target behavior tree test case; the node execution cache information includes the first interrupt node of the last execution of the target behavior tree test case; the first interrupt node is any behavior tree node in the target behavior tree test case; The target operation determination module comprises: The first execution module is used to execute the target behavior tree test case starting from the first interrupt node to obtain the target operation.
9. The device according to claim 7, characterized in that The test trigger request includes a trigger sequence number; The device also includes: A first determining module, configured to determine a previous trigger sequence number of the current trigger sequence number when the trigger sequence number of the currently received test trigger request is consistent with the trigger sequence number of the last received test trigger request; A second acquisition module is used to acquire node execution cache information corresponding to the previous trigger sequence number from a public cache area, and determine a second interrupt node from the node execution cache information; the second interrupt node is any behavior tree node in the target behavior tree test case; The target operation determination module comprises: The second execution module is used to execute the target behavior tree test case starting from the second interrupt node to obtain the target operation.
10. The device according to claim 7, characterized in that The target operation determination module comprises: A target node determination module, used to determine a target node in a target state during execution of the target behavior tree test case; A second determining module, configured to determine a preset operation corresponding to the target node as the target operation; The device also includes: The information cache module is used to cache the node execution information of the target node into a public cache area.
11. The device according to claim 7, characterized in that The device also includes: A serialization processing module, used for performing serialization processing on the target operation to obtain serialization operation information; An operation instruction generating module is used to generate the operation instruction based on the serialized operation information.
12. The device according to any one of claims 7 to 11, characterized in that: The device also includes: A test subtree creation module, used to pre-create multiple test subtrees corresponding to multiple test functions; A target subtree selection module, configured to select a target subtree from the plurality of test subtrees based on a test target of the client to be tested; A use case generation module is used to generate the target behavior tree test case based on the target subtree.
13. An electronic device, characterized in that: The device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the automated testing method as described in any one of claims 1 to 6.
14. A computer storage medium, characterized in that: The storage medium stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded by the processor and executes the automated testing method according to any one of claims 1 to 6.
