Simulation test method, device and storage medium
By receiving simulation information requests from the test page, setting and packaging the engineering code of the simulation function, and mounting dynamic tracking and monitoring tools, the problem of low efficiency of interface simulation testing in the existing technology is solved, and dynamic monitoring and display of interface response content is realized. Improves testing efficiency.
Patent Information
- Application Number
- CN202210534404.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-05-17
AI Technical Summary
When the prior art simulates the called interface, developers need to modify the interface code and redeploy the application, resulting in low testing efficiency.
Provide a simulation test method, by receiving simulation information requests input from the test page, setting and packaging the engineering code of the simulation function, mounting the dynamic tracking and monitoring tool to the application process, triggering the interface simulation function to take effect, and saving the effective information to the database and Test page to realize the monitoring and display of interface response simulation content.
Without modifying the interface code, the dynamic tracking monitoring tool monitoring method is executed, and the interface can return the specified response content, which significantly improves the testing efficiency.
Smart Images

Figure CN114817063B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a simulation test method, device and storage medium. Background Art
[0002] Mock testing technology refers to simulating the return of a service interface in some way, so that the return of the interface replaces the original return content with customized return content.
[0003] During the system development process, the system needs to be tested to ensure that it can run normally. However, the system to be tested usually needs to call other interfaces during the logic processing, and the called interface may not be fully developed or the interface system may be abnormal. In this case, the called interface can be simulated to complete the test of the system to be tested.
[0004] When the existing technology simulates the called interface, the developer needs to modify the interface code and redeploy the application to meet the test requirements, which results in low test efficiency. Summary of the invention
[0005] The present application provides a simulation test method, device and storage medium to solve the problem of low test efficiency in the prior art of simulating a called interface.
[0006] In a first aspect, the present application provides a simulation test method, comprising:
[0007] Receive a simulation information request input from a test page, the simulation information request carries simulation information, and the simulation information includes: the server address of the application to which the interface to be simulated belongs, the application name, and the method name to be simulated;
[0008] According to the simulation information, the information corresponding to the project providing the simulation function is set;
[0009] Package the code corresponding to the project that provides the simulation function and copy it to the server corresponding to the server address;
[0010] Mount the dynamic tracking monitoring tool to the process of the application corresponding to the application name to monitor whether the method corresponding to the method name is executed;
[0011] Trigger the simulation function of the interface that needs to be simulated to take effect;
[0012] The simulation information of the function taking effect is saved in the database, and the simulation information of the function taking effect is sent to the test page, so that the tester can perform project testing according to the simulation information of the function taking effect displayed on the test page.
[0013] In a possible implementation, after the simulation function of the interface to be simulated is triggered to take effect, the following steps are further included:
[0014] If the method corresponding to the monitoring method name of the dynamic tracking monitoring tool is executed, the method response simulates the response content contained in the information.
[0015] In a possible implementation, information corresponding to the project providing the simulation function is set according to the simulation information, including:
[0016] According to the simulation information, the content of the source file providing the simulation function in the project providing the simulation function is set.
[0017] In a possible implementation, according to the simulation information, the content of the source file providing the simulation function in the project providing the simulation function is set, including:
[0018] Use regular expressions to replace the corresponding content in the source file that provides the simulation function with the class name of the method to be simulated, the method name to be simulated, and the response content contained in the simulation information.
[0019] In a possible implementation, before setting information corresponding to the project providing the simulation function according to the simulation information, the method further includes:
[0020] Save the code corresponding to the project that provides simulation functions.
[0021] In a possible implementation, the simulation test method further includes:
[0022] A request for uninstalling simulation is received, and the simulation information is logically deleted so that the interface to be simulated responds to the initial content, where the initial content is the response content of the interface to be simulated before the simulation is performed.
[0023] In a possible implementation, before logically deleting the simulation information so that the interface to be simulated responds to the content before the simulation, the method further includes:
[0024] Uninstall the dynamic tracking monitoring tool mounted on the application process.
[0025] In a possible implementation, after receiving a request to uninstall simulation and logically deleting simulation information so that the interface to be simulated responds to the initial content, the method further includes:
[0026] Send the simulated information of the function taking effect in the database to the test page to update the simulated information displayed on the test page.
[0027] In a second aspect, the present application provides a simulation test device, comprising:
[0028] The receiving module is used to receive the simulation information request inputted from the test page, the simulation information request carries simulation information, and the simulation information includes: the server address of the application to which the interface to be simulated belongs, the application name and the method name to be simulated;
[0029] The processing module is used to set the information corresponding to the project providing the simulation function according to the simulation information; package the code corresponding to the project providing the simulation function and copy it to the server corresponding to the server address; mount the dynamic tracking monitoring tool to the process of the application corresponding to the application name to monitor whether the method corresponding to the method name is executed; trigger the simulation function of the interface to be simulated to take effect; and save the simulation information of the effective function to the database;
[0030] The sending module is used to send the simulation information of the function taking effect to the test page, so that the tester can perform project testing according to the simulation information of the function taking effect displayed on the test page.
[0031] In a third aspect, the present application provides a simulation test device, comprising: a processor, a memory, wherein codes are stored in the memory, and the processor runs the codes stored in the memory to execute the simulation test method as described in any one of the first aspects.
[0032] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the simulation test method as described in any one of the first aspects.
[0033] The present application provides a simulation test method, device and storage medium, the method comprising: receiving a simulation information request inputted by a test page, wherein the simulation information request carries simulation information, and the simulation information comprises: the server address, application name and method name to be simulated of the application to which the interface to be simulated belongs. The information corresponding to the project providing the simulation function is set according to the simulation information. After the information corresponding to the project providing the simulation function is set, the code corresponding to the project providing the simulation function is packaged and copied to the server corresponding to the server address. The dynamic tracking monitoring tool is mounted on the process of the application corresponding to the application name, and the simulation function of the interface to be simulated is triggered to take effect. At this time, the dynamic tracking monitoring tool monitors whether the method corresponding to the method name is executed. The simulation information of the effective function is saved to the database, and the simulation information of the effective function is sent to the test page. The tester can perform project testing according to the simulation information of the effective function displayed on the test page. When the dynamic tracking monitoring tool monitors that the method corresponding to the method name is executed, the interface to be simulated returns the response content, and there is no need to modify the interface code to be simulated, which effectively improves the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0035] Figure 1 A simulation test method process provided in the embodiment of the present application Figure 1 ;
[0036] Figure 2 A simulation test method process provided in the embodiment of the present application Figure 2 ;
[0037] Figure 3 A schematic diagram of simulation information provided in an embodiment of the present application;
[0038] Figure 4 A flow chart of a method for uninstalling a simulation function provided in an embodiment of the present application;
[0039] Figure 5 A schematic diagram of a simulation test device provided in an embodiment of the present application Figure 1 ;
[0040] Figure 6 A schematic diagram of a simulation test device provided in an embodiment of the present application Figure 2 .
[0041] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0042] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0043] First, the terms involved in this application are explained:
[0044] JVM (Java Virtual Machine) is a specification for computing devices. It is a fictional computer that is implemented by simulating various computer functions on an actual computer.
[0045] Sandbox: is a virtual system program that allows running a browser or other program in a sandbox environment, so that changes made during the run can be deleted later.
[0046] Aspect Oriented Programming (AOP): is a technology that achieves unified maintenance of program functions through pre-compilation and dynamic proxy during runtime. AOP can be used to isolate various parts of business logic, thereby reducing the coupling between the various parts of business logic, improving the reusability of the program, and improving development efficiency.
[0047] Maven: It is a project management and automatic build tool based on the concept of Project Object Model (POM). Maven uses a central information fragment to manage the build, report and documentation steps of a project.
[0048] During the system development process, the system needs to be tested to ensure that it can operate normally. Generally, testing the system requires testing multiple interfaces of the system. The interface to be tested needs to call other interfaces during the logic processing. When the called interface is not fully developed or fails, the called interface can be simulated to complete the test of the system to be tested.
[0049] For example, when testing interface B1, since interface B1 internally calls interface D1, and interface D1 is unavailable due to incomplete development or system abnormality, interface D1 needs to be simulated so that interface B1 can return specific content when calling interface D1, so that interface B1 can continue to execute normally and complete its own logical processing.
[0050] In another scenario, the tester needs to test certain specific scenarios and simulate the relevant interfaces. For example, the tester needs to test the user registration specific scenario of interface C1, and the implementation of this specific scenario requires calling the query interface D2 to query whether the user already exists. At this time, the query interface D2 needs to be simulated to make the query interface D2 return "no such user", so that interface C1 continues to execute its own logic and completes the user registration.
[0051] When simulating the called interface, developers are required to modify the interface code and redeploy the application to meet the test requirements, resulting in low test efficiency.
[0052] The present application provides a simulation test method, which receives a simulation information request input from a test page, wherein the simulation information request carries simulation information, and the simulation information includes the server address of the application to which the interface to be simulated belongs, the application name, and the method name to be simulated. After setting the information corresponding to the project providing the simulation function according to the simulation information, the code corresponding to the project providing the simulation function is packaged and copied to the server corresponding to the server address. The dynamic tracking and monitoring tool is mounted on the process of the application corresponding to the application name, and the simulation function of the interface to be simulated is triggered to take effect. When the dynamic tracking and monitoring tool monitors that the method corresponding to the method name is executed, the interface to be simulated returns the specified response content, and there is no need to modify the interface code to be simulated, which effectively improves the test efficiency.
[0053] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0054] Figure 1 A simulation test method process provided in the embodiment of the present application Figure 1 The method of this embodiment can be executed by a simulation test device and can be implemented by hardware, software, or a combination of hardware and software. Figure 1 As shown, the method provided by the present application may include:
[0055] S101: receiving a simulation information request inputted from a test page, wherein the simulation information request carries simulation information, and the simulation information includes: a server address where an application to which an interface to be simulated belongs is located, an application name, and a method name to be simulated.
[0056] Application as a service can be an independently deployed project, such as user service, after-sales service, product service, etc. Methods are functions in application code.
[0057] An interface is a way for a web (World Wide Web) system to provide a function to external calls.
[0058] The simulation information is the relevant information of the interface to be simulated, including the server address of the application to which the interface to be simulated belongs, the application name and the method name to be simulated, as well as the class name to which the method belongs and the response content. Among them, the class name to which the method belongs can be used to determine the method to be simulated, and the response content is the return content specified by the interface to be simulated.
[0059] S102: Setting information corresponding to the project providing the simulation function according to the simulation information.
[0060] The project is a code project. Specifically, the code project is to save the code source files and configuration files in a directory according to certain conventions. After operating the directory, the service deployment can be realized. The project that provides simulation function can be a Maven project that integrates the jvm-sanbox package, which contains the source files that provide simulation function code.
[0061] The project providing the simulation function also includes information such as the application name and method name. In one implementation scenario, the source file content providing the simulation function in the project providing the simulation function can be set according to the simulation information. For example, the method name to be simulated contained in the simulation information replaces the corresponding method name information in the source file.
[0062] S103: Packaging the code corresponding to the project providing the simulation function and copying it to the server corresponding to the server address.
[0063] The code corresponding to the project that provides the simulation function can be packaged by executing the project packaging command.
[0064] In one implementation scenario, the code providing the simulation function may be packaged to generate a jar package, and the jar package may be remotely copied to a server corresponding to the server address, where the application to which the interface to be simulated belongs is located.
[0065] S104: Mounting a dynamic tracking monitoring tool to the process of the application corresponding to the application name to monitor whether the method corresponding to the method name is executed.
[0066] In one implementation scenario, the dynamic tracking monitoring tool can be mounted to the process corresponding to the process number according to the process number of the application.
[0067] The dynamic tracking monitoring tool is a tool for monitoring whether the application method is executed. It can be a sandbox jvm-sanbox or a btrace tool, and this application does not impose any restrictions on this.
[0068] S105: Triggering the simulation function of the interface to be simulated to take effect.
[0069] In one implementation scenario, a simulation function validation command may be executed based on the process number of the process corresponding to the application name mounted by the dynamic tracking tool to trigger the simulation function of the interface to be simulated to take effect.
[0070] When the simulation function of the interface to be simulated is triggered to take effect, the response content of the interface to be simulated is the response content in the simulation information, and the dynamic tracking monitoring tool starts to monitor whether the method corresponding to the method name is executed.
[0071] In one implementation scenario, if the method corresponding to the method name monitored by the dynamic tracking monitoring tool is executed, the method response simulation information includes the response content. The method corresponding to the method name is the method to be simulated.
[0072] S106: The simulation information of the function being effective is saved in a database, and the simulation information of the function being effective is sent to a test page, so that the tester can perform project testing according to the simulation information of the function being effective displayed on the test page.
[0073] The simulation information in the database includes simulation information with effective functions and simulation information with invalid functions. Simulation information with effective functions refers to information that can respond to the specified content. Simulation information with invalid functions does not have simulation functions, that is, it cannot respond to the specified content.
[0074] In one implementation scenario, after receiving a request for querying simulation information sent by a test page, the simulation information of the functional efficacy is sent to the test page. The simulation information of the effective functions displayed on the test page can be displayed in the form of a list.
[0075] The simulation information of the function displayed on the test page may include: application name, class name to which the method belongs, and method name to be simulated.
[0076] The embodiment of the present application provides a simulation test method, which receives a simulation information request inputted by a test page, wherein the simulation information request carries simulation information, and the simulation information includes: the server address, application name, and method name to be simulated of the application to which the interface to be simulated belongs. According to the simulation information, the information corresponding to the project providing the simulation function can be set. After the information corresponding to the project providing the simulation function is set, the project providing the simulation function is packaged and copied to the server corresponding to the server address. The dynamic tracking monitoring tool is mounted on the process of the application corresponding to the application name, and the simulation function of the interface to be simulated is triggered to take effect. At this time, the dynamic tracking monitoring tool can monitor whether the method to be simulated is executed. When the method is executed, the method can respond to the response content in the simulation information. The method provided by the present application can set the information corresponding to the project providing the simulation function according to the simulation information, and monitor whether the simulated method is executed through the dynamic tracking monitoring tool. When the method is executed, the response content in the simulation information can be responded, without modifying the code of the interface to be simulated, and without restarting the application to which the interface to be simulated belongs, thereby improving the test efficiency.
[0077] Based on the above embodiments, a specific embodiment is provided below to describe the process of the simulation test method.
[0078] Figure 2 A simulation test method process provided in the embodiment of the present application Figure 2, the method provided in this application can be performed by a simulation test device, as follows:
[0079] S201: receiving a simulation information request inputted from a test page, wherein the simulation information request carries simulation information, and the simulation information includes: a server address where an application to which an interface to be simulated belongs is located, an application name, and a method name to be simulated.
[0080] In one implementation scenario, the tester can input simulation information on the test page and click an "inject simulation" button to enable the test page to send a simulation information request to the simulation test device.
[0081] like Figure 3 As shown, the simulation information may also include the class name to which the method belongs and the response content, wherein the class name to which the method belongs can be used to determine the method to be simulated, and the response content is the return content specified by the interface to be simulated.
[0082] S202: Save the code corresponding to the project providing the simulation function.
[0083] In one implementation scenario, the project that provides the simulation function can be a Maven project that integrates the jvm-sanbox package. Its overall architecture is as follows:
[0084]
[0085]
[0086] Among them, the ServiceMethodMockerModule.java file is a source file that defines the code that provides the simulation function.
[0087] S203: According to the simulation information, the content of the source file providing the simulation function in the project providing the simulation function is set.
[0088] In one implementation scenario, a regular expression may be used to replace the corresponding content in the source file providing the simulation function with the class name of the method to be simulated, the method name to be simulated, and the response content contained in the simulation information.
[0089] For example, the source file that provides the simulation function is the ServiceMethodMockerModule.java file, which contains the contents of onclass, onBehavior, and result. If the class name of the method contained in the simulation information is cn.how2j.trend.kcard-admin.Auth, set the content of onclass in the source file to cn.how2j.trend.kcard-admin.Auth; if the method name contained in the simulation information is checkUserMsg, set the content of onBehavior in the source file to checkUserMsg; similarly, if the response content contained in the simulation information is {"code":"1000","msg":"true"}, set the content of result in the source file to {"code":"1000","msg":"true"}.
[0090] S204: Packaging the code corresponding to the project providing the simulation function and copying it to the server corresponding to the server address.
[0091] In one implementation scenario, the code corresponding to the project providing the simulation function is packaged into a jar package by executing the project packaging command, and the jar package is remotely copied to the ~ / .sandbox-module directory of the server corresponding to the server address. The server is the server where the application to which the interface to be simulated belongs is located.
[0092] For example, if the server address included in the simulation information is 130.54.3.129, the command for remotely copying the jar package to the server can be: scp target / mock.jar root@130.54.3.129:~ / .sandbox-module / .
[0093] S205: Mounting a dynamic tracking monitoring tool to the process of the application corresponding to the application name, so as to monitor whether the method corresponding to the method name is executed.
[0094] Dynamic tracing monitoring tools are tools that monitor whether the methods to be simulated are executed. They can be sandbox jvm-sanbox or btrace tools. Sandbox is an AOP (Aspect Oriented Programming) solution tool that can operate programs in progress without restarting or intruding the target JVM (Java Virtual Machine) application.
[0095] In one implementation scenario, the application name is kcard-admin, and the mounting command can be ps-ef|grep-i_kcard-admin|awk'{print$2}'|. / sandbox.sh-p, where ps-ef obtains all process information, grep-i_kcard-admin filters out processes containing the kcard-admin application, awk'{print$2}' obtains the process number in the process information, and . / sandbox.sh-p mounts the sandbox to the process corresponding to the specified process number.
[0096] S206: Triggering the simulation function of the interface to be simulated to take effect.
[0097] In one implementation scenario, if the process number of the application to which the dynamic tracking monitoring tool is mounted corresponding to the application name is 64229, then the command for triggering the simulation function to take effect is: . / sandbox.sh-p 64229-d'service-method-mocker / beginMock'.
[0098] After the simulation function of the interface to be simulated is triggered to take effect, the response content of the interface to be simulated is the response content in the simulation information, that is, the simulation of the interface to be simulated is completed. At this time, the dynamic tracking monitoring tool will monitor whether the method is executed.
[0099] In one implementation scenario, the monitored method is checkUserMsg. When this method is executed, the processing of the method logic declared in AdviceListener is triggered. For example, since the afterReturning method is declared in AdviceListener in the source file, it means that when the checkUserMsg method is executed, when it returns the response content, the content defined in afterReturning is used to replace the initial response content of the checkUserMsg method and return it to the caller. The content defined in afterReturning is the response content contained in the simulation information.
[0100] It should be noted that mounting the dynamic tracking monitoring tool to the process of the application corresponding to the application name and triggering the simulation function of the interface to be simulated to take effect are both effective on the server where the interface application to be simulated is located.
[0101] S207: The simulation information of the function being effective is saved in a database, and the simulation information of the function being effective is sent to a test page, so that the tester can perform project testing according to the simulation information of the function being effective displayed on the test page.
[0102] In one implementation scenario, the simulation information of the functions displayed on the test page can be displayed in the form of a list, as shown in Table 1. The simulation information of the functions displayed on the test page can include: application name, class name to which the method belongs, method name to be simulated, response content and operation.
[0103] Table 1 Simulation information list
[0104]
[0105] Among them, "Uninstall simulation" is displayed in the operation. When the tester clicks this button, the simulation information corresponding to "Uninstall simulation" will be logically deleted, so that the interface that needs to be simulated responds to the initial content.
[0106] The present application provides a simulation test method, which receives a simulation information request inputted by a test page, wherein the simulation information request carries simulation information, and the simulation information includes the server address, application name, and method name to be simulated of the application to which the interface to be simulated belongs. The code corresponding to the project providing the simulation function is saved, and the content of the source file in the project providing the simulation function is set according to the simulation information. After the content of the source file in the project providing the simulation function is set, the code providing the simulation function is packaged and copied to the server corresponding to the server address. The dynamic tracking monitoring tool is mounted on the process of the application corresponding to the application name. When the simulation function of the interface to be simulated is triggered to take effect, the dynamic tracking monitoring tool can monitor whether the method corresponding to the method name is executed. When the method is executed, the method can respond to the response content in the simulation information. The simulation information of the effective function is saved to the database, and the simulation information of the effective function is sent to the test page, so that the tester can perform project testing according to the simulation information of the effective function displayed on the test page. The method provided in the present application monitors whether the simulated method is executed through a dynamic tracking monitoring tool. When the method is executed, it can respond to the response content set in the simulation information. There is no need to modify the code of the interface to be simulated, and there is no need to restart the application to which the interface to be simulated belongs, thereby improving testing efficiency.
[0107] When the simulation function of the interface to be simulated, i.e. the calling interface, takes effect, the tester can test the interface to be tested. When the system to which the calling interface belongs receives an HTTP (Hyper Text Transfer Protocol) request sent by the interface to be tested, since the HTTP request contains the uniform resource locator of the calling interface, the system to which the calling interface belongs can assign the HTTP request to the calling interface according to the uniform resource locator of the calling interface. At this point, the dynamic tracking tool monitors that the method corresponding to the calling interface is executed, and the calling interface returns the response content to the interface to be tested, and the interface to be tested can continue to execute its own logic to complete the test.
[0108] Based on the above embodiment, an embodiment is provided below to describe in detail the process of uninstalling the simulation function after the test process is completed.
[0109] Figure 4 A flowchart of a method for uninstalling a simulation function provided in an embodiment of the present application. The method provided in the present application can be executed by a simulation function device, as follows:
[0110] S401: receiving a request for uninstalling simulation, and logically deleting simulation information so that the interface to be simulated responds to initial content, where the initial content is the response content of the interface to be simulated before simulation.
[0111] After the interface or front-end page to be tested is tested, the simulation function can be logically deleted so that the interface to be simulated responds to the initial content. In one implementation scenario, the user can select the simulation function to be uninstalled from the simulation information of the function displayed on the test page, and click the "Uninstall Simulation" button to achieve the logical deletion of the simulation information. The logical deletion of the simulation information marks the status of the simulation information as invalid.
[0112] The existing method of restoring the content of the interface to be simulated before being simulated requires developers to modify their code, which is inefficient. At the same time, since the interface code to be simulated is modified to the initial code, there will be omissions, resulting in a high probability of problems. The method provided by the present application can achieve the initial content of the interface to be simulated by logically deleting the simulation information, which is more efficient and reduces the probability of failure.
[0113] Since the interface or front-end page to be tested has been tested, there is no need for a dynamic tracking monitoring tool to monitor whether the method to be simulated is executed. Therefore, before logically deleting the simulation information, the dynamic tracking monitoring tool mounted on the application process can be uninstalled.
[0114] S402: Send the simulation information of the effective function in the database to the test page to update the simulation information displayed on the test page.
[0115] The database stores simulation information with effective functions and simulation information with invalid functions. The simulation information with invalid functions does not have simulation functions, so only the effective simulation information in the database needs to be sent to the test page. The tester can perform subsequent tests based on the simulation information with effective functions displayed on the test page.
[0116] The embodiment of the present application provides a method for uninstalling a simulation function, receiving a request for uninstalling the simulation, and logically deleting the simulation information so that the interface to be simulated responds to the initial content, and the initial content is the response content of the interface to be simulated before the simulation. After the simulation information is logically deleted, the simulation information of the function taking effect in the database is sent to the test page, and the simulation information displayed on the test page is updated to facilitate subsequent testing by the tester. The method provided by the present application can realize that the interface to be simulated responds to the response content before being simulated by logically deleting the simulation function, without modifying the interface code to be simulated to the initial code, thereby improving the efficiency and flexibility of uninstalling the simulation function and reducing the probability of failure of the interface to be simulated.
[0117] Figure 5 A schematic diagram of a simulation test device provided in an embodiment of the present application Figure 1 .like Figure 5 As shown, an embodiment of the present application provides a simulation test device 500 , which may include a receiving module 501 , a processing module 502 , and a sending module 503 .
[0118] The receiving module 501 is used to receive a simulation information request inputted from a test page, wherein the simulation information request carries simulation information, and the simulation information includes: the server address of the application to which the interface to be simulated belongs, the application name, and the method name to be simulated;
[0119] The processing module 502 is used to set the information corresponding to the project providing the simulation function according to the simulation information; package the code corresponding to the project providing the simulation function and copy it to the server corresponding to the server address; mount the dynamic tracking monitoring tool to the process of the application corresponding to the application name to monitor whether the method corresponding to the method name is executed; trigger the simulation function of the interface to be simulated to take effect; and save the simulation information of the effective function to the database;
[0120] The sending module 503 is used to send the simulation information of the effective function to the test page, so that the tester can perform project testing according to the effective simulation information displayed on the test page.
[0121] The device of this embodiment can be used to perform the following steps: Figure 1 The implementation principle and technical effect of the method embodiment shown are similar and will not be repeated here.
[0122] Figure 6 A schematic diagram of a simulation test device provided in an embodiment of the present application Figure 2 .like Figure 6 As shown, an embodiment of the present application provides a simulation test device 600 including a processor 601 and a memory 602 , wherein the processor 601 and the memory 602 are connected via a bus 603 .
[0123] In the specific implementation process, the memory 602 stores codes, and the processor 601 runs the codes stored in the memory 602 to execute the simulation test method of the above method embodiment.
[0124] The specific implementation process of the processor 601 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0125] In the above Figure 6 In the illustrated embodiment, it should be understood that the processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0126] The memory 602 may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk storage.
[0127] The bus 603 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus 603 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus 603 in the drawings of the present application is not limited to only one bus or one type of bus.
[0128] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the simulation test method of the above method embodiment.
[0129] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0130] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0131] An embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the simulation test method provided in any embodiment of the present application is implemented.
[0132] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0133] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A simulation test method, It is characterized in that Applied to a simulation test device, the method comprises: Receive a simulation information request inputted from a test page, wherein the simulation information request carries simulation information, and the simulation information includes: a server address of an application to which an interface to be simulated belongs, an application name, and a method name to be simulated; Setting information corresponding to the project providing the simulation function according to the simulation information; Packaging the code corresponding to the project providing the simulation function and copying it to the server corresponding to the server address; Mounting a dynamic tracking monitoring tool to the process of the application corresponding to the application name to monitor whether the method corresponding to the method name is executed; Triggering the simulation function of the interface that needs to be simulated to take effect; The simulation information of the function being effective is saved in a database, and the simulation information of the function being effective is sent to the test page, so that the tester can perform project testing according to the simulation information of the function being effective displayed on the test page.
2. The method according to claim 1, It is characterized in that The simulation information further includes: response content; after the simulation function of the interface to be simulated is triggered to take effect, it also includes: If the dynamic tracking monitoring tool monitors that the method corresponding to the method name is executed, the method responds with the response content included in the simulation information.
3. The method according to claim 2, It is characterized in that The step of setting information corresponding to the project providing the simulation function according to the simulation information includes: According to the simulation information, the content of the source file providing the simulation function in the project providing the simulation function is set.
4. The method according to claim 3, It is characterized in that The step of setting the content of the source file providing the simulation function in the project providing the simulation function according to the simulation information includes: The class name to which the method belongs, the method name to be simulated and the response content contained in the simulation information are replaced with corresponding contents in the source file providing the simulation function by using a regular expression.
5. The method according to any one of claims 1 to 4, It is characterized in that Before setting the information corresponding to the project providing the simulation function according to the simulation information, the method further includes: The code corresponding to the project providing the simulation function is saved.
6. The method according to claim 1, It is characterized in that The method further comprises: A request for uninstalling simulation is received, and the simulation information is logically deleted so that the interface to be simulated responds to initial content, where the initial content is the response content of the interface to be simulated before simulation.
7. The method according to claim 6, It is characterized in that Before the simulation information is logically deleted so that the interface response to be simulated is the content before the simulation, the method further includes: Uninstall the dynamic tracking and monitoring tool mounted on the application process.
8. The method according to claim 6 or 7, It is characterized in that After receiving the request for uninstalling the simulation and logically deleting the simulation information so that the interface to be simulated responds to the initial content, the method further includes: The simulation information of the function taking effect in the database is sent to the test page to update the simulation information displayed on the test page.
9. A simulation test device, It is characterized in that include: A receiving module, used for receiving a simulation information request inputted from a test page, wherein the simulation information request carries simulation information, and the simulation information includes: a server address of an application to which an interface to be simulated belongs, an application name, and a method name to be simulated; A processing module is used to set information corresponding to the project providing the simulation function according to the simulation information; package the code corresponding to the project providing the simulation function and copy it to the server corresponding to the server address; mount the dynamic tracking monitoring tool to the process of the application corresponding to the application name to monitor whether the method corresponding to the method name is executed; trigger the simulation function of the interface to be simulated to take effect; and save the simulation information of the effective function to the database; The sending module is used to send the simulation information of the function taking effect to the test page, so that the tester can perform project testing according to the simulation information of the function taking effect displayed on the test page.
10. A simulation test device, include: A processor and a memory, wherein the memory stores codes, and the processor runs the codes stored in the memory to execute the simulation test method according to any one of claims 1 to 8.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the simulation test method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the simulation test method described in any one of claims 1 to 8 is implemented.
