Interface testing method and device based on knowledge graph
By using an interface testing method based on knowledge graphs and reinforcement learning, the interface call relationships are automatically sorted out, solving the problem that existing interface testing cannot provide full coverage and achieving efficient automated testing.
Patent Information
- Application Number
- CN202210227586.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-08
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2042-03-08
AI Technical Summary
Existing interface testing methods cannot achieve full coverage and are prone to omissions, leading to missed issues.
An interface testing method based on knowledge graphs is adopted. The interface call path is constructed through knowledge graphs, and reinforcement learning is combined to carry out automated testing, automatically sort out the call relationship, and use intelligent agents to perform test operations on the controls.
It achieves full coverage of interfaces, automates testing, reduces human error, and improves testing efficiency and accuracy.
Smart Images

Figure CN114564407B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and more specifically, to an interface testing method and apparatus based on knowledge graphs. Background Technology
[0002] Interface testing is a crucial part of the testing process. It involves simulating the sending of messages between interfaces to achieve test coverage of a specific interface's functionality. However, this method can only guarantee that the interface functions correctly for a single message type and cannot guarantee full coverage of the interface, making it prone to problems caused by oversights. Summary of the Invention
[0003] The main objective of this invention is to provide a knowledge graph-based interface testing method and apparatus to automatically sort out call relationships and perform automated testing, thereby achieving full coverage of interfaces.
[0004] To achieve the above objectives, embodiments of the present invention provide an interface testing method based on a knowledge graph, comprising:
[0005] Obtain the test interface and determine the corresponding interface test model;
[0006] Determine the business functions corresponding to the interface test model, and determine the controls based on the business functions;
[0007] The interface test results are obtained by using an agent trained based on the operation interface and response interface in the interface test model to perform test operations on the control.
[0008] In one embodiment, determining the interface test model corresponding to the test interface includes:
[0009] Determine the test path corresponding to the test interface and obtain the interface test model for the test path.
[0010] In one embodiment, it further includes:
[0011] Perform the following iterative processing:
[0012] Determine the control corresponding to the test path, and operate the control through the agent in the initial interface test model to obtain the operation interface and response interface;
[0013] The reward and penalty values are determined based on the operation interface, response interface, test path, and preset reward function;
[0014] When the current iteration count reaches the preset iteration count, the initial interface test model is determined to be the interface test model; otherwise, the agent in the initial interface test model is updated according to the reward and penalty value.
[0015] In one embodiment, determining the reward / penalty value based on the operation interface, response interface, test path, and preset reward function includes:
[0016] The response coefficient is determined based on the positional relationship between the operation interface and the response interface in the test path;
[0017] The path coefficients are determined based on the test path and the preset reward function;
[0018] The reward and penalty values are determined based on the response coefficient and the path coefficient.
[0019] In one embodiment, it further includes:
[0020] The total reward and penalty value is determined based on the reward and penalty value.
[0021] When the total reward and penalty value reaches the preset reward and penalty threshold, the initial interface test model is determined to be the interface test model; otherwise, the agent in the initial interface test model is updated according to the reward and penalty value.
[0022] In one embodiment, determining the total reward / penalty value based on the reward / penalty value includes:
[0023] The number of training steps is determined based on the response coefficient;
[0024] The penalty value is determined based on the number of training steps;
[0025] The total reward / penalty value is determined based on the penalty value and the reward / penalty value.
[0026] This invention also provides a knowledge graph-based interface testing device, comprising:
[0027] The interface test model determination module is used to obtain the test interface and determine the corresponding interface test model for the test interface.
[0028] The control determination module is used to determine the business functions corresponding to the interface test model and determine the controls based on the business functions.
[0029] The testing module is used to perform test operations on the controls using an agent trained based on the operation interface and response interface in the interface testing model, and to obtain the interface test results.
[0030] In one embodiment, the interface test model determination module is specifically used to: determine the test path corresponding to the test interface, and obtain the interface test model of the test path.
[0031] In one embodiment, it further includes:
[0032] The operation module is used to determine the controls corresponding to the test path, and to operate the controls through the agent in the initial interface test model to obtain the operation interface and response interface;
[0033] The reward and penalty value module is used to determine the reward and penalty value based on the operation interface, response interface, test path, and preset reward function;
[0034] The first iteration module is used to determine the initial interface test model as the interface test model when the current iteration number reaches the preset iteration number; otherwise, it updates the agent in the initial interface test model according to the reward and penalty value.
[0035] In one embodiment, the reward / penalty value module includes:
[0036] The response coefficient unit is used to determine the response coefficient based on the positional relationship between the operation interface and the response interface in the test path.
[0037] The path coefficient unit is used to determine the path coefficient based on the test path and the preset reward function;
[0038] The reward / penalty value unit is used to determine the reward / penalty value based on the response coefficient and path coefficient.
[0039] In one embodiment, it further includes:
[0040] The Total Reward and Penalty Value module is used to determine the total reward and penalty value based on the reward and penalty value.
[0041] The second iteration module is used to determine the initial interface test model as the interface test model when the total reward and punishment value reaches the preset reward and punishment threshold; otherwise, it updates the agent in the initial interface test model according to the reward and punishment value.
[0042] In one embodiment, the total reward / penalty value module includes:
[0043] The training step count unit is used to determine the number of training steps based on the response coefficient.
[0044] Penalty value unit, used to determine the penalty value based on the number of training steps;
[0045] The total reward / penalty value unit is used to determine the total reward / penalty value based on the penalty value and the reward / penalty value.
[0046] This invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of the knowledge graph-based interface testing method.
[0047] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the knowledge graph-based interface testing method.
[0048] This invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the knowledge graph-based interface testing method.
[0049] The knowledge graph-based interface testing method and apparatus of this invention first determines the interface testing model corresponding to the test interface, then determines the business function corresponding to the interface testing model to determine the control based on the business function, and finally performs test operations on the control through the intelligent agent trained based on the operation interface and response interface in the interface testing model to obtain the interface test results. It can automatically sort out the call relationship and perform automated testing to achieve full coverage of the interface. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is a flowchart of the knowledge graph-based interface testing method in an embodiment of the present invention;
[0052] Figure 2 This is a flowchart of an interface testing method based on knowledge graphs in another embodiment of the present invention;
[0053] Figure 3 This is a flowchart of creating an interface test model in an embodiment of the present invention;
[0054] Figure 4 This is a flowchart illustrating the determination of reward and punishment values in an embodiment of the present invention;
[0055] Figure 5 This is a flowchart for determining the total reward / penalty value in an embodiment of the present invention;
[0056] Figure 6 This is a structural block diagram of the knowledge graph-based interface testing device in an embodiment of the present invention;
[0057] Figure 7 This is a structural block diagram of an interface testing device based on a knowledge graph in another embodiment of the present invention;
[0058] Figure 8 This is a structural block diagram of the computer device in an embodiment of the present invention. Detailed Implementation
[0059] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0060] Those skilled in the art will recognize that embodiments of the present invention can be implemented as a system, apparatus, device, method, or computer program product. Therefore, this disclosure can be specifically implemented in the following forms: entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0061] Given that existing technologies cannot guarantee full coverage of interfaces, leading to potential oversights, this invention provides a knowledge graph-based interface testing method and apparatus. This method combines knowledge graphs and reinforcement learning to automatically analyze and test interface call relationships. The knowledge graph extracts structured interface call information from data such as registered call information, system logs, and application tracking points, enabling the retrieval of all related interface calls for a given interface and establishing end-to-end interface call paths. Reinforcement learning, based on these call paths, allows the model agent to automatically explore the test page randomly. The model provides rewards and penalties based on the agent's actions, ultimately maximizing rewards and penalties to train the model and enabling it to master behavioral patterns within the given call path. This achieves the goal of automatically analyzing call relationships and performing automated testing. The invention will be described in detail below with reference to the accompanying drawings.
[0062] Figure 1 This is a flowchart of an interface testing method based on knowledge graphs in an embodiment of the present invention. Figure 2 This is a flowchart of an interface testing method based on a knowledge graph, as described in another embodiment of the present invention. Figures 1-2 As shown, the interface testing methods based on knowledge graphs include:
[0063] S101: Obtain the test interface and determine the interface test model corresponding to the test interface.
[0064] In one embodiment, determining the interface test model corresponding to a test interface includes: determining the test path corresponding to the test interface and obtaining the interface test model of the test path. Multiple test paths correspond to a test interface. Each test path corresponds one-to-one with an interface test model, and each test path includes multiple interfaces. When determining the test path corresponding to a test interface, an interface call relationship knowledge graph can be extracted from structured data of registered interface call information, transaction log extraction, and event tracking. The entities in the knowledge graph are mainly interfaces, and the entity attributes include the business functions they belong to. The relationships are the call relationships between the interfaces. The test path is determined based on the call relationships between the interfaces.
[0065] S102: Determine the business function corresponding to the interface test model, and determine the controls based on the business function.
[0066] In practice, first determine the test path corresponding to the interface test model, and then determine the controls based on the business functions corresponding to the test path.
[0067] S103: The agent trained based on the operation interface and response interface in the interface testing model performs test operations on the control corresponding to the test interface to obtain the interface test results.
[0068] Figure 1 The execution entity of the knowledge graph-based interface testing method shown can be a computer. Figure 1 As shown in the process, the knowledge graph-based interface testing method of this invention first determines the interface testing model corresponding to the test interface, then determines the business function corresponding to the interface testing model to determine the control based on the business function, and finally performs test operations on the control corresponding to the test interface through the intelligent agent trained based on the operation interface and response interface in the interface testing model to obtain the interface test results. It can automatically sort out the call relationship and perform automated testing to achieve full coverage of the interface.
[0069] Figure 3 This is a flowchart illustrating the creation of an interface test model in an embodiment of the present invention. For example... Figure 3 As shown, knowledge graph-based interface testing methods also include:
[0070] Perform the following iterative processing:
[0071] S201: Determine the control corresponding to the test path, and operate the control through the agent in the initial interface test model to obtain the operation interface and response interface.
[0072] In one embodiment, the control for determining the test path includes:
[0073] Determine the business function corresponding to the test path; determine the controls for the scenario entry page based on the business function.
[0074] In practice, the intersection of the business functions of each interface in the test path can be taken as the business function corresponding to the test path, and the space in the application interface where the business function is located can be used to determine the control of the scene entry page.
[0075] For example, there are test paths such as (ABC) and (DEC), where A, B, C, D, and E are all interfaces. Each interface has business functions such as x and y, like mobile banking deposit and mobile banking query functions. Interface entities A and B possess the attribute of business function x, interface entities D and E possess the attribute of business function y, and interface entity C possesses both business functions x and y. Therefore, the business function corresponding to test path (ABC) is x, and the business function corresponding to test path (DEC) is y.
[0076] In this invention, controls refer to the environmental elements in the reinforcement learning model (interface testing model), including page control names and page control location information. When the interface testing model operates within the scene, it may jump to a new page or the current page may change, causing changes to the scene information (controls). Therefore, the controls also need to be re-collected after the interface testing model operates within the scene. The operations in this invention are mainly divided into three categories: clicking, swiping, and input.
[0077] In practice, one of the scenarios corresponding to the test path is randomly selected. The controls on the scenario's entry page are used as the environmental element inputs for the first step of the model. The agent randomly selects operations based on the extracted environmental elements, i.e., the agent performs random clicks, swipes, and inputs on the page. For example, when the aforementioned (ABC) test path is selected, its corresponding business function is x, such as the mobile banking deposit function. The initial page of the deposit function is the scenario entry page, which contains controls and control element location information. The page controls on the page are used as the environmental element inputs for the first step of the model, such as the card number input box, the amount input box, and the confirmation button.
[0078] S202: Determine the reward / penalty value based on the operation interface, response interface, test path, and preset reward function.
[0079] Figure 4 This is a flowchart illustrating the determination of reward and punishment values in an embodiment of the present invention. For example... Figure 4 As shown, the reward / penalty values are determined based on the operation interface, response interface, test path, and preset reward function, including:
[0080] S301: Determine the response coefficient based on the positional relationship between the operation interface and the response interface in the test path.
[0081] While the agent operates on the control, the background records the interface response, determines whether the response interface is in the current test path, and assigns a response coefficient accordingly. For example, if there is no interface response, the response coefficient is set to 0; if the response interface is in the current test path and follows the operation interface, the response coefficient is set to the first response value, which can be 1; if the response interface is in the current test path and precedes the operation interface, or if the response interface is not in the current test path, the response coefficient is set to the second response value, and the operation in this iteration is terminated, which can be -1; if the response interface is the target interface, the response coefficient is set to the third response value, and the operation in this iteration is terminated, which can be 10.
[0082] S302: Determine the path coefficients based on the test path and the preset reward function.
[0083] The longer the test path, the larger the path coefficient, which can be used to avoid excessive penalty values due to too many training steps, thus affecting the total reward and punishment value.
[0084] S303: Determine the reward / penalty value based on the response coefficient and path coefficient.
[0085] In practice, the reward and penalty values can be determined using the following formula:
[0086]
[0087] Where r is the reward / penalty value, F(x) is the path coefficient, F(x) = f(x), x is the test path length, f(x) is the preset reward function, and α i Let be the response coefficient of the result caused by the i-th step operation, and s be the number of training steps in this iteration.
[0088] S203: Has the current iteration count reached the preset iteration count?
[0089] S204: When the current iteration count reaches the preset iteration count, determine the initial interface test model as the interface test model.
[0090] In one embodiment, the method further includes: determining a total reward / penalty value based on the reward / penalty value; and determining an initial interface test model as an interface test model when the total reward / penalty value reaches a preset reward / penalty threshold.
[0091] Figure 5 This is a flowchart illustrating the determination of the total reward / penalty value in an embodiment of the present invention. For example... Figure 5 As shown, the total reward / penalty value is determined based on the operation interface, response interface, test path, and preset reward function, including:
[0092] S401: Determine the number of training steps based on the response coefficient.
[0093] S402: Determine the penalty value based on the number of training steps.
[0094] S403: Determine the total reward / penalty value based on the penalty value and the reward / penalty value.
[0095] The total reward / penalty value provides corresponding feedback based on the impact of the agent's chosen actions. This reward / penalty accumulates continuously during model training, and the ultimate goal of model training is to maximize this reward / penalty. Specifically, the total reward / penalty value is set as follows:
[0096] R = r + L(s);
[0097] Where R is the total reward / penalty value, r is the reward / penalty value, L(s) is the penalty value, and s is the number of training steps.
[0098] S205: When the current iteration count has not reached the preset iteration count, update the agent in the initial interface test model according to the reward and penalty value.
[0099] In one embodiment, the method further includes: when the total reward / penalty value does not reach the preset reward / penalty threshold, updating the agent in the initial interface test model according to the reward / penalty value.
[0100] Once the model is trained, it can be used as a subsequent automated test script. During testing, automated testing can be performed on all test paths involved in the interface or on specified test paths. After providing the test path entry point, selecting the corresponding interface test model will allow the agent to automatically operate the controls on the page and complete the corresponding test tasks.
[0101] The specific process of this invention embodiment is as follows:
[0102] Taking test interface A as an example, the full range of interface paths (such as CBA and FEA) are obtained by using user transaction logs and other information as the data source for constructing the interface path graph. Then, the business functions corresponding to the two paths are identified, such as mobile banking deposit function and mobile banking query function. After extracting the interface paths, reinforcement learning model training can begin. Taking the DQN (Deep Q Network) model as an example, the specific training steps are as follows:
[0103] 1. Set environment parameters. Randomly select a test path from the extracted test path list, such as the (CBA) path, and select the corresponding scenario entry page, such as the mobile banking deposit function. Extract various control information and their corresponding position information from the page, such as buttons and input boxes, as the environment parameters of the model.
[0104] 2. Define the action space that the agent can take. In this invention, actions such as clicking, swiping, and inputting are generally defined to manipulate the page. The agent in the model randomly selects actions from the defined action space and performs corresponding operations on the controls selected on the page.
[0105] 3. Calculate the total reward / penalty value based on the agent's actions and their impact. After a random action by the agent, page changes and backend API responses will occur. At this point, the total reward / penalty value corresponding to that action can be calculated using a pre-defined reward / penalty function. The aforementioned summation reward / penalty function is in the form of... The reward / penalty function (reward / penalty value) for each step is α. i F(x), where F(x) is set to x. 2 If x is the length of the test path, then F(x) is 9 during the model training process of the (CBA) path.
[0106] α i Let be the response function corresponding to the result of the i-th step operation. If there is no interface response, the response coefficient is set to 0; if the response interface is in the current test path and follows the operation interface, the response coefficient is set to 1; if the response interface is in the current test path and precedes the operation interface, or if the response interface is not in the current test path, the response coefficient is set to -1, and the operation in this iteration is terminated; if the response interface is the target interface, the response coefficient is set to 10, and the operation in this iteration is terminated. The reward / penalty value corresponding to each step operation can then be calculated. This process is repeated several times until the agent triggers the target interface, which completes one iteration. The final training objective of the model is to maximize the reward / penalty value.
[0107] 4. Once the model achieves the expected result (total reward / penalty value reaches the preset reward / penalty threshold) or after the preset number of iterations, the model training for that scenario is considered complete. After training for the (CBA) scenario, save the model and set the label to the (CBA) path. Then, perform the above model training steps for the (FEA) scenario path.
[0108] 5. Once the model training is complete, comprehensive automated testing can be performed on the interface. When testing interface A, extract all models related to interface A from the saved model repository, such as (CBA) and (FEA) models. Select one model from these models sequentially, open the initial page corresponding to the selected model, and the trained agent in the model can then operate the controls on the page based on the training results. After the (CBA) model completes training, select the (FEA) model sequentially for testing, repeating the above steps until all models have been tested.
[0109] In summary, the knowledge graph-based interface testing method of this invention constructs a complete interface call path through the knowledge graph. Starting from any interface, it can derive all the upstream entry points and paths that call that interface. Based on the obtained entry points and paths, it performs automatic reinforcement learning training, thereby achieving the effect of automatically analyzing business scenarios without relying on human intervention and realizing the writing of automated test scripts.
[0110] Based on the same inventive concept, this invention also provides an interface testing device based on a knowledge graph. Since the principle of this device in solving problems is similar to that of the interface testing method based on a knowledge graph, the implementation of this device can refer to the implementation of the method, and the repeated parts will not be described again.
[0111] Figure 6 This is a structural block diagram of the knowledge graph-based interface testing device in an embodiment of the present invention. Figure 7 This is a structural block diagram of an interface testing device based on a knowledge graph, according to another embodiment of the present invention. Figures 6-7 As shown, the knowledge graph-based interface testing device includes:
[0112] The interface test model determination module is used to obtain the test interface and determine the corresponding interface test model for the test interface.
[0113] The control determination module is used to determine the business functions corresponding to the interface test model and determine the controls based on the business functions.
[0114] The testing module is used to perform test operations on the controls using an agent trained based on the operation interface and response interface in the interface testing model, and to obtain the interface test results.
[0115] In one embodiment, the interface test model determination module is specifically used to: determine the test path corresponding to the test interface, and obtain the interface test model of the test path.
[0116] In one embodiment, it further includes:
[0117] The operation module is used to determine the controls corresponding to the test path, and to operate the controls through the agent in the initial interface test model to obtain the operation interface and response interface;
[0118] The reward and penalty value module is used to determine the reward and penalty value based on the operation interface, response interface, test path, and preset reward function;
[0119] The first iteration module is used to determine the initial interface test model as the interface test model when the current iteration number reaches the preset iteration number; otherwise, it updates the agent in the initial interface test model according to the reward and penalty value.
[0120] In one embodiment, the reward / penalty value module includes:
[0121] The response coefficient unit is used to determine the response coefficient based on the positional relationship between the operation interface and the response interface in the test path.
[0122] The path coefficient unit is used to determine the path coefficient based on the test path and the preset reward function;
[0123] The reward / penalty value unit is used to determine the reward / penalty value based on the response coefficient and path coefficient.
[0124] In one embodiment, it further includes:
[0125] The Total Reward and Penalty Value module is used to determine the total reward and penalty value based on the reward and penalty value.
[0126] The second iteration module is used to determine the initial interface test model as the interface test model when the total reward and punishment value reaches the preset reward and punishment threshold; otherwise, it updates the agent in the initial interface test model according to the reward and punishment value.
[0127] In one embodiment, the total reward / penalty value module includes:
[0128] The training step count unit is used to determine the number of training steps based on the response coefficient.
[0129] Penalty value unit, used to determine the penalty value based on the number of training steps;
[0130] The total reward / penalty value unit is used to determine the total reward / penalty value based on the penalty value and the reward / penalty value.
[0131] like Figure 7 As shown, in practical applications, the knowledge graph-based interface testing device includes a knowledge graph construction module, an interface path extraction module, a reinforcement learning model construction module, a reinforcement learning model training module, and an automated test execution module.
[0132] The knowledge graph construction module is mainly used for the extraction and construction of knowledge graphs using API calls.
[0133] The interface path extraction module includes an interface test model determination module, which is used to extract all path information related to a given interface from the knowledge graph, and finally form multiple test paths.
[0134] The reinforcement learning model building module is mainly used to build reinforcement learning models;
[0135] The reinforcement learning model training module is mainly used for model training, including the operation module, reward and penalty value module, first iteration module, total reward and penalty value module, and second iteration module.
[0136] The automated test execution module includes a control determination module and a test module, which are mainly used to perform automated testing on the corresponding pages based on the action instructions given by the model.
[0137] In summary, the knowledge graph-based interface testing device of this invention first determines the interface testing model corresponding to the test interface, then determines the business function corresponding to the interface testing model to determine the control based on the business function, and finally performs test operations on the control corresponding to the test interface through the intelligent agent trained based on the operation interface and response interface in the interface testing model to obtain the interface test results. It can automatically sort out the call relationship and perform automated testing to achieve full coverage of the interface.
[0138] This invention also provides a specific implementation of a computer device capable of implementing all the steps in the knowledge graph-based interface testing method described in the above embodiments. Figure 8 This is a structural block diagram of the computer device in an embodiment of the present invention, see below. Figure 8 The computer equipment specifically includes the following:
[0139] Processor 801 and memory 802.
[0140] The processor 801 is used to call the computer program in the memory 802. When the processor executes the computer program, it implements all the steps in the knowledge graph-based interface testing method in the above embodiments. For example, when the processor executes the computer program, it implements the following steps:
[0141] Obtain the test interface and determine the corresponding interface test model;
[0142] Determine the business functions corresponding to the interface test model, and determine the controls based on the business functions;
[0143] The interface test results are obtained by using an agent trained based on the operation interface and response interface in the interface test model to perform test operations on the control.
[0144] In summary, the computer device of this embodiment first determines the interface test model corresponding to the test interface, then determines the business function corresponding to the interface test model to determine the control based on the business function, and finally performs test operations on the control corresponding to the test interface through the intelligent agent trained based on the operation interface and response interface in the interface test model to obtain the interface test results. It can automatically sort out the call relationship and perform automated testing to achieve full coverage of the interface.
[0145] This invention also provides a computer-readable storage medium capable of implementing all steps of the knowledge graph-based interface testing method in the above embodiments. The computer-readable storage medium stores a computer program that, when executed by a processor, implements all steps of the knowledge graph-based interface testing method in the above embodiments. For example, when the processor executes the computer program, it implements the following steps:
[0146] Obtain the test interface and determine the corresponding interface test model;
[0147] Determine the business functions corresponding to the interface test model, and determine the controls based on the business functions;
[0148] The interface test results are obtained by using an agent trained based on the operation interface and response interface in the interface test model to perform test operations on the control.
[0149] In summary, the computer-readable storage medium of this invention first determines the interface test model corresponding to the test interface, then determines the business function corresponding to the interface test model to determine the control based on the business function, and finally performs test operations on the control corresponding to the test interface through the intelligent agent trained based on the operation interface and response interface in the interface test model to obtain the interface test results. It can automatically sort out the call relationship and perform automated testing to achieve full coverage of the interface.
[0150] This invention also provides a computer program product capable of implementing all steps of the knowledge graph-based interface testing method in the above embodiments. The computer program product includes a computer program / instructions that, when executed by a processor, implement all steps of the knowledge graph-based interface testing method in the above embodiments. For example, when the processor executes the computer program, it implements the following steps:
[0151] Obtain the test interface and determine the corresponding interface test model;
[0152] Determine the business functions corresponding to the interface test model, and determine the controls based on the business functions;
[0153] The interface test results are obtained by using an agent trained based on the operation interface and response interface in the interface test model to perform test operations on the control.
[0154] In summary, the computer program product of this invention first determines the interface test model corresponding to the test interface, then determines the business function corresponding to the interface test model to determine the control based on the business function, and finally performs test operations on the control corresponding to the test interface through the intelligent agent trained based on the operation interface and response interface in the interface test model to obtain the interface test results. It can automatically sort out the call relationship and perform automated testing to achieve full coverage of the interface.
[0155] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
[0156] Those skilled in the art will also understand that the various illustrative logical blocks, units, and steps listed in the embodiments of the present invention can be implemented by electronic hardware, computer software, or a combination of both. To clearly demonstrate the interchangeability of hardware and software, the functions of the various illustrative components, units, and steps described above have been generally described. Whether such functionality is implemented through hardware or software depends on the specific application and the overall system design requirements. Those skilled in the art can implement the described functions using various methods for each specific application, but such implementation should not be construed as exceeding the scope of protection of the embodiments of the present invention.
[0157] The various illustrative logic blocks, units, or devices described in the embodiments of this invention can be implemented or operate the described functions using a general-purpose processor, digital signal processor, application-specific integrated circuit (ASIC), field-programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof. The general-purpose processor can be a microprocessor; alternatively, it can be any conventional processor, controller, microcontroller, or state machine. The processor can also be implemented using a combination of computing devices, such as a digital signal processor and a microprocessor, multiple microprocessors, one or more microprocessors combined with a digital signal processor core, or any other similar configuration.
[0158] The steps of the methods or algorithms described in the embodiments of this invention can be directly embedded in hardware, a software module executed by a processor, or a combination of both. The software module can be stored in RAM, flash memory, ROM, EPROM, EEPROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from and write information to the storage medium. Optionally, the storage medium can also be integrated into the processor. The processor and storage medium can be housed in an ASIC, which can be housed in a user terminal. Optionally, the processor and storage medium can also be housed in different components of the user terminal.
[0159] In one or more exemplary designs, the functions described in the embodiments of the present invention can be implemented in hardware, software, firmware, or any combination of these three. If implemented in software, these functions can be stored on a computer-readable medium or transmitted on a computer-readable medium in the form of one or more instructions or code. Computer-readable media include computer storage media and communication media that facilitate the transfer of computer programs from one place to another. Storage media can be any available media that can be accessed by a general-purpose or special-purpose computer. For example, such computer-readable media can include, but is not limited to, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program code in the form of instructions or data structures and other forms that can be read by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Furthermore, any connection can be suitably defined as a computer-readable medium, for example, if the software is transmitted from a website, server or other remote resource via a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wirelessly, such as infrared, wireless and microwave, it is also included in the defined computer-readable medium. The disks and discs mentioned include compressed disks, laser discs, optical discs, DVDs, floppy disks, and Blu-ray discs. Disks typically copy data magnetically, while disks typically copy data optically using lasers. Combinations of the above can also be contained in computer-readable media.
Claims
1. A knowledge graph-based interface testing method, characterized in that, include: Obtain the test interface and determine the corresponding interface test model; The business function corresponding to the interface test model is determined, and the control is determined according to the business function. Specifically, the test path corresponding to the interface test model is determined, and the control is determined according to the business function corresponding to the test path. A knowledge graph of interface call relationships between test interfaces is extracted using structured data of registered interface call information, transaction log extraction, and data tracking. The test path is determined according to the call relationships between each interface. The control is an environmental element in the interface test model, including page control name and page control position information. The control is re-collected after the interface test model performs operations in the scenario. The operations of the control include clicking, swiping, and input. The control is tested by an agent trained based on the operation interface and response interface in the interface test model to obtain the interface test results. The method further includes: determining a response coefficient based on the positional relationship between the operation interface and the response interface in the test path; determining a path coefficient based on the test path and a preset reward function; and determining a reward / penalty value based on the response coefficient, the path coefficient, and the preset reward function; wherein, the longer the test path, the larger the path coefficient. The method further includes: determining the number of training steps based on the response coefficient; determining a penalty value based on the training steps; and determining a total reward / penalty value based on the penalty value and the reward / penalty value.
2. The knowledge graph-based interface testing method according to claim 1, characterized in that, Determining the interface test model corresponding to the test interface includes: Determine the test path corresponding to the test interface, and obtain the interface test model for the test path.
3. The knowledge graph-based interface testing method according to claim 2, characterized in that, Also includes: Perform the following iterative processing: Determine the control corresponding to the test path, and operate the control through the agent in the initial interface test model to obtain the operation interface and the response interface; The reward and penalty values are determined based on the operation interface, the response interface, the test path, and the preset reward function; When the current iteration count reaches the preset iteration count, the initial interface test model is determined to be an interface test model; otherwise, the agent in the initial interface test model is updated according to the reward / penalty value.
4. The knowledge graph-based interface testing method according to claim 3, characterized in that, Also includes: The total reward and penalty value is determined based on the aforementioned reward and penalty value; When the total reward and penalty value reaches the preset reward and penalty threshold, the initial interface test model is determined to be an interface test model; otherwise, the agent in the initial interface test model is updated according to the reward and penalty value.
5. A knowledge graph-based interface testing device, characterized in that, include: The interface test model determination module is used to obtain the test interface and determine the corresponding interface test model for the test interface. The control determination module is used to determine the business function corresponding to the interface test model, and determine the control based on the business function. Specifically, it determines the test path corresponding to the interface test model, and determines the control based on the business function corresponding to the test path. It extracts a knowledge graph of interface call relationships between test interfaces using structured data of registered interface call information, transaction log extraction, and data tracking. The test path is determined based on the call relationships between the interfaces. The control is an environmental element in the interface test model, including page control name and page control position information. The control is re-collected after the interface test model performs operations in the scenario. The operations of the control include clicking, swiping, and input. The testing module is used to perform test operations on the control through the intelligent agent trained based on the operation interface and response interface in the interface testing model, and obtain the interface test results. The device further includes: a response coefficient determination module, used to determine the response coefficient based on the positional relationship between the operation interface and the response interface in the test path; a path coefficient determination module, used to determine the path coefficient based on the test path and a preset reward function; and a reward / penalty value determination module, used to determine the reward / penalty value based on the response coefficient, the path coefficient, and the preset reward function; wherein, the longer the test path, the larger the path coefficient. The device further includes: a training step determination module, used to determine the training step based on the response coefficient; a penalty value determination module, used to determine a penalty value based on the training step; and a total reward / penalty value determination module, used to determine a total reward / penalty value based on the penalty value and the reward / penalty value.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the knowledge graph-based interface testing method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the knowledge graph-based interface testing method according to any one of claims 1 to 4.
8. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the knowledge graph-based interface testing method according to any one of claims 1 to 4.