Data testing system function method, device and related equipment based on production environment
By deploying interface intercept components in a production environment, processing and storing interface call results, the problem of low interface coordination efficiency in system functional testing is solved, real data scenarios are provided, and testing efficiency and quality are improved.
Patent Information
- Application Number
- CN202110412744.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-16
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2041-04-16
AI Technical Summary
Multiple interfaces are needed to coordinate in system functional testing, resulting in inefficient testing and lack of real and reliable data scenarios, which affects the quality of test results.
Deploy interface intercept components in a production environment, intercept and process the interface call results, and store them to the test scenario server, providing a complete data scenario, so that the test environment can directly obtain data from the server, reducing dependence on external interfaces.
It improves the efficiency of system functional testing, provides real and reliable data scenarios, improves the quality of test results, and reduces labor and time costs.
Smart Images

Figure CN112948272B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of system function testing, and in particular to a method, apparatus and related equipment for testing system functions based on data in a production environment. Background Art
[0002] After system development is complete, system functional testing is an essential step. While internal system functional testing can be accomplished through unit testing, inter-system functional testing requires data coordination and the human resources of multiple parties. For example, when testing a system function, multiple interfaces must be called to complete the test. In this case, coordination with the providers of each interface is required to complete the test, which reduces the efficiency of system functional testing.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present invention, and therefore may include information that does not constitute prior art known to ordinary technicians in this field. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a data testing system function method, device and related equipment based on a production environment, which can at least improve the efficiency of system function testing to a certain extent, and can also provide a complete, real and reliable data scenario for subsequent system function testing by intercepting and saving the interface data of the production environment, so as to improve the quality of the test results.
[0005] Other features and advantages of the present invention will become apparent from the following detailed description, or may be learned in part by practice of the present invention.
[0006] According to a first aspect of an embodiment of the present invention, a method for data testing system functions based on a production environment is provided, which is applied to the production environment of the system, and a first interface interception component is deployed in the production environment. The method includes: obtaining an interface configuration table from a test scenario server, and the interface in the interface configuration table is an intercepted interface; when a call occurs in the business logic in the production environment, using the first interface interception component to detect whether the currently called interface is an interface in the interface configuration table; if the currently called interface is an interface in the interface configuration table, using the first interface interception component to process the call return result of the currently called interface; sending the processing result and the ID of the call request to the test scenario server, so that the test scenario server stores the processing result in a database according to the ID of the call request.
[0007] In some embodiments of the present invention, using the first interface interception component to process the call return result of the current call interface includes: using the first interface interception component to serialize the call return result of the current call interface in a preset data format to obtain a character string in a preset format.
[0008] In some embodiments of the present invention, before sending the processing results and the call request ID to the test scenario server, the method also includes: using the first interface interception component to detect whether there is a unique call request ID in the current thread; if there is a unique call request ID, obtaining the call request ID; or if there is no unique call request ID, generating a unique call request ID and obtaining the call request ID.
[0009] According to a second aspect of an embodiment of the present invention, a method for testing system functions based on data in a production environment is provided, which is applied to a test environment of a system, and a second interface interception component is deployed in the test environment. The method includes: obtaining a test scenario configuration table from a test scenario server, the test scenario configuration table containing the id of a business test scenario; configuring the id of the business test scenario in the test scenario configuration table to the current thread; according to the id of the business test scenario in the current thread, querying the test data corresponding to the id of the business test scenario from the database in the test scenario server, the test data being a string serialized by intercepting the data in the production environment by the first interface interception component, the first interface interception component being different from the second interface interception component, and the first interface interception component being deployed in the production environment of the system; using the second interface interception component to process the test data, and using the processing result as the return value; in the test environment, testing the system function based on the return value.
[0010] In some embodiments of the present invention, before querying the test data corresponding to the id of the business test scenario from the database in the test scenario server according to the id of the business test scenario in the current thread, the method also includes: preferentially utilizing the second interface interception component to query the test data corresponding to the id of the business test scenario from the local database according to the id of the business test scenario in the current thread.
[0011] In some embodiments of the present invention, querying the test data corresponding to the ID of the business test scenario from the database in the test scenario server according to the ID of the business test scenario in the current thread includes: sending the ID of the business test scenario in the current thread to the test scenario server through the internal interface of the test environment, so that the test scenario server matches the ID of the call request corresponding to the ID of the business test scenario from the database based on the ID of the business test scenario, and obtains the test data corresponding to the ID of the business test scenario according to the matched ID of the call request, and returns the test data to the test environment; and receiving the test data through the internal interface of the test environment.
[0012] In some embodiments of the present invention, using the second interface interception component to process the test data and using the processing result as the return value includes: using the second interface interception component to deserialize the test data according to the data type of the test data, obtaining the object in the test data, and using the object as the return value.
[0013] According to a third aspect of an embodiment of the present invention, a device for testing system functions based on a data production environment is provided, which is applied to the production environment of the system, and a first interface interception component is deployed in the production environment. The device includes: an interface configuration table acquisition module, which is used to obtain an interface configuration table from a test scenario server, and the interface in the interface configuration table is an intercepted interface; an interface detection module, which uses the first interface interception component to detect whether the currently called interface is an interface in the interface configuration table when a call occurs in the business logic in the production environment; a processing module, which uses the first interface interception component to process the call return result of the currently called interface if the currently called interface is an interface in the interface configuration table; and a sending module, which is used to send the processing result and the ID of the call request to the test scenario server, so that the test scenario server stores the processing result in a database according to the ID of the call request.
[0014] In some embodiments of the present invention, the processing module is configured to: utilize the first interface interception component to serialize the call return result of the current call interface in a preset data format to obtain a character string in the preset format.
[0015] In some embodiments of the present invention, before sending the processing results and the call request ID to the test scenario server, the device also includes: a thread detection module, which uses the first interface interception component to detect whether there is a unique call request ID in the current thread; a request ID acquisition module, which acquires the call request ID if there is a unique call request ID; or if there is no unique call request ID, generates a unique call request ID and acquires the call request ID.
[0016] According to a fourth aspect of an embodiment of the present invention, a device for testing system functions based on data in a production environment is provided, which is applied to a test environment of a system, and a second interface interception component is deployed in the test environment. The device includes: a test scenario configuration table acquisition module, which is used to obtain a test scenario configuration table from a test scenario server, wherein the test scenario configuration table contains the ID of a business test scenario; a configuration module, which is used to configure the ID of the business test scenario in the test scenario configuration table to the current thread; a first query module, which is used to query the database in the test scenario server for test data corresponding to the ID of the business test scenario according to the ID of the business test scenario in the current thread, wherein the test data is a string serialized by intercepting data in the production environment by the first interface interception component, and the first interface interception component is different from the second interface interception component, and the first interface interception component is deployed in the production environment of the system; a processing module, which uses the second interface interception component to process the test data and uses the processing result as a return value; and a testing module, which tests the function of the system based on the return value in the test environment.
[0017] In some embodiments of the present invention, before querying the test data corresponding to the id of the business test scenario from the database in the test scenario server according to the id of the business test scenario in the current thread, the device also includes: a second query module, which is used to preferentially utilize the second interface interception component to query the test data corresponding to the id of the business test scenario from the local database according to the id of the business test scenario in the current thread.
[0018] In some embodiments of the present invention, the first query module is configured to: send the ID of the business test scenario in the current thread to the test scenario server through the internal interface of the test environment, so that the test scenario server matches the ID of the call request corresponding to the ID of the business test scenario from the database based on the ID of the business test scenario, and obtains the test data corresponding to the ID of the business test scenario according to the matched ID of the call request, and returns the test data to the test environment; and receives the test data through the internal interface of the test environment.
[0019] In some embodiments of the present invention, the processing module is configured to: utilize the second interface interception component to deserialize the test data according to the data type of the test data, obtain the object in the test data, and use the object as the return value.
[0020] According to a fifth aspect of an embodiment of the present invention, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for data testing system functions based on a production environment as described in the first aspect of the above embodiment or the method for data testing system functions based on a production environment as described in the second aspect.
[0021] According to the sixth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for the data testing system function based on the production environment as described in the first aspect of the above embodiment or the method for the data testing system function based on the production environment as described in the second aspect is implemented.
[0022] The technical solution provided by the embodiment of the present invention may have the following beneficial effects:
[0023] In the technical solution provided by some embodiments of the present invention, an interface configuration table is obtained from a test scenario server. When a call is made to the business logic in the production environment, a first interface interception component is used to detect whether the currently called interface is an interface in the interface configuration table. If the currently called interface is an interface in the interface configuration table, the first interface interception component is used to process the call return result of the currently called interface, and the processing result is stored in the test scenario server according to the ID of the call request. In this way, when the system function is subsequently tested, there is no need to coordinate multiple external interfaces to call data. It is only necessary to obtain data from the test scenario server through the internal interface of the test environment, thereby improving the efficiency of the system function test. Moreover, by intercepting and saving the interface data of the production environment, a complete, real and reliable data scenario can be provided for the subsequent system function test, so that the quality of the test results is higher.
[0024] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present invention, and together with the specification, are used to explain the principles of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and those skilled in the art can derive other drawings based on these drawings without inventive effort. In the drawings:
[0026] Figure 1 A schematic diagram showing an exemplary system architecture to which a method for testing system functions based on data in a production environment or an apparatus for testing system functions based on data in a production environment according to an embodiment of the present invention may be applied;
[0027] Figure 2 A flowchart of a method for testing system functions based on data in a production environment according to an embodiment of the present invention is schematically shown;
[0028] Figure 3 A flowchart schematically illustrates a method for testing system functions based on data in a production environment according to another embodiment of the present invention;
[0029] Figure 4 Schematically shows a flow chart of a method for testing system functions based on data in a production environment in a test environment according to an embodiment of the present invention;
[0030] Figure 5 A flowchart schematically illustrates a method for testing system functions based on data in a production environment in a test environment according to another embodiment of the present invention;
[0031] Figure 6 A block diagram schematically illustrates an apparatus for testing system functions based on data in a production environment according to an embodiment of the present invention;
[0032] Figure 7 A block diagram schematically illustrates an apparatus for testing system functions based on data in a production environment according to another embodiment of the present invention;
[0033] Figure 8 A block diagram schematically illustrates an apparatus for testing system functions based on data in a production environment in a test environment according to an embodiment of the present invention;
[0034] Figure 9 A block diagram schematically illustrates an apparatus for testing system functions based on data in a production environment in a test environment according to another embodiment of the present invention;
[0035] Figure 10 A schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0036] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art.
[0037] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, it will be appreciated by those skilled in the art that the technical solutions of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.
[0038] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0039] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0040] Figure 1 A schematic diagram shows an exemplary system architecture to which a method for testing system functions based on data in a production environment or an apparatus for testing system functions based on data in a production environment according to an embodiment of the present invention may be applied.
[0041] like Figure 1 As shown, the system architecture may include a production environment server 100, a test environment server 200, and a test scenario server 300. The production environment server 100 is deployed with the system's production environment, the test environment server 200 is deployed with the system's test environment, and the test scenario server 300 contains a pre-configured test scenario configuration table and an interface configuration table. The test scenario server 300 also contains a production environment data table for storing production environment data intercepted from the production environment.
[0042] In some embodiments of the present invention, interface interception components are configured in the production environment server 100 and the test environment server 200. For example, a first interface interception component is configured in the business project of the production environment server 100 to intercept production environment data. In another example, a second interface interception component is configured in the business project of the test environment server 200 to parse the intercepted production environment data. The first interface interception component and the second interface interception component are different.
[0043] In some embodiments of the present invention, after the system is online in the production environment server 100, an interface configuration table can be obtained from the test scenario server 300. The interface in the interface configuration table is the intercepted interface. When the business logic of the production environment server 100 is called, the first interface interception component is used to detect whether the currently called interface is an interface in the interface configuration table. If the currently called interface is an interface in the interface configuration table, the first interface interception component is used to process the call return result of the currently called interface; the processing result and the ID of the call request are sent to the test scenario server 300, so that the test scenario server 300 stores the processing result in the production environment data table of the test scenario server 300 according to the ID of the call request. In this way, when the system function is subsequently tested, there is no need to coordinate multiple external interfaces to call data. It is only necessary to obtain data from the test scenario server 300 through the internal interface of the test environment, thereby improving the efficiency of the system function test. Moreover, by intercepting and saving the interface data of the production environment, a complete, real and reliable data scenario can be provided for the subsequent system function test, so that the quality of the test result is higher.
[0044] In some embodiments of the present invention, if the currently called interface is an interface in the interface configuration table, a first interface interception component is used to intercept the call return result of the currently called interface. For example, the interception method can be aspect interception based on the local engineering class, or it can be interface interception based on the microservice. Specifically, the interface interception includes an AOP interceptor (by default, intercepting the service package path) implemented or passed by a filter based on the microservice RPC interface (by default, intercepting all interfaces).
[0045] In some embodiments of the present inventors, after the system development is completed, the system can complete the function test in the test environment server 200. For example, a test scenario configuration table is obtained from the test scenario server 300, and the test scenario configuration table contains the id of the business test scenario. The id of the business test scenario in the test scenario configuration table is configured in the current thread. According to the id of the business test scenario in the current thread, the test data corresponding to the id of the business test scenario is queried from the database in the test scenario server 300. In this way, calling the test data does not require coordinating with multiple interface providers, saving time and manpower costs. The test data is then processed and the processing result is used as a return value. In the test environment server 200, the function of the system is tested based on the return value, thereby improving the testing efficiency of the system function. In this embodiment, the above-mentioned test data is a string of data serialized by intercepting the data in the production environment through the first interface interception component.
[0046] In some embodiments of the present inventors, when testing the system functions in the test environment server 300, the second interface interception component can be preferentially used to load the local test data of the test scenario server 300 to test the system functions. The local test data can be pre-customized.
[0047] In some embodiments of the present invention, the production environment server 100 can be used to implement Figure 2 and Figure 3 The test environment server 200 can be used to implement the method of testing system functions based on data from the production environment. Figure 4 and Figure 5 Describes a method for testing system functionality based on production environment data.
[0048] Figure 2 The flowchart of the method for testing system functions based on data of a production environment according to an embodiment of the present invention is schematically shown.
[0049] like Figure 2 As shown, the method for testing system functions based on data in a production environment may include steps S210 to S240.
[0050] In step S210, an interface configuration table is obtained from the test scenario server, where the interfaces in the interface configuration table are intercepted interfaces.
[0051] In step S220, when a call is made to the business logic in the production environment, the first interface interception component is used to detect whether the currently called interface is an interface in the interface configuration table.
[0052] In step S230, if the currently called interface is an interface in the interface configuration table, the first interface interception component is used to process the call return result of the currently called interface.
[0053] In step S240 , the processing result and the ID of the calling request are sent to the test scenario server, so that the test scenario server stores the processing result in a database according to the ID of the calling request.
[0054] The method can obtain an interface configuration table from a test scenario server. When a call is made to the business logic in the production environment, the first interface interception component is used to detect whether the currently called interface is an interface in the interface configuration table. If the currently called interface is an interface in the interface configuration table, the first interface interception component is used to process the call return result of the currently called interface, and the processing result is stored in the test scenario server according to the ID of the call request. In this way, when the system function is subsequently tested, there is no need to coordinate multiple external interfaces to call data. It is only necessary to obtain data from the test scenario server through the internal interface of the test environment, thereby improving the efficiency of the system function test. Moreover, by intercepting and saving the interface data of the production environment, a complete, real and reliable data scenario can be provided for subsequent system function testing, so that the quality of the test results is higher.
[0055] In some embodiments of the present invention, the interface configuration table can be pre-configured based on actual business testing requirements. The interface configuration table is used to store intercepted interfaces. For example, the intercepted interface can be a call interface for a production environment. In this embodiment, the configured interface configuration table can be distributed to the project of the first interface interception component. The interface configuration format is: [full class name.interface / method name…].
[0056] In some embodiments of the present invention, when a call is made to business logic in a production environment, a first interface interception component is used to detect whether the currently called interface is an interface in an interface configuration table. For example, when a call is made to business logic in a production environment, the first interface interception component is used to match an interface identifier that is identical to the identifier of the currently called interface from the interface configuration table. If the match is successful, the first interface interception component intercepts the call result of the currently called interface.
[0057] In some embodiments of the present invention, processing the call return result of the current call interface using the first interface interception component includes: using the first interface interception component to serialize the call return result of the current call interface in a preset data format to obtain a string in the preset format. For example, using the first interface interception component to serialize the return object of the current call interface in JSON format to obtain a string in JSON format. In this example, the preset data format can be set according to actual circumstances.
[0058] In some embodiments of the present invention, the processing result and the ID of the call request are sent to the test scenario server so that the test scenario server stores the processing result in a database according to the ID of the call request. For example, the processing result is a string in the above-mentioned json format, and the string in the json format and the ID of the call request are printed in a log. Through a log collector, a log containing the string in the json format and the ID of the call request is sent to the test scenario server. When the test scenario server receives the log, it parses it to obtain the string in the json format and the ID of the call request. The test scenario server uses the ID of the call request as the business primary key and stores the string in the json format in the mysql database, which facilitates subsequent query and use of the data in the mysql database when testing system functions.
[0059] Figure 3 The flowchart of a method for testing system functions based on data of a production environment according to another embodiment of the present invention is schematically shown.
[0060] like Figure 3 As shown, before step S240, the method further includes step S310 and step S320.
[0061] In step S310, the first interface interception component is used to detect whether there is a unique call request id in the current thread.
[0062] In step S320, if there is a unique calling request ID, the calling request ID is obtained; or if there is no unique calling request ID, a unique calling request ID is generated and the calling request ID is obtained.
[0063] This method can use the first interface interception component to detect whether there is a unique call request ID in the current thread. If there is a unique call request ID, the call request ID is obtained; or if there is no unique call request ID, a unique call request ID is generated and the call request ID is obtained. This makes it convenient to obtain test data from the above-mentioned MySQL database according to the test scenario ID that is the same as the unique call request ID when testing the system function later, thereby ensuring the accuracy of the data.
[0064] In one embodiment of the present invention, the system functions can be tested according to normal unit testing or overall testing functions. If coverage condition testing or regression testing is required for different scenarios, the global business test scenario ID can be reset as needed.
[0065] In one embodiment of the present invention, by intercepting a specific interface in the production environment, a data set can be generated based on the unique ID of the call request. This complete data set is then used as a test scenario for interface simulation and regression testing in the development environment. This improves test quality and efficiency.
[0066] Figure 4 The flowchart of the method for testing system functions based on data of a production environment in a test environment according to an embodiment of the present invention is schematically shown.
[0067] like Figure 4 As shown, the method for testing system functions based on data in a production environment in a test environment includes steps S410 to S450.
[0068] In step S410, a test scenario configuration table is obtained from the test scenario server, where the test scenario configuration table includes the ID of the business test scenario.
[0069] In step S420, the id of the business test scenario in the test scenario configuration table is configured into the current thread.
[0070] In step S430, according to the id of the business test scenario in the current thread, the test data corresponding to the id of the business test scenario is queried from the database in the test scenario server.
[0071] In step S440, the second interface interception component is used to process the test data, and the processing result is used as the return value.
[0072] In step S450 , in a test environment, the functionality of the system is tested based on the return value.
[0073] This method can obtain a test scenario configuration table from a test scenario server, configure the id of the business test scenario in the test scenario configuration table to the current thread, and query the test data corresponding to the id of the business test scenario from the database in the test scenario server according to the id of the business test scenario in the current thread. In this way, calling test data does not require coordinating multiple interface providers, saving time and manpower costs. The test data is then processed and the processing result is used as the return value. In the test environment, the system function is tested based on the return value, thereby improving the testing efficiency of the system function.
[0074] In one embodiment of the present invention, the test scenario configuration table can be configured based on actual service requests. For example, the test scenario ID in the test scenario configuration table can be set to the same ID as the call request ID used to call service data. This allows the test scenario ID to be matched to the same call request ID in the MySQL database of the test scenario server, thereby retrieving test data from the MySQL database based on the call request ID.
[0075] In one embodiment of the present invention, the ID of the business test scenario in the test scenario configuration table is configured in the current thread. For example, when testing system functions in a test environment, the preset test scenario ID is configured in the system runtime environment, that is, the test scenario ID is configured in the current thread to declare the test scenario.
[0076] In one embodiment of the present invention, based on the ID of the business test scenario in the current thread, the test data corresponding to the business test scenario ID is retrieved from the database of the test scenario server. For example, in a test environment, when calling an external or internal interface, the second interface interception component may first query whether there is a local matching data file, and then query the test scenario server for data based on the business test scenario ID in the current thread. If data is found, the test data is deserialized according to the interface return type, and the generated object is used as the return value, without performing a normal interface / method call.
[0077] In one embodiment of the present invention, the above test data is a string serialized by intercepting data in the production environment through a first interface interception component. The first interface interception component is different from the second interface interception component. The first interface interception component is deployed in the production environment of the system.
[0078] In some embodiments of the present invention, before querying the test data corresponding to the id of the business test scenario from the database in the test scenario server according to the id of the business test scenario in the current thread, the method also includes: preferentially using the second interface interception component to query the test data corresponding to the id of the business test scenario from the local database according to the id of the business test scenario in the current thread. For example, when calling an external interface or an internal interface, the second interface interception component can preferentially query whether there is a local matching data file based on the id of the business test scenario in the current thread. If the match is successful, the system function is tested based on the local test data, which further speeds up the test efficiency. In this embodiment, local test data can be written according to the actual test requirements, and then the written test data is stored in the local default storage path. For example, the written json file is stored in the local disk according to the default classpath path. Local test data is used to supplement or replace the data in the test scenario server. The naming format of the locally configured test data file is [full name of the class.interface / method].
[0079] In some embodiments of the present invention, using the second interface interception component to process the test data and using the processing result as the return value includes: using the second interface interception component to deserialize the test data according to the data type of the test data, obtaining the object in the test data, and using the object as the return value.
[0080] Figure 5 The flowchart schematically shows a method for testing system functions based on data of a production environment in a test environment according to another embodiment of the present invention.
[0081] like Figure 5 As shown, the above step S430 may specifically include step S510 and step S520.
[0082] In step S510, the id of the business test scenario in the current thread is sent to the test scenario server through the internal interface of the test environment, so that the test scenario server matches the id of the call request corresponding to the id of the business test scenario from the database based on the id of the business test scenario, and obtains the test data corresponding to the id of the business test scenario according to the matched id of the call request, and returns the test data to the test environment.
[0083] In step S520, test data is received through an internal interface of the test environment.
[0084] This method can call test data for test system functions through the internal interface of the test environment without relying on external interfaces, and developers do not need to coordinate with multiple interface providers. This simplifies the testing process and improves testing efficiency.
[0085] In some embodiments of the present invention, when testing system functions, the second interface interception component is preferentially used to load locally pre-configured test data. If no test data is matched locally, the id of the business test scenario in the current thread is sent to the test scenario server based on the interface inside the test environment, so that the test scenario server matches the id of the call request corresponding to the id of the business test scenario from the database based on the id of the business test scenario (for example, the id of the business test scenario is the same as the id of the call request), and obtains the test data corresponding to the id of the business test scenario based on the matched call request id, and returns the test data to the test environment. In this way, the call results of different interfaces can be simulated, and no longer rely heavily on external systems and environments.
[0086] Figure 6 The block diagram schematically shows an apparatus for testing system functions based on data in a production environment according to an embodiment of the present invention.
[0087] like Figure 6 As shown, the device 600 for testing system functions based on data in a production environment includes an interface configuration table acquisition module 610 , an interface detection module 620 , a processing module 630 and a sending module 640 .
[0088] Specifically, the interface configuration table acquisition module 610 is used to acquire an interface configuration table from the test scenario server, where the interfaces in the interface configuration table are intercepted interfaces.
[0089] The interface detection module 620 uses the first interface interception component to detect whether the currently called interface is an interface in the interface configuration table when a call is made to the business logic in the production environment.
[0090] Processing module 630, if the currently called interface is an interface in the interface configuration table, uses the first interface interception component to process the call return result of the currently called interface.
[0091] The sending module 640 is used to send the processing result and the ID of the calling request to the test scenario server, so that the test scenario server stores the processing result in the database according to the ID of the calling request.
[0092] The device 600 for testing system functions based on data in a production environment can obtain an interface configuration table from a test scenario server. When a call is made to the business logic in the production environment, the first interface interception component is used to detect whether the currently called interface is an interface in the interface configuration table. If the currently called interface is an interface in the interface configuration table, the first interface interception component is used to process the call return result of the currently called interface, and the processing result is stored in the test scenario server according to the ID of the call request. In this way, when the system function is subsequently tested, there is no need to coordinate multiple external interfaces to call data. It is only necessary to obtain data from the test scenario server through the internal interface of the test environment, thereby improving the efficiency of system function testing. Moreover, by intercepting and saving the interface data of the production environment, a complete, real and reliable data scenario can be provided for subsequent system function testing, making the quality of the test results higher.
[0093] According to an embodiment of the present invention, the device 600 for testing system functions based on data in a production environment can be used to implement Figure 2 The embodiment describes a method for testing system functions in a production environment based on data in the production environment.
[0094] In one embodiment of the present invention, the processing module 630 is configured to: utilize the first interface interception component to serialize the call return result of the current call interface in a preset data format to obtain a character string in the preset format.
[0095] Figure 7 A block diagram schematically shows an apparatus for testing system functions based on data in a production environment according to another embodiment of the present invention.
[0096] like Figure 7 As shown, the apparatus 600 for testing system functions based on data in a production environment may further include a thread detection module 650 and a request ID acquisition module 660 .
[0097] Specifically, the thread detection module 650 uses the first interface interception component to detect whether there is a unique call request id in the current thread.
[0098] The request ID acquisition module 660 acquires the ID of the call request if there is a unique call request ID; or generates a unique call request ID and acquires the ID of the call request if there is no unique call request ID.
[0099] The device 600 for testing system functions based on data in a production environment can use the first interface interception component to detect whether there is a unique call request ID in the current thread. If there is a unique call request ID, the call request ID is obtained; or if there is no unique call request ID, a unique call request ID is generated and the call request ID is obtained. This makes it convenient to obtain test data from the above-mentioned MySQL database according to the test scenario ID that is the same as the unique call request ID when testing the system function, thereby ensuring the accuracy of the data.
[0100] According to an embodiment of the present invention, the device 600 for testing system functions based on data in a production environment can be used to implement Figure 3 The embodiment describes a method for testing system functions in a production environment based on data in the production environment.
[0101] Since each module of the apparatus 600 for testing system functions based on data in a production environment according to an exemplary embodiment of the present invention can be used to implement the above 2 to Figure 3 The steps of an example embodiment of a method for testing the functions of a data test system based on a production environment are described. Therefore, for details not disclosed in the embodiment of the device of the present invention, please refer to the above-mentioned embodiment of the method for testing the functions of a data test system based on the production environment applied in a production environment of the present invention.
[0102] It is understood that the interface configuration table acquisition module 610, the interface detection module 620, the processing module 630, the sending module 640, the thread detection module 650, and the request ID acquisition module 660 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present invention, at least one of the interface configuration table acquisition module 610, the interface detection module 620, the processing module 630, the sending module 640, the thread detection module 650, and the request ID acquisition module 660 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented in hardware or firmware in any other reasonable way of integrating or packaging the circuit, or in an appropriate combination of software, hardware, and firmware. Alternatively, at least one of the interface configuration table acquisition module 610, the interface detection module 620, the processing module 630, the sending module 640, the thread detection module 650, and the request ID acquisition module 660 can be at least partially implemented as a computer program module, and when the program is run by a computer, the functions of the corresponding module can be executed.
[0103] Figure 8 The block diagram schematically shows an apparatus for testing system functions based on data in a production environment in a test environment according to an embodiment of the present invention.
[0104] like Figure 8 As shown, the apparatus 800 for testing system functions based on data in a production environment in a test environment may include a test scenario configuration table acquisition module 810 , a configuration module 820 , a first query module 830 , a processing module 840 and a testing module 850 .
[0105] Specifically, the test scenario configuration table acquisition module 810 is configured to acquire a test scenario configuration table from a test scenario server, where the test scenario configuration table includes the ID of the business test scenario.
[0106] The configuration module 820 is used to configure the ID of the business test scenario in the test scenario configuration table into the current thread.
[0107] The first query module 830 is used to query the test data corresponding to the ID of the business test scenario from the database in the test scenario server according to the ID of the business test scenario in the current thread. The test data is a string serialized by intercepting the data in the production environment through the first interface interception component. The first interface interception component is different from the second interface interception component. The first interface interception component is deployed in the production environment of the system.
[0108] The processing module 840 uses the second interface interception component to process the test data and uses the processing result as a return value.
[0109] The test module 850 tests the functionality of the system based on the return value in the test environment.
[0110] The device 800 for testing system functions based on data in a production environment in a test environment can obtain a test scenario configuration table from a test scenario server, configure the id of the business test scenario in the test scenario configuration table to the current thread, and query the test data corresponding to the id of the business test scenario from the database in the test scenario server according to the id of the business test scenario in the current thread. In this way, calling the test data does not require coordinating with multiple interface providers, saving time and manpower costs, and then processing the test data, and using the processing result as a return value. In the test environment, the function of the system is tested based on the return value, thereby improving the testing efficiency of the system function.
[0111] According to an embodiment of the present invention, the apparatus 800 for testing system functions based on data in a production environment in a test environment can be used to implement Figure 4 The embodiment describes a method for testing system functions based on data from a production environment in a test environment.
[0112] In some embodiments of the present invention, the first query module 830 is configured to: send the ID of the business test scenario in the current thread to the test scenario server through the internal interface of the test environment, so that the test scenario server matches the ID of the call request corresponding to the ID of the business test scenario from the database based on the ID of the business test scenario, and obtains the test data corresponding to the ID of the business test scenario according to the matched ID of the call request, and returns the test data to the test environment; and receives the test data through the internal interface of the test environment.
[0113] In some embodiments of the present invention, the processing module 840 is configured to: utilize the second interface interception component to deserialize the test data according to the data type of the test data, obtain the object in the test data, and use the object as the return value.
[0114] Figure 9The block diagram schematically shows an apparatus for testing system functions based on data of a production environment in a test environment according to another embodiment of the present invention.
[0115] like Figure 9 As shown, the apparatus 800 for testing system functions based on data in a production environment in a test environment may further include a second query module 860 .
[0116] Specifically, the second query module 860 is configured to preferentially utilize the second interface interception component to query the test data corresponding to the ID of the business test scenario from the local database according to the ID of the business test scenario in the current thread.
[0117] The device 800 for testing system functions based on production environment data in a test environment can first query whether there is a local matching data file based on the ID of the business test scenario in the current thread. If a match is successful, the system function is tested based on the local test data, which further speeds up the test efficiency.
[0118] Since each module of the apparatus 800 for testing system functions based on data in a production environment in a test environment according to an exemplary embodiment of the present invention can be used to implement the above 4~ Figure 5 The steps of an example embodiment of the method for testing the functions of a data test system based on a production environment in a test environment are described. Therefore, for details not disclosed in the embodiment of the device of the present invention, please refer to the above-mentioned embodiment of the method for testing the functions of a data test system based on a production environment in a test environment of the present invention.
[0119] It is understandable that the test scenario configuration table acquisition module 810, the configuration module 820, the first query module 830, the processing module 840, the test module 850, and the second query module 860 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present invention, at least one of the test scenario configuration table acquisition module 810, the configuration module 820, the first query module 830, the processing module 840, the test module 850, and the second query module 860 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented in hardware or firmware in any other reasonable way of integrating or packaging the circuit, or in an appropriate combination of software, hardware, and firmware. Alternatively, at least one of the test scenario configuration table acquisition module 810, the configuration module 820, the first query module 830, the processing module 840, the test module 850, and the second query module 860 can be at least partially implemented as a computer program module, and when the program is run by a computer, the function of the corresponding module can be executed.
[0120] Reference below Figure 10 , which shows a schematic structural diagram of a computer system 1000 of an electronic device suitable for implementing an embodiment of the present invention. Figure 10 The computer system 1000 of the electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention.
[0121] like Figure 10 As shown, computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage unit 1008 into a random access memory (RAM) 1003. Various programs and data required for system operation are also stored in RAM 1003. CPU 1001, ROM 1002, and RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to bus 1004.
[0122] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output section 1007 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 1008 including a hard disk; and a communication section 1009 including a network interface card such as a LAN card or a modem. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1010 as needed, so that computer programs read therefrom can be installed into the storage section 1008 as needed.
[0123] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1009 and / or installed from a removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present application are performed.
[0124] It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.
[0125] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0126] The units involved in the embodiments of the present invention may be implemented in software or hardware, and the units described may also be provided in a processor. In some cases, the names of these units do not limit the units themselves.
[0127] As another aspect, the present application further provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or may exist independently and not be incorporated into the electronic device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device implements the method described in the above embodiments for use in a production environment based on the data testing system function of the production environment, or the method for use in a test environment based on the data testing system function of the production environment.
[0128] For example, the electronic device can implement Figure 4 As shown in: In step S410, a test scenario configuration table is obtained from the test scenario server, and the test scenario configuration table contains the ID of the business test scenario. In step S420, the ID of the business test scenario in the test scenario configuration table is configured in the current thread. In step S430, based on the ID of the business test scenario in the current thread, the test data corresponding to the ID of the business test scenario is queried from the database in the test scenario server. In step S440, the second interface interception component is used to process the test data, and the processing result is used as the return value. In step S450, in the test environment, the function of the system is tested based on the return value.
[0129] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.
[0130] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present invention.
[0131] Other embodiments of the present invention will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the invention being indicated by the following claims.
[0132] It should be understood that the present invention is not limited to the exact construction 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 invention is limited only by the appended claims.
Claims
1. A method for testing system functions based on data from a production environment, applied to a system's production environment, characterized in that: A first interface interception component is deployed in the production environment, and the method includes: Obtain an interface configuration table from the test scenario server, where the interface in the interface configuration table is an intercepted interface, and the intercepted interface is a calling interface of the production environment; When the business logic in the production environment is called, the first interface interception component is used to detect whether the currently called interface is an interface in the interface configuration table; If the currently called interface is an interface in the interface configuration table, using the first interface interception component to process the call return result of the currently called interface; The processing result and the id of the calling request are sent to the test scenario server, so that the test scenario server stores the processing result in the database according to the id of the calling request, wherein the id is the unique id of the calling request in the current thread, wherein the processing result is used to obtain test data from the database according to the test scenario id that is the same as the unique calling request id when testing the system function.
2. The method according to claim 1, characterized in that Using the first interface interception component to process the call return result of the current call interface includes: The first interface interception component is used to serialize the call return result of the current calling interface in a preset data format to obtain a character string in a preset format.
3. The method according to claim 1, characterized in that Before sending the processing result and the ID of the calling request to the test scenario server, the method further includes: Using the first interface interception component to detect whether there is a unique call request id in the current thread; If there is a unique call request id, the call request id is obtained; or if there is no unique call request id, a unique call request id is generated and the call request id is obtained.
4. A method for testing system functions based on data from a production environment, applied to a system test environment, characterized in that: A second interface interception component is deployed in the test environment, and the method includes: Obtaining a test scenario configuration table from a test scenario server, wherein the test scenario configuration table includes an ID of a business test scenario; Configure the id of the business test scenario in the test scenario configuration table to the current thread; According to the id of the business test scenario in the current thread, query the test data corresponding to the id of the business test scenario from the database in the test scenario server, wherein the test data is a string obtained by serializing the data in the production environment intercepted by a first interface interception component, the first interface interception component is different from the second interface interception component, and the first interface interception component is deployed in the production environment of the system; Using the second interface interception component to process the test data, and using the processing result as a return value; In the test environment, the function of the system is tested based on the return value.
5. The method according to claim 4, characterized in that Before querying the test data corresponding to the ID of the business test scenario from the database in the test scenario server according to the ID of the business test scenario in the current thread, the method further includes: The second interface interception component is preferentially used to query the test data corresponding to the id of the business test scenario from the local database according to the id of the business test scenario in the current thread.
6. The method according to claim 4, characterized in that According to the id of the business test scenario in the current thread, querying the test data corresponding to the id of the business test scenario from the database in the test scenario server includes: Sending the id of the business test scenario in the current thread to the test scenario server through the internal interface of the test environment, so that the test scenario server matches the id of the call request corresponding to the id of the business test scenario from the database based on the id of the business test scenario, and obtains the test data corresponding to the id of the business test scenario according to the matched call request id, and returns the test data to the test environment; and The test data is received through an internal interface of the test environment.
7. The method according to claim 4, characterized in that The test data is processed by using the second interface interception component, and the processing result is used as a return value including: The second interface interception component is used to deserialize the test data according to the data type of the test data, obtain the object in the test data, and use the object as the return value.
8. A device for testing system functions based on data from a production environment, applied to a system production environment, characterized in that: A first interface interception component is deployed in the production environment, and the device includes: An interface configuration table acquisition module is used to acquire an interface configuration table from a test scenario server, wherein the interface in the interface configuration table is an intercepted interface, and the intercepted interface is a calling interface of a production environment; An interface detection module, when a call is made to the business logic in the production environment, uses the first interface interception component to detect whether the currently called interface is an interface in the interface configuration table; A processing module, if the currently called interface is an interface in the interface configuration table, uses the first interface interception component to process the call return result of the currently called interface; A sending module is used to send the processing result and the ID of the calling request to the test scenario server, so that the test scenario server stores the processing result in the database according to the ID of the calling request, and the ID is the unique ID of the calling request in the current thread, wherein the processing result is used to obtain test data from the database according to the test scenario ID that is the same as the unique calling request ID when testing the system function.
9. A device for testing system functions based on data from a production environment, applied to a system test environment, characterized in that: A second interface interception component is deployed in the test environment, and the device includes: A test scenario configuration table acquisition module, used to acquire a test scenario configuration table from a test scenario server, wherein the test scenario configuration table includes an ID of a business test scenario; A configuration module, used to configure the id of the business test scenario in the test scenario configuration table into the current thread; A first query module is used to query the test data corresponding to the ID of the business test scenario from the database in the test scenario server according to the ID of the business test scenario in the current thread, wherein the test data is a string obtained by serializing the data in the production environment intercepted by the first interface interception component, the first interface interception component is different from the second interface interception component, and the first interface interception component is deployed in the production environment of the system; A processing module, using the second interface interception component to process the test data, and using the processing result as a return value; A test module tests the function of the system based on the return value in the test environment.
10. An electronic device, comprising: one or more processors; as well as A storage device, used to store one or more programs, when the one or more programs are executed by the one or more processors, enables the one or more processors to implement the method according to any one of claims 1 to 3 or the method according to any one of claims 4 to 7.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 or the method according to any one of claims 4 to 7 is implemented.
Citation Information
Patent Citations
Interface testing method and device, computer device and storage medium
CN109446063A
Regression test method and device, electronic equipment and storage medium
CN112380115A