Interface simulation test method, device, equipment and medium
By using command lines and development components to form a simulation proxy mechanism in interface simulation testing, the problems of high dependence and low security in existing technologies are solved, and efficient and secure interface simulation testing is achieved.
Patent Information
- Application Number
- CN202411722863.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-11-27
AI Technical Summary
Existing interface simulation testing solutions have problems such as code intrusion, severe dependencies, and cumbersome use, resulting in low security and low testing efficiency.
By analyzing and processing the interface to be tested, multiple related servers are determined. The simulation proxy script is pulled using the command line and mounted on the target server to form a simulation proxy mechanism. The service information is obtained and registered on the simulation management platform. The simulation rules are configured, and the development component is used to call the simulation proxy mechanism to intercept the test request for matching test processing.
It reduces the dependence on code, improves test security and efficiency, and realizes the standardized processing of interface simulation testing.
Smart Images

Figure CN119668965B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data security, and in particular to an interface simulation test method, device, equipment and medium. Background Art
[0002] Currently, existing interface simulation testing solutions primarily implement interface simulation testing by introducing JAR packages or gateways into the code, combined with internal service configuration. However, introducing JAR packages into the code carries the risk of importing non-business functional code, which becomes uncontrollable after release to production and poses security risks. Furthermore, each upgrade or modification requires reintroducing a new toolkit to the server, making it inconvenient to use. Furthermore, not all servers are connected to the gateway, and calls between servers typically do not pass through the gateway, making this scenario difficult to cover. Consequently, existing interface simulation testing solutions suffer from code intrusion, heavy dependencies, and cumbersome use, resulting in lower security and testing efficiency. Summary of the Invention
[0003] The embodiments of the present invention provide an interface simulation test method, apparatus, device and medium, aiming to solve the problems of existing interface simulation test solutions such as intrusive code, severe dependency and cumbersome use, which result in low security and low test efficiency.
[0004] In a first aspect, an embodiment of the present invention provides an interface simulation test method, the method comprising:
[0005] Analyze and process the interface to be tested to obtain multiple associated servers;
[0006] Determine a target server from the plurality of associated servers according to a preset screening strategy;
[0007] Acquire simulation server data, and determine a command line according to the simulation server data;
[0008] Pulling a simulation proxy script using the command line, and mounting the simulation proxy script to the target server to form a simulation proxy mechanism;
[0009] Acquire service information of the target server, and register the service information to a simulation management platform to configure multiple simulation rules of the interface to be tested;
[0010] Acquire other associated servers except the target server from the plurality of associated servers;
[0011] For the multiple simulation rules, the development component is used to call the simulation proxy mechanism to intercept the test request when the target server sends a test request to the other associated servers to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested.
[0012] In a second aspect, an embodiment of the present invention further provides an interface simulation test device, the device comprising:
[0013] An analysis unit, configured to analyze and process the interface to be tested to obtain multiple associated servers;
[0014] a screening unit, configured to determine a target server from the plurality of associated servers according to a preset screening strategy;
[0015] a first acquiring unit, configured to acquire simulation server data and determine a command line according to the simulation server data;
[0016] A mounting unit, configured to use the command line to pull a simulation proxy script, and mount the simulation proxy script to the target server to form a simulation proxy mechanism;
[0017] a configuration unit, configured to obtain service information of the target server, register the service information to a simulation management platform, and configure multiple simulation rules of the interface to be tested;
[0018] A second acquiring unit, configured to acquire other associated servers except the target server from the plurality of associated servers;
[0019] The test unit is used to use the development component to call the simulation proxy mechanism for the multiple simulation rules so that when the target server sends a test request to the other associated servers, the test request is intercepted to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested.
[0020] In a third aspect, an embodiment of the present invention further provides an electronic device, which includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method described in the first aspect is implemented.
[0021] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method described in the first aspect can be implemented.
[0022] The present invention provides an interface simulation test method, device, equipment and medium, the method comprising: performing analysis and processing based on an interface to be tested to obtain multiple associated servers; determining a target server from the multiple associated servers according to a preset screening strategy; obtaining simulation server data, and determining a command line according to the simulation server data; using the command line to pull a simulation proxy script, and mounting the simulation proxy script to the target server to form a simulation proxy mechanism; obtaining service information of the target server, and registering the service information to a simulation management platform to configure multiple simulation rules of the interface to be tested; obtaining other associated servers other than the target server from the multiple associated servers; and for the multiple simulation rules, using a development component to call the simulation proxy mechanism to intercept the test request when the target server sends a test request to the other associated servers so as to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain a target test result of the interface to be tested. The embodiment of the present invention can use the command line to directly pull the simulation proxy script and mount the simulation proxy script on the target server to form a simulation proxy mechanism. Therefore, there is no need to introduce a jar package in the code or perform simulation testing through a gateway, which reduces dependencies and improves test security. By developing components to call the simulation proxy mechanism to intercept the test request when the other associated servers send a test request to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested, thereby realizing standardized processing of interface simulation testing and improving test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0024] Figure 1 A schematic diagram of a flow chart of an interface simulation test method provided by an embodiment of the present invention;
[0025] Figure 2 Another flowchart of the interface simulation test method provided by an embodiment of the present invention;
[0026] Figure 3 A schematic block diagram of an interface simulation test device provided in an embodiment of the present invention;
[0027] Figure 4 A schematic block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0029] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0030] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0031] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0032] Embodiments of the present invention provide an interface simulation testing method, apparatus, device, and medium. The interface simulation testing method can be applied in an application environment where systems or applications developed in multiple languages are used for interface simulation testing. In this application, multiple associated servers and simulation servers communicate data via a network, the multiple associated servers obtain simulation server data from the simulation server, and the multiple associated servers use command lines to pull simulation agent scripts from the simulation server. A simulation management platform is applied to the multiple associated servers. Based on the interface to be tested, multiple associated servers are obtained by analyzing and processing; a target server is determined from the multiple associated servers according to a preset screening strategy; simulation server data is obtained, and a command line is determined according to the simulation server data; a simulation proxy script is pulled using the command line, and the simulation proxy script is mounted on the target server to form a simulation proxy mechanism; service information of the target server is obtained, and the service information is registered in a simulation management platform to configure multiple simulation rules of the interface to be tested; other associated servers other than the target server are obtained from the multiple associated servers; for the multiple simulation rules, the simulation proxy mechanism is called using a development component to intercept the test request when the target server sends a test request to the other associated servers so as to perform a corresponding matching test process on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested. In the present invention, the simulation proxy script is directly pulled using a command line, and the simulation proxy script is mounted on the target server to form a simulation proxy mechanism, and then the simulation proxy mechanism is called by a development component to intercept the test request when the target server sends a test request to the other associated servers so as to perform a corresponding matching test process on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested. Therefore, there is no need to introduce JAR packages into the code or perform simulation tests through a gateway, which reduces dependencies and improves test security and efficiency. The multiple associated servers can be, but are not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. An associated server can be implemented as a standalone server or a server cluster consisting of multiple servers. The present invention is described in detail below using specific embodiments.
[0033] Figure 1 Schematic diagram of the flow of the interface simulation test method provided by the embodiment of the present invention. Figure 1 As shown, the method includes the following steps S110-S170.
[0034] S110: Analyze and process the interface to be tested to obtain multiple associated servers.
[0035] In this embodiment, the interface simulation test method can be applied to systems or applications of multiple development languages in various application scenarios to perform simulation tests on the interface to be tested. The simulation test is achieved through data interaction between the multiple associated servers. The multiple associated servers can return data through the interface in real time when the interface to be tested is normal.
[0036] The interface to be tested is a plurality of lines of compiled code consisting of letters or data.
[0037] It should be understood that the analysis process here refers to the process of analyzing the servers that interact with the interface to be tested and determining all servers associated with the interface to be tested as multiple associated servers.
[0038] In one embodiment, in step S110, analyzing and processing the interface to be tested to obtain multiple associated servers includes:
[0039] Performing data analysis on the interface to be tested using a preset analysis strategy to obtain multiple server protocol addresses;
[0040] The plurality of associated servers are determined according to the plurality of server protocol addresses.
[0041] In this embodiment, the analysis strategy refers to a pre-set strategy for performing data analysis and processing on the interface to be tested, specifically, performing rule comparison processing on the data of the interface to be tested and the rule data to obtain a rule result. If the rule result is that the data of the interface to be tested is the same as the rule data, then the data is determined to be a server protocol address; if the rule result is that the data of the interface to be tested is different from the rule data, then the data is determined not to be a server protocol address. In this way, data analysis and processing are performed on all data of the interface to be tested to obtain the multiple server protocol addresses. Among them, the rule data is the composition rule of the server protocol address, for example, it can include the number of digits and the number of symbols; the multiple server protocol addresses refer to two or more server protocol addresses.
[0042] The plurality of associated servers are determined according to the plurality of server protocol addresses. Specifically, one server protocol address corresponds to one associated server, and a corresponding associated server can be determined according to each server protocol address.
[0043] Through the above embodiment, it can be seen that the interface to be tested is analyzed and processed using a preset analysis strategy to obtain multiple server protocol addresses; and the multiple associated servers are determined based on the multiple server protocol addresses. Therefore, the determination of multiple associated servers is achieved through analysis and processing, which improves accuracy.
[0044] S120: Determine a target server from the multiple associated servers according to a preset screening strategy.
[0045] After obtaining multiple associated servers, in order to accurately select a target server that meets the requirements of the interface to be tested and can perform one-end interface simulation testing, it is necessary to screen the target server from the multiple associated servers according to a preset screening strategy.
[0046] In one embodiment, in step S120, determining the target server from the plurality of associated servers according to the preset screening strategy includes:
[0047] performing association processing on the plurality of associated servers to obtain an association graph;
[0048] A search process is performed based on the association graph to determine the target server.
[0049] In this embodiment, the data to be tested can be used to correlate the multiple associated servers to obtain an association graph. Based on the association graph, a search process is performed to determine a server-side interface simulation test, and the server is used as the target server. The association graph is a polygonal relationship connection graph, including vertices and associated edges of the multiple associated servers.
[0050] Through the above embodiment, it can be seen that the association process is performed on multiple associated servers to obtain an association graph; and the search process is performed based on the association graph to determine the target server. Therefore, the target server is quickly obtained through the association process and the search process, ensuring the processing timeliness and improving the processing efficiency.
[0051] S130: Acquire simulation server data, and determine a command line according to the simulation server data.
[0052] In this embodiment, the simulation server data is obtained from the simulation server, and the command line is composed based on the simulation server domain name in the simulation server data. For example, the command line can be curl -fSsL http: / / simulation server domain name / install-mock-agent.sh, where curl -fSsL indicates support for obtaining and executing remote scripts, and install-mock-agent.sh is the simulation agent script.
[0053] S140: Use the command line to pull the simulation proxy script, and mount the simulation proxy script to the target server to form a simulation proxy mechanism.
[0054] In this embodiment, the command line can be run in a command prompt window to pull the simulation proxy script, and the simulation proxy script is directly executed to mount it on the target server to form a simulation proxy mechanism. Therefore, there is no need to introduce JAR packages into the code or perform simulation testing through a gateway, which reduces dependencies and improves test security.
[0055] S150: Obtain service information of the target server, and register the service information to a simulation management platform to configure multiple simulation rules of the interface to be tested.
[0056] In this embodiment, while the simulation proxy script is mounted on the target server to form the simulation proxy mechanism, service information of the target server is obtained and registered with a simulation management platform to configure multiple simulation rules for the interface to be tested. The service information includes data such as the service name, instance information, and the update user; the simulation management platform is installed and applied on the target server.
[0057] In one embodiment, in step S150, that is, registering the service information to the simulation management platform to configure multiple simulation rules of the interface to be tested, includes:
[0058] Registering on the simulation management platform through the service information to obtain a simulation test task;
[0059] Configure based on the simulation test task and the interface to be tested to obtain the test type, simulation matching conditions and response results;
[0060] The test type, the simulation matching condition and the response result constitute each simulation rule.
[0061] In this embodiment, the service information is used to directly register in the simulation management platform to obtain a corresponding simulation test task, and the test type, simulation matching conditions and response results are configured based on the simulation test task and the interface to be tested. The test type, the simulation matching conditions and the response results constitute each simulation rule. Among them, a simulation test task corresponds to multiple simulation rules; each simulation rule includes data such as test type, simulation matching conditions, response results, simulation name and simulation description; the test type refers to the type of data request made by the interface to be tested from the target server to other associated servers among the multiple associated servers except the target server, and can include export request type and import request type; the simulation matching conditions include condition type, request path, request method, query parameters, body parameters and request header data; the response result includes http response code and response data, etc.
[0062] Through the above embodiment, it can be seen that service information is used to register on the simulation management platform to obtain a simulation test task; based on the simulation test task and the interface to be tested, the test type, simulation matching conditions, and response results are configured to form each simulation rule. Therefore, through the registration and configuration process, each simulation rule is obtained, achieving standardized processing of simulation rules and improving testing efficiency.
[0063] S160: Acquire other associated servers except the target server from the multiple associated servers.
[0064] In this embodiment, other associated servers except the target server are obtained from the multiple associated servers, and the multiple associated servers include one target server and multiple other associated servers.
[0065] S170. For the multiple simulation rules, the simulation proxy mechanism is called by the development component to intercept the test request when the target server sends a test request to the other associated servers to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested.
[0066] In this embodiment, the development component is a development framework corresponding to systems or applications in multiple development languages. For example, if the development language is JAVA, the corresponding development component may be jvm-sandbox; a simulation rule corresponds to the target server and one other associated server.
[0067] In one embodiment, step S170, that is, for the multiple simulation rules, using the development component to call the simulation proxy mechanism to intercept the test request when the target server sends the test request to the other associated servers, so as to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested, specifically includes the following steps S171-S173:
[0068] S171, turning on the simulation switch of the target server, and using the development component to call the simulation agent mechanism to load the multiple simulation rules from the simulation management platform;
[0069] S172: When the target server sends the test request to the other associated servers, the simulation proxy mechanism intercepts the test request and performs a matching test on the test request according to the simulation matching condition in each simulation rule to obtain an initial test result.
[0070] S173: Compare the initial test result with the response result to obtain the target test result.
[0071] In this embodiment, if Figure 2 As shown, steps S171-S173 specifically include: after turning on the simulation switch of the target server, using the development component to call the simulation proxy mechanism, that is, injecting the simulation proxy logic in the simulation proxy mechanism into the target server, so as to use the simulation proxy mechanism to load the multiple simulation rules from the simulation management platform; when the target server sends the test request to a corresponding other associated server based on each simulation rule in the multiple simulation rules, the simulation proxy mechanism intercepts the test request, and uses the simulation proxy mechanism to directly match the test request according to the simulation matching conditions in each simulation rule to obtain the initial test result; and compares the initial test result with the response result to obtain the target test result. Wherein, the initial test result includes http response code and / or response data, etc.
[0072] Performing a matching test on the test request according to the simulation matching condition in each simulation rule to obtain an initial test result, specifically including: determining a satisfaction condition based on the condition type; performing a matching test on the condition type, the request method, the Query parameter, the Body parameter and the request header with the test request according to the satisfaction condition to obtain the initial test result; wherein, the satisfaction condition includes satisfying all conditions and satisfying any condition.
[0073] Through the above embodiment, it can be seen that the simulation switch of the target server is turned on, and the simulation proxy mechanism is called by the development component to load the multiple simulation rules from the simulation management platform; when the target server sends the test request to the other associated servers, the simulation proxy mechanism intercepts the test request and performs a matching test process with the test request according to the simulation matching conditions in each simulation rule to obtain an initial test result; the initial test result is compared with the response result to obtain the target test result. Therefore, the standardized processing of interface simulation testing is achieved, and the testing efficiency is improved.
[0074] In one embodiment, after the initial test result and the response result are compared to obtain the target test result, the method includes:
[0075] If the target test result is that the initial test result is the same as the response result, the target server determines that the interface to be tested is normal and stops sending the test request to a corresponding other associated server based on each simulation rule.
[0076] In this embodiment, if the http response code in the initial test result is the same as the http response code in the response result, and / or the response data in the initial test result is the same as the response data in the response result, then the target test result is the same as the initial test result and the response result; if the target test result is the same as the initial test result and the response result, then the target server determines that the interface to be tested is normal, and at this time, stops sending the test request to the corresponding other associated server based on each simulation rule. Therefore, standardized processing of interface simulation testing is achieved, and test efficiency is improved.
[0077] In one embodiment, after the initial test result and the response result are compared to obtain the target test result, the method includes:
[0078] If the target test result is that the initial test result is different from the response result, the target server continues to send the test request to a corresponding other associated server, and the other associated server returns a request result to the target server based on the test request.
[0079] In this embodiment, if the HTTP response code in the initial test result is different from the HTTP response code in the response result, and / or the response data in the initial test result is different from the response data in the response result, then the target test result is different from the initial test result and the response result; if the target test result is different from the initial test result and the response result, then the target server determines that the interface to be tested is abnormal. In this case, the test request is continued to be sent to a corresponding other associated server, and the other associated server returns the request result to the target server based on the test request. Therefore, standardized processing of interface simulation testing is achieved, and testing efficiency is improved.
[0080] To sum up, the embodiment of the present invention uses the command line to directly pull the simulation proxy script, and mounts the simulation proxy script on the target server to form a simulation proxy mechanism. Therefore, there is no need to introduce a jar package in the code or perform simulation testing through a gateway, which reduces dependencies and improves test security. The simulation proxy mechanism is called by the development component to intercept the test request when the target server sends a test request to the other associated servers to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested, thereby realizing standardized processing of interface simulation testing and improving test efficiency.
[0081] Figure 3 Schematic block diagram of the interface simulation test device provided by the embodiment of the present invention. Figure 3 As shown, corresponding to the above interface simulation test method, the present invention also provides an interface simulation test device. Specifically, please refer to Figure 3 , the interface simulation test device 700 includes:
[0082] An analyzing unit 701 is configured to analyze and process the interface to be tested to obtain multiple associated servers;
[0083] A screening unit 702 is configured to determine a target server from the plurality of associated servers according to a preset screening strategy;
[0084] A first acquiring unit 703 is configured to acquire simulation server data and determine a command line according to the simulation server data;
[0085] The mounting unit 704 is configured to use the command line to pull the simulation proxy script and mount the simulation proxy script to the target server to form a simulation proxy mechanism;
[0086] The configuration unit 705 is configured to obtain service information of the target server and register the service information to a simulation management platform to configure multiple simulation rules of the interface to be tested;
[0087] A second acquiring unit 706 is configured to acquire other associated servers except the target server from the plurality of associated servers;
[0088] The test unit 707 is used to use the development component to call the simulation proxy mechanism for the multiple simulation rules so that when the target server sends a test request to the other associated servers, the test request is intercepted to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested.
[0089] In some embodiments, when performing the step of analyzing and processing the interface to be tested to obtain multiple associated servers, the analyzing unit 701 is specifically configured to:
[0090] Performing data analysis on the interface to be tested using a preset analysis strategy to obtain multiple server protocol addresses;
[0091] The plurality of associated servers are determined according to the plurality of server protocol addresses.
[0092] In some embodiments, when performing the step of determining the target server from the multiple associated servers according to the preset screening strategy, the screening unit 702 is specifically configured to:
[0093] performing association processing on the plurality of associated servers to obtain an association graph;
[0094] A search process is performed based on the association graph to determine the target server.
[0095] In some embodiments, when performing the step of registering the service information to the simulation management platform to configure multiple simulation rules of the interface to be tested, the configuration unit 705 is specifically configured to:
[0096] Registering on the simulation management platform through the service information to obtain a simulation test task;
[0097] Configure based on the simulation test task and the interface to be tested to obtain the test type, simulation matching conditions and response results;
[0098] The test type, the simulation matching condition and the response result constitute each simulation rule.
[0099] In some embodiments, when the testing unit 707 executes the step of calling the simulation proxy mechanism using the development component for the multiple simulation rules so that when the target server sends a test request to the other associated servers, intercepting the test request to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested, it is specifically used to:
[0100] Turning on the simulation switch of the target server, and using the development component to call the simulation agent mechanism to load the multiple simulation rules from the simulation management platform;
[0101] When the target server sends the test request to the other associated servers, the simulation proxy mechanism intercepts the test request and performs a matching test on the test request according to the simulation matching condition in each simulation rule to obtain an initial test result;
[0102] The initial test result is compared with the response result to obtain the target test result.
[0103] In some embodiments, after performing the step of comparing the initial test result with the response result to obtain the target test result, the method is further configured to:
[0104] If the target test result is that the initial test result is the same as the response result, the target server determines that the interface to be tested is normal and stops sending the test request to a corresponding other associated server based on each simulation rule.
[0105] In some embodiments, after performing the step of comparing the initial test result with the response result to obtain the target test result, the method is further configured to:
[0106] If the target test result is that the initial test result is different from the response result, the target server continues to send the test request to a corresponding other associated server, and the other associated server returns a request result to the target server based on the test request.
[0107] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned interface simulation test device and each unit can refer to the corresponding description in the aforementioned method embodiment. For the convenience and brevity of description, it will not be repeated here.
[0108] The interface simulation test device can be implemented in the form of a computer program. Figure 4 Runs on the computer equipment shown.
[0109] See also Figure 4 , Figure 4 8 is a schematic block diagram of an electronic device provided by an embodiment of the present invention. The computer device 800 can be a terminal or a server, wherein the terminal can be an electronic device with communication functions. The server can be a standalone server or a server cluster consisting of multiple servers.
[0110] See Figure 4 The electronic device 800 includes a processor 802 , a memory, and a network interface 805 connected via a system bus 801 , wherein the memory may include a non-volatile storage medium 803 and an internal memory 804 .
[0111] The non-volatile storage medium 803 can store an operating system 8031 and a computer program 8032. The computer program 8032 includes program instructions, which, when executed, can enable the processor 802 to perform an interface simulation test method.
[0112] The processor 802 is used to provide computing and control capabilities to support the operation of the entire electronic device 800.
[0113] The internal memory 804 provides an environment for the operation of the computer program 8032 in the non-volatile storage medium 803. When the computer program 8032 is executed by the processor 802, the processor 802 can execute an interface simulation test method.
[0114] The network interface 805 is used to communicate with other devices over the network. Figure 4The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present invention, and does not constitute a limitation on the electronic device 800 to which the solution of the present invention is applied. The specific electronic device 800 may include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0115] The processor 802 is configured to execute a computer program 8032 stored in the memory to implement the following steps:
[0116] Based on the interface to be tested, multiple associated servers are obtained through analysis and processing; a target server is determined from the multiple associated servers according to a preset screening strategy; simulation server data is obtained, and a command line is determined according to the simulation server data; a simulation proxy script is pulled using the command line, and the simulation proxy script is mounted on the target server to form a simulation proxy mechanism; service information of the target server is obtained, and the service information is registered with a simulation management platform to configure multiple simulation rules of the interface to be tested; other associated servers other than the target server are obtained from the multiple associated servers; for the multiple simulation rules, the simulation proxy mechanism is called using a development component to intercept the test request when the target server sends a test request to the other associated servers so as to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested.
[0117] It should be understood that in the embodiment of the present invention, the processor 802 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0118] Those skilled in the art will appreciate that all or part of the steps in the method of the above-described embodiment can be implemented by instructing the relevant hardware through a computer program. The computer program includes program instructions, which can be stored in a storage medium that is computer-readable. The program instructions are executed by at least one processor in the computer system to implement the steps in the method of the above-described embodiment.
[0119] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor performs the following steps:
[0120] Based on the interface to be tested, multiple associated servers are obtained through analysis and processing; a target server is determined from the multiple associated servers according to a preset screening strategy; simulation server data is obtained, and a command line is determined according to the simulation server data; a simulation proxy script is pulled using the command line, and the simulation proxy script is mounted on the target server to form a simulation proxy mechanism; service information of the target server is obtained, and the service information is registered with a simulation management platform to configure multiple simulation rules of the interface to be tested; other associated servers other than the target server are obtained from the multiple associated servers; for the multiple simulation rules, the simulation proxy mechanism is called using a development component to intercept the test request when the target server sends a test request to the other associated servers so as to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested.
[0121] The storage medium may be any computer-readable storage medium that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.
[0122] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0123] In the several embodiments provided herein, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the various units is merely a logical functional division, and actual implementation may employ other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.
[0124] The steps in the methods of the embodiments of the present invention may be adjusted in order, combined, or deleted as needed. The units in the devices of the embodiments of the present invention may be combined, divided, or deleted as needed. Furthermore, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit.
[0125] If this integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, terminal, or network device, etc.) to execute all or part of the steps of the method described in various embodiments of the present invention.
[0126] The above is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims. At the same time, the non-Company software tools or components that appear in the embodiments of the present invention are merely examples and do not represent actual use.
Claims
1. An interface simulation test method, characterized in that: The method comprises: Analyze and process the interface to be tested to obtain multiple associated servers; Determine a target server from the plurality of associated servers according to a preset screening strategy; Acquire simulation server data, and determine a command line according to the simulation server data; Pulling a simulation proxy script using the command line, and mounting the simulation proxy script to the target server to form a simulation proxy mechanism; Acquire service information of the target server, and register the service information to a simulation management platform to configure multiple simulation rules of the interface to be tested; Acquire other associated servers except the target server from the plurality of associated servers; For the multiple simulation rules, the development component is used to call the simulation proxy mechanism to intercept the test request when the target server sends a test request to the other associated servers to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested.
2. The interface simulation test method according to claim 1, characterized in that: Registering the service information to the simulation management platform to configure multiple simulation rules of the interface to be tested includes: Registering on the simulation management platform through the service information to obtain a simulation test task; Configure based on the simulation test task and the interface to be tested to obtain the test type, simulation matching conditions and response results; The test type, the simulation matching condition and the response result constitute each simulation rule.
3. The interface simulation test method according to claim 2, characterized in that: The method of calling the simulation proxy mechanism using a development component for the multiple simulation rules to intercept the test request when the target server sends the test request to the other associated servers, so as to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain a target test result of the interface to be tested includes: Turning on the simulation switch of the target server, and using the development component to call the simulation agent mechanism to load the multiple simulation rules from the simulation management platform; When the target server sends the test request to the other associated servers, the simulation proxy mechanism intercepts the test request and performs a matching test on the test request according to the simulation matching condition in each simulation rule to obtain an initial test result; The initial test result is compared with the response result to obtain the target test result.
4. The interface simulation test method according to claim 3, characterized in that: After the initial test result and the response result are compared to obtain the target test result, the method includes: If the target test result is the same as the initial test result and the response result, the target server determines that the interface to be tested is normal and stops sending the test request to a corresponding other associated server.
5. The interface simulation test method according to claim 4, characterized in that: After the initial test result and the response result are compared to obtain the target test result, the method includes: If the target test result is that the initial test result is different from the response result, the target server continues to send the test request to a corresponding other associated server, and the other associated server returns a request result to the target server based on the test request.
6. The interface simulation test method according to claim 1, characterized in that: The analysis and processing based on the interface to be tested to obtain multiple associated servers includes: Performing data analysis on the interface to be tested using a preset analysis strategy to obtain multiple server protocol addresses; The plurality of associated servers are determined according to the plurality of server protocol addresses.
7. The interface simulation test method according to claim 6, characterized in that: Determining the target server from the plurality of associated servers according to a preset screening strategy includes: performing association processing on the plurality of associated servers to obtain an association graph; A search process is performed based on the association graph to determine the target server.
8. An interface simulation test device, characterized in that: The device comprises: An analysis unit, configured to analyze and process the interface to be tested to obtain multiple associated servers; a screening unit, configured to determine a target server from the plurality of associated servers according to a preset screening strategy; a first acquiring unit, configured to acquire simulation server data and determine a command line according to the simulation server data; A mounting unit, configured to use the command line to pull a simulation proxy script, and mount the simulation proxy script to the target server to form a simulation proxy mechanism; a configuration unit, configured to obtain service information of the target server, register the service information to a simulation management platform, and configure multiple simulation rules of the interface to be tested; A second acquiring unit, configured to acquire other associated servers except the target server from the plurality of associated servers; The test unit is used to use the development component to call the simulation proxy mechanism for the multiple simulation rules so that when the target server sends a test request to the other associated servers, the test request is intercepted to perform corresponding matching test processing on the multiple simulation rules and the test request to obtain the target test result of the interface to be tested.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the interface simulation test method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The storage medium stores a computer program, which includes program instructions. When the program instructions are executed by a processor, the processor executes the interface simulation test method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Interface call test method and device and computer readable storage medium
CN110990205A
Simulation test method, storage medium and electronic equipment
CN117724961A