Functional service testing method, system and terminal device

By obtaining baffle rules on the client and intercepting test requests locally, the problem of low efficiency of functional service testing in the existing technology is solved, and efficient testing is achieved when dependent services are not provided or have not been developed.

CN113238886BActive Publication Date: 2024-09-27WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110515691.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-12
Publication Date
2024-09-27
Estimated Expiration
2041-05-12

AI Technical Summary

Technical Problem

Existing baffle testing technology cannot test functional services when other services on which the functional services depend are not provided or have not been fully developed, resulting in low testing efficiency.

Method used

By obtaining the baffle rules on the client and intercepting the test request locally, parsing the request parameters and generating test results, it avoids sending the test request to the baffle server.

Benefits of technology

It improves the efficiency of functional service testing, reduces network transmission delay, can still complete testing when other services that functional services depend on are not provided or have not been fully developed, and improves the shortcomings of traditional baffle testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113238886B
    Figure CN113238886B
Patent Text Reader

Abstract

The present invention relates to the field of financial technology, and discloses a testing method, system, and terminal device for functional services. The testing method for functional services obtains baffle rules for the functional services through a client, wherein the baffle rules are configured in a baffle server connected to the client; intercepts a test request initiated for the functional service, and parses the test request to obtain request parameters; compares the request parameters locally according to the baffle rules to generate a test result. Compared with the method of performing functional service testing based on the traditional baffle testing technology—mock server, the present invention can improve the defect that the traditional baffle test cannot simulate the baffle to complete the functional service test, and improves the test efficiency of testing the functional service.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of financial technology (Fintech), and in particular to a testing method, system and terminal device for functional services. Background Art

[0002] With the development of computer technology, more and more technologies are being applied in the financial field. Traditional finance is gradually transforming into financial technology. However, due to the security, real-time and stability requirements of the financial industry, higher requirements are also placed on technology.

[0003] At present, functional service testing of applications or systems in the process of development or upgrading is mostly based on baffle testing (also known as mock testing, mock testing is a testing method in which a virtual object is used to create some objects that are not easy to construct or obtain for testing during the testing process) technology. However, since the current baffle testing technology simulates service objects outside the application or system to be tested, there is a mutual dependency between the functional service of the application or system to be tested and other services. However, if one or more of the other services do not provide external services or have not yet completed development (if the development is not completed, the baffle testing technology cannot create virtual objects), the baffle testing technology cannot be used to test the functional service. Summary of the invention

[0004] The main purpose of the present invention is to provide a testing method, apparatus, terminal equipment, computer storage medium and computer program product for functional services, aiming to improve the testing efficiency of functional service testing based on baffle testing technology.

[0005] To achieve the above object, the present invention provides a method for testing a functional service, which is applied to a client and includes:

[0006] Acquire a baffle rule of the functional service, wherein the baffle rule is configured in a baffle server connected to the client;

[0007] Intercepting a test request initiated for the functional service, and parsing the test request to obtain request parameters;

[0008] The request parameters are compared locally according to the baffle rules to generate a test result.

[0009] In addition, to achieve the above object, the present invention further provides a method for testing a functional service, the method for testing a functional service is applied to a baffle server, the baffle server is connected to the client as described above, and the method for testing a functional service includes:

[0010] Generating a baffle rule for the functional service according to preset rule configuration data, wherein the rule configuration data is received based on a graphical user interface;

[0011] Obtaining client information transmitted by the client;

[0012] The baffle rule is pushed to the client according to the client information, so that the client can locally generate a test result corresponding to the test request according to the baffle rule, wherein the test request is initiated for the functional service.

[0013] In addition, to achieve the above-mentioned purpose, the present invention further provides a functional service testing system, the functional service testing system comprising a client, the client comprising:

[0014] A first acquisition module, used for acquiring a baffle rule of the functional service, wherein the baffle rule is configured in a baffle server connected to the client;

[0015] An interception module, used to intercept the test request initiated for the functional service, and parse the test request to obtain request parameters;

[0016] A test module, used for locally comparing the request parameters according to the baffle rule to generate a test result;

[0017] The functional service testing system further includes a baffle service end, and the baffle service end includes:

[0018] A rule configuration module, configured to generate a baffle rule for the functional service according to preset rule configuration data, wherein the rule configuration data is received based on a graphical user interface;

[0019] A second acquisition module, used to acquire the client information transmitted by the client;

[0020] A rule push module is used to push the baffle rule to the client according to the client information, so that the client can locally generate a test result corresponding to the test request according to the baffle rule, wherein the test request is initiated for the functional service.

[0021] Among them, each functional module of the functional service testing system of the present invention implements the steps of the functional service testing method described above during operation.

[0022] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal device, which includes: a memory, a processor, and a test program for functional services stored in the memory and executable on the processor, and the test program for the functional services, when executed by the processor, implements the steps of the test method for the functional services as described above.

[0023] In addition, to achieve the above objectives, the present invention also provides a computer storage medium, on which a test program for a functional service is stored, and when the test program for the functional service is executed by a processor, the steps of the test method for the functional service as described above are implemented.

[0024] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the testing method of the functional service described above are implemented.

[0025] The present invention provides a method, system, terminal device, computer storage medium and computer program product for testing a functional service, wherein baffle rules of the functional service are obtained through a client, wherein the baffle rules are configured in a baffle server connected to the client; a test request initiated for the functional service is intercepted, and the test request is parsed to obtain request parameters; and the request parameters are compared locally according to the baffle rules to generate a test result.

[0026] When the present invention performs functional service testing on an application or system in the process of development or upgrading, the present invention obtains the baffle rules configured in the baffle server connected to the client through a client loaded with the functional service, and then directly intercepts the test request initiated by the test staff for the functional service locally, and parses the test request to obtain relevant request parameters. Finally, the corresponding test result is directly generated after comparing the request parameters locally according to the obtained baffle rules.

[0027] Compared with the functional service testing method based on the traditional baffle testing technology - mock server, the present invention does not need to send the test request for the functional service to be tested to the baffle server. Therefore, even if other services that the functional service depends on do not provide external services or are not fully developed, the entire test process for the functional service to be tested can be completed directly on the client side, thereby improving the defect that the traditional baffle test cannot simulate the baffle to complete the functional service test, and improving the test efficiency of the functional service test.

[0028] In addition, since the testing methods for the functional services of the present invention are all executed locally on the client, that is, the comparison process of the baffle rules and the generation and output of the test results are all on the local end where the functional service to be tested is installed, there is no need to send additional test requests for the functional service, thereby reducing or even avoiding the impact of network transmission delays on functional service testing, further improving test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A schematic diagram of the device structure of the hardware operating environment of the terminal device involved in the embodiment of the present invention;

[0030] Figure 2 A schematic flow chart of a first embodiment of a test method serving the functions of the present invention;

[0031] Figure 3 A schematic diagram of an application scenario involved in an embodiment of a test method for serving the functions of the present invention;

[0032] Figure 4 A schematic diagram of an application flow involved in an embodiment of a test method for serving the functions of the present invention;

[0033] Figure 5 Another application flow diagram of an embodiment of a test method serving the functions of the present invention;

[0034] Figure 6 A schematic diagram of another application flow involved in an embodiment of a test method serving the functions of the present invention;

[0035] Figure 7 A graphical user interface involved in an embodiment of a test method for serving the functions of the present invention;

[0036] Figure 8 A schematic diagram of functional modules of an embodiment of a test system serving the functions of the present invention.

[0037] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0038] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0039] Reference Figure 1 , Figure 1 The present invention is a schematic diagram of the device structure of the hardware operating environment of the terminal device involved in the embodiment of the present invention.

[0040] The terminal device of the embodiment of the present invention can be a client device loaded with the functional service that needs to be tested, or, the terminal device of the embodiment of the present invention can also be a baffle server device specifically used to test the functional service and thus configure relevant baffle rules. The device can be a smart phone, PC (Personal Computer), tablet computer, portable computer, etc.

[0041] like Figure 1 As shown, the terminal device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed RAM memory, or it may be a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.

[0042] Those skilled in the art will understand that Figure 1 The terminal device structure shown in the figure does not constitute a limitation on the terminal device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0043] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a test program for functional services.

[0044] exist Figure 1 In the terminal shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client and communicate data with the client; and the processor 1001 can be used to call the test program of the functional service stored in the memory 1005, and execute the various embodiments of the following functional service testing method.

[0045] Based on the above hardware structure, various embodiments of the testing method of the functional service of the present invention are proposed.

[0046] It should be noted that, currently, functional service testing for applications or systems in the process of development or upgrading is mostly based on the baffle testing technology. However, since the current baffle testing technology simulates the service objects outside the application or system to be tested, for example, refer to the attached Figure 3 In the application scenario shown, when the execution of the functional service A to be tested needs to rely on the execution of the external function B or the external function C, and the execution of the external function C needs to rely on the joint execution of the external function D and the external function E, the traditional mock server needs to simulate the external function B, the external function C, the external function D and the external function E for calling when testing the functional service A.

[0047] However, when there is a mutual dependency between the functional service of the application or system to be tested and other services, but one or more of its other services do not provide external services or have not yet been developed (for example, in the above example, external function D and external function E have not yet been developed), the traditional baffle testing technology cannot simulate the one or more services for the functional service to be tested to call, and thus the baffle testing technology cannot be used to perform the testing process of the functional service. Therefore, the testing efficiency of functional service testing based on traditional baffle testing technology still needs to be improved.

[0048] In view of the above phenomenon, the present invention provides a method for testing functional services. Figure 2 , Figure 2 This is a flow chart of a first embodiment of a method for testing a functional service of the present invention. In this embodiment, the method for testing a functional service is applied to the client device loaded with the functional service to be tested. The method for testing a functional service includes:

[0049] Step S10, obtaining a baffle rule of the functional service, wherein the baffle rule is configured in a baffle server connected to the client;

[0050] It should be noted that, in the present embodiment, the baffle rules of the functional service to be tested are obtained by configuring the baffle server device connected to the current client device, and the baffle server device provides a graphical user interface for the testing staff, so that the baffle server device receives the rule configuration data input by the testing staff for testing the functional service to be tested based on the graphical user interface, and then generates the baffle rules according to the rule configuration data.

[0051] After the baffle server device configures and generates baffle rules for testing the functional service to be tested, the client device directly obtains the baffle rules from the baffle server device and directly stores the baffle rules locally.

[0052] Specifically, for example, the client device establishes an HTTP (Hypertext Transfer Protocol) network connection or an RMB (Reliable Message Bus) type communication connection with the baffle server device, thereby pulling the baffle rules configured and generated for testing the functional service to be tested from the baffle server device through the HTTP network connection or the RMB communication connection, and then directly stores the baffle rules locally for subsequent calls.

[0053] Furthermore, in a feasible embodiment, the above step S10 may include:

[0054] Step S101, when it is detected that the functional service is started, the baffle rule configured for the functional service is obtained from the baffle server, and the baffle rule is stored in a local cache.

[0055] After the client device installs the functional service to be tested, it continuously monitors whether the functional service is triggered to start. When it detects that the functional service is triggered to start, it starts to generate baffle rules for testing the functional service from the baffle server device or the baffle server device configuration, and directly stores the baffle rules locally.

[0056] Specifically, for example, please refer to Figure 5 As shown in the application flow diagram, after the client device establishes an HTTP network connection or RMB communication connection with the baffle server device and locally downloads and installs the functional service to be tested (it is assumed that the baffle server device has also locally configured and generated baffle rules for testing the functional service at this time), the client device continuously monitors whether the system triggers a startup instruction for the functional service based on the tester's operation, so that when the client device detects the startup instruction to start running the functional service (the illustrated application system), the client device also synchronously queries the baffle rules that have been configured and generated from the baffle server device through the HTTP network connection or RMB communication connection established with the baffle server device (the illustrated mock-admin), and further queries the baffle rules for the target baffle rules belonging to the functional service installed on the current client device, and finally, pulls the target baffle rules and directly stores the target baffle rules in the cache (SDK) of the local running functional service for subsequent calls.

[0057] Furthermore, in a feasible embodiment, before the above step S10, the testing method of the functional service of the present invention may further include:

[0058] Step S40, collecting client information, and transmitting the client information to the baffle server, so that the baffle server pushes the baffle rules according to the client information.

[0059] It should be noted that, in the present embodiment, the client information is information provided to the baffle server device, and the baffle server actively pushes the baffle rules according to the client information. For example, the client information may specifically be IP (Internet Protocol) address information and communication port information. It should be understood that, based on different design requirements of actual applications, in different feasible implementation methods, the client information may of course also be other information other than the IP address information and communication port information listed in the present embodiment, but which can also play the above-mentioned role. The testing method of the functional service of the present invention is not limited to the specific type of the client information.

[0060] After establishing a communication connection with the baffle server device, the client device begins to collect client information locally for providing to the baffle server device, and the baffle server actively pushes the baffle rules. Then, the client device uploads the client information to the baffle server device so that the baffle server device can actively push the baffle rules to the client device after configuring and generating baffle rules for testing the functional services to be tested, and the client device directly stores the baffle rules locally.

[0061] Specifically, for example, after the client device establishes an HTTP network connection or an RMB communication connection with the baffle server device, it begins to collect IP address information and communication port information locally, and transmits the collected IP address information and communication port information to the baffle server device through the HTTP network connection or the RMB communication connection. Thus, the baffle server device can, after configuring and generating baffle rules for the functional service to be tested, actively push the baffle rules to the client device on a regular basis according to the IP address information and the communication port information. After receiving the baffle rules, the client device also directly stores the baffle rules locally for subsequent calls.

[0062] It should be noted that, in this embodiment, the baffle server device locally configures and generates baffle rules for testing the functional service to be tested based on the received rule configuration data. That is, the baffle server device receives the rule configuration data for configuring the baffle rules for the functional service to be tested input by the test staff through the graphical user interface output by the front-end screen to the test staff, and then immediately locally configures and generates the baffle rules according to the rule configuration data.

[0063] Specifically, for example, the graphical user interface output by the front screen of the baffle server device to the test staff may be as shown in the attached figure. Figure 7 For the graphical user interface shown, please refer to Figure 4 In the application process, any of the multiple baffle server devices (mock-admin in the figure) receives a login request that is accessed after being diverted based on nginx (Nginx (engine x) is a high-performance HTTP and reverse proxy web server that also provides IMAP / POP3 / SMTP services) technology, and then allows the corresponding test staff to log in based on the login request, and then outputs the attached information to the test staff through the front-end screen. Figure 7 The graphical user interface shown, whereby the baffle server receives the rule configuration data input by the test staff based on the graphical user interface to configure the conditions and return values ​​of the baffle rules (i.e., when the request parameter a=1 in the test request, it returns "true", otherwise, it returns "false"), thereby generating baffle rules (mock rules).

[0064] Step S20, intercepting a test request initiated for the functional service, and parsing the test request to obtain request parameters;

[0065] After obtaining the baffle rules for testing the functional service to be tested from the baffle server device, the client device further monitors the test request for the functional service triggered by the test staff, intercepts the test request while monitoring the test request, and parses the test request to obtain the request parameters.

[0066] Specifically, for example, please refer to Figure 6 As shown in the application flow diagram, after the client device pulls the baffle rules generated by the baffle server device for the functional service (application system) to be tested from the baffle server device and stores the baffle rules in the cache (SDK) of the local running of the functional service (application system), the client device begins to monitor the test requests (user requests shown in the figure) initiated by the test staff (system users shown in the figure) for the functional service (application system) based on test needs. After monitoring the test request (user request), the client device immediately intercepts the test request (user request) in the local cache (SDK) and parses it to obtain the request parameters.

[0067] It should be noted that, in this embodiment, the client device intercepts the test request initiated for the functional service to be tested based on spring aop technology (Spring: Spring framework is an open source application framework and a lightweight container for managing the life cycle of JAVA objects; AOP: Aspect Oriented Programming, aspect-oriented programming, is mainly used to solve some system-level problems in program development, and adds some additional functions without changing the original logic).

[0068] Specifically, since the test request initiated by the test staff for the functional service to be tested is transmitted to the baffle server device through the http network connection or RMB communication connection established between the client device and the baffle server device if it is not intercepted, all requests for the functional service can be intercepted by pre-intercepting the http or RMB receiving request entrance in the local cache - mock-sdk where the baffle rules are stored using spring aop technology. Using spring aop technology, a proxy object is dynamically generated during the startup of the functional service. The proxy object adds the code of the mock rules stored in the cache - mock-sdk to the original code. In this way, when a request for the functional service is received, the client device will also execute the code of the mock rule, thereby realizing the interception of the request and the corresponding mock function (comparing the parsed request parameters with the baffle rules).

[0069] Step S30: locally compare the request parameters according to the baffle rule to generate a test result.

[0070] After the client device stores the baffle rules for the functional service to be tested obtained from the baffle server device locally, and intercepts the test request initiated for the functional service and parses the request parameters, the client device directly compares the request parameters with the baffle rules locally to generate a test result of the test request for the functional service, and outputs the test result through the graphical user interface of the service request to the test staff.

[0071] Furthermore, in a feasible embodiment, the above step S30 may include:

[0072] Step S301, traversing the baffle rules in the local cache;

[0073] Step S302: In the process of traversing the baffle rules, the request parameters are compared with the baffle rules to dynamically generate a test result.

[0074] The client device traverses the baffle rules to be tested in the local cache, and compares the traversed baffle rules with the parsed request parameters one by one, and uses the response value obtained from the comparison as the test result of the test request for the functional service, and finally outputs the test result directly locally through the service request to the graphical user interface of the test staff.

[0075] It should be noted that, in the present embodiment, the baffle rules generated by the baffle server device based on the rule configuration data input by the test staff are configured to simulate the response values ​​corresponding to the services on which the functional services to be tested depend. For example, the baffle server device is configured during the configuration of a baffle rule: "When the request parameter A=1, return "success"; when the request parameter A=2, return "failure". In this way, the "request parameter A=1" and "request parameter A=2" in the configuration process are the baffle rules, and the corresponding "return success" and "return failure" are the response values.

[0076] Specifically, for example, please refer to Figure 6 In the application flow diagram shown, after the client device intercepts the test request (user request) in the local cache (SDK) and parses the request parameters to obtain the request parameters, it immediately starts to traverse the baffle rules (mock rules) obtained from the baffle server device in the local cache (SDK), and when each rule is traversed, the rule is compared with the request parameters, so that when the request parameters recorded in the rule are compared to the parsed request parameters, the response value corresponding to the request parameters recorded in the rule is immediately encapsulated into the test result of the current test request based on the groovyshell (Groovy: an agile dynamic language for Java virtual machines, which is a mature object-oriented programming language that can be used for object-oriented programming and can be used as a scripting language) language. The test result for the functional service (application system) to be tested is directly generated locally. In addition, after the client device dynamically generates the test result based on the groovyshell language, it further outputs the test result through the graphical user interface of the functional service (application system) facing the test staff (system user) output on the front screen.

[0077] It should be noted that, in this embodiment, the client device dynamically generates test results based on the groovyshell language as follows: the groovyshell language executes the java bytecode syntax requirements based on the java virtual machine, and dynamically generates a java class according to the java bytecode syntax requirements for the baffle rules configured in the baffle server device - mock-admin, and then compiles the java class into a java bytecode file and loads it into the virtual machine, so that the java virtual machine can return the test result after comparing the request parameters with the baffle rules after execution, so as to directly respond to the client device front end with the test result.

[0078] The embodiment of the present invention provides a method for testing a functional service, wherein after a baffle rule for testing a functional service to be tested is generated by a client device on a baffle server device, the baffle rule is directly obtained from the baffle server device and directly stored locally; after the client device obtains the baffle rule for testing the functional service to be tested from the baffle server device, the client device further monitors a test request for the functional service triggered by a testing staff, intercepts the test request when monitoring the test request, and parses the test request to obtain request parameters; after the client device stores the baffle rule for the functional service to be tested obtained from the baffle server device locally, intercepts the test request initiated for the functional service and parses to obtain request parameters, the client device directly compares the request parameter with the baffle rule locally to generate a test result of the test request for the functional service, and outputs the test result through the service request to a graphical user interface for the testing staff.

[0079] Compared with the functional service testing method based on the traditional baffle testing technology - mock server, the present invention does not need to send the test request for the functional service to be tested to the baffle server. Therefore, even if other services that the functional service depends on do not provide external services or are not fully developed, the entire test process for the functional service to be tested can be completed directly on the client side, thereby improving the defect that the traditional baffle test cannot simulate the baffle to complete the functional service test, and improving the test efficiency of the functional service test.

[0080] In addition, since the testing methods for the functional services of the present invention are all executed locally on the client, that is, the comparison process of the baffle rules and the generation and output of the test results are all on the local end where the functional service to be tested is installed, there is no need to send additional test requests for the functional service, thereby reducing or even avoiding the impact of network transmission delays on functional service testing, further improving test efficiency.

[0081] Further, based on the above first embodiment, a second embodiment of the test method of the functional service of the present invention is proposed. The main difference between this embodiment and the above first embodiment is that in this embodiment, in addition to storing the baffle rules obtained from the baffle server device in the local cache (SDK), the client device can also store the baffle rules in a local fixed memory. The test method of the functional service of the present invention can also include:

[0082] Step S50, storing the baffle rule in a local memory, and updating the baffle rule according to a preset first time period;

[0083] It should be noted that, in this embodiment, the local memory is the internal storage space of the client device for stably storing system files, in addition to the cache (SDK) occupied by each running of the functional service.

[0084] After the client device obtains the baffle rules generated by the baffle server device for testing the functional service to be tested from the baffle server device, the client device further stores the baffle rules in the local internal storage space for stable storage of system files. Therefore, when it is subsequently monitored that the functional service is triggered to start based on the operation of the test staff and a test request initiated by the test staff for the functional service is received, the baffle rules are directly traversed from the local internal storage space to compare the traversed baffle rules with the request parameters obtained by parsing the test request to obtain a response value, and then the response value is directly encapsulated into a test result locally for output.

[0085] In addition, it should be noted that in the present embodiment, the preset first time period is the time period based on which the client device updates the baffle rules stored in the local memory. It should be understood that based on the different design needs of actual applications, in different feasible embodiments, the client device can of course use time periods of different sizes to update the locally stored baffle rules. The testing method of the functional service of the present invention is not limited to the specific size of the preset first time period.

[0086] After the client device pulls all the baffle rules from the baffle server device to the local internal storage space for storage, since the baffle server device may modify the configured baffle rules, delete the original baffle rules, or add new baffle rules based on the new rule configuration data input by the tester, in order to ensure that the locally stored baffle rules are consistent with the baffle rules configured by the baffle server device, the client device obtains all the baffle rules from the baffle server device again at a certain time period (a preset first time period), and then uses the newly obtained baffle rules to update the locally stored baffle rules, that is, add and store new baffle rules, replace the modified baffle rules, and / or delete the baffle rules that exist in the locally stored baffle rules but do not exist in the newly obtained baffle rules.

[0087] Furthermore, in another feasible embodiment, the testing method of the functional service of the present invention may also include:

[0088] Configure and generate baffle rules for the functional services to be tested in local memory.

[0089] The client device receives the rule configuration data for the functional service to be tested locally from the test staff, directly configures and generates baffle rules in the local internal storage space, and stores the baffle rules in a system configuration file that can be extracted by the client device running system. In this way, when the client device subsequently monitors that the functional service is triggered to start based on the operation of the test staff and receives the test request initiated by the test staff for the functional service, it directly extracts the system configuration file from the local internal storage space to traverse the baffle rules, and compares the traversed baffle rules with the request parameters obtained by parsing the test request to obtain a response value, and then directly encapsulates the response value into a test result locally for output.

[0090] In this embodiment, the baffle rules obtained from the baffle server device are stored in the local internal storage space for stable storage of system files through the client device, or the rule configuration data for the functional service to be tested by the test staff is directly received locally through the client device, so as to generate the baffle rules locally according to the rule configuration data, and the baffle rules are stored in the system configuration file that can be extracted by the client device running system. Therefore, when it is subsequently monitored that the functional service is triggered to start based on the operation of the test staff, and a test request initiated by the test staff for the functional service is received, the baffle rules are traversed directly from the local internal storage space to compare the traversed baffle rules with the request parameters obtained by parsing the test request to obtain a response value, and then the response value is directly encapsulated into a test result locally for output.

[0091] In this way, when an abnormality occurs in the communication connection between the client device and the baffle server device, so that the baffle rules cannot be pulled when the functional service to be tested starts running, or when the baffle server device fails to run, the client device can still compare the test requests for the functional service locally based on the baffle rules previously pulled and stored in the internal storage space or directly configured in the internal storage space to generate test results, thereby ensuring that the test for the functional service can proceed smoothly and further improving the test efficiency.

[0092] Further, based on the above-mentioned first and second embodiments, a third embodiment of a method for testing a functional service of the present invention is proposed. The main difference between this embodiment and the above-mentioned first and second embodiments is that, in the above-mentioned step S20, after intercepting the test request initiated for the functional service, the method for testing the functional service of the present invention may further include:

[0093] Step A, detecting whether the test request is the same as the original test request;

[0094] It should be noted that, in the present embodiment, each time the client device locally intercepts a test request for the functional service to be tested, parses the request parameters and traverses the baffle rules for comparison to generate a test result, the intercepted test request and the generated test result are associated and stored in the local cache (SDK) and / or internal storage space. The original test request described in the present embodiment is the test request stored by the client device in the cache (SDK) and / or internal storage space and associated with the corresponding test result.

[0095] Each time the client device intercepts a test request initiated by the test staff for the functional service to be tested, the test request is compared with the original test request that is pre-stored in the local cache and / or internal storage space and is associated with the corresponding test result to detect whether the test request is the same as the original test request.

[0096] Specifically, for example, after the client device intercepts the test request initiated by the test staff for the functional service to be tested based on the spring aop technology, the client device immediately compares the test request with the original test request stored in the local cache (SDK) and / or internal storage space in association with the test results, that is, compares whether the request parameters of the test request are the same as the request parameters of the original test request, and when the two request parameters are the same, it is determined that the test request is the same as the original test request.

[0097] Step B: If yes, then the original test result corresponding to the original test request is locally indexed, and the original test result is fed back as the test result corresponding to the test request.

[0098] When the client device detects that the newly intercepted test request is the same as the original test request, it directly uses the test result associated with the original test request pre-stored in the local cache and / or internal storage space as the test result corresponding to the current newly intercepted test request, and outputs the test result to the graphical user interface of the test staff through the current service request to be tested.

[0099] Specifically, for example, when the client device compares the request parameters of the newly intercepted test request and finds that they are the same as the request parameters of the original test request, and thus determines that the test request is the same as the original test request, the client device directly extracts the test result associated with the original test request from the local cache (SDK) and / or internal storage space, and uses the test result as the test result corresponding to the newly intercepted test request, so as to output the test result through the graphical user interface (GUI) of the functional service for test staff output on the front screen of the client device.

[0100] It should be noted that, because each time the client device executes the baffle rule locally based on GroovyShell, even the same baffle rule will repeatedly generate a bytecode file, and then load the bytecode file on the Java virtual machine for execution. Therefore, if multiple mock operations are performed on the same test request (comparing the parameters of the rule and the request to obtain the response value), the files generated by using GroovyShell will increase, affecting the overall performance of the client device.

[0101] Based on this, in this embodiment, after the client device intercepts each test request initiated by the test staff for the functional service to be tested, the test request is compared with the original test request pre-stored in the local cache and / or internal storage space and associated with the corresponding test result to detect whether the test request is the same as the original test request; when the client device detects that the newly intercepted test request is the same as the original test request, it directly uses the test result pre-stored in the local cache and / or internal storage space and associated with the original test request as the test result corresponding to the current newly intercepted test request, and outputs the test result to the graphical user interface of the test staff through the current service request to be tested. In this way, it avoids GroovyShell from repeatedly generating too many files locally, effectively guarantees the overall performance of the client device, and further improves the test efficiency of the test operation for the functional service to be tested installed on the client device.

[0102] Furthermore, the present invention also provides a method for testing a functional service, which is applied to the baffle service end described in the above embodiments, and comprises the following steps:

[0103] Step S60, generating a baffle rule for the functional service according to preset rule configuration data, wherein the rule configuration data is received based on a graphical user interface;

[0104] It should be noted that, in the present embodiment, the rule configuration data is the data input by the testing staff into the baffle server device for configuring the baffle rules based on the testing needs of the functional service to be tested. It should be understood that based on the different design needs of the actual application, in different feasible implementation methods, the data input by the testing staff for configuring the baffle rules may of course be different. The testing method for the functional service of the present invention is not limited to the specific content of the rule configuration data.

[0105] The baffle server device receives the rule configuration data for configuring baffle rules for the functional service to be tested input by the test staff through a graphical user interface output by the front-end screen to the test staff, and then immediately generates new baffle rules locally according to the rule configuration data or updates the pre-configured baffle rules.

[0106] Specifically, for example, the graphical user interface output by the front screen of the baffle server device to the test staff may be as shown in the attached figure. Figure 7 For the graphical user interface shown, please refer to Figure 4 In the application process, any of the multiple baffle server devices (mock-admin in the figure) receives a login request that is accessed after being diverted based on nginx (Nginx (engine x) is a high-performance HTTP and reverse proxy web server that also provides IMAP / POP3 / SMTP services) technology, and then allows the corresponding test staff to log in based on the login request, and then outputs the attached information to the test staff through the front-end screen. Figure 7 The graphical user interface shown in the figure, so that the baffle server receives the rule configuration data input by the test staff based on the graphical user interface: 1) Baffle (mock) type: based on http network connection or based on RMB communication connection, 2) Mock path: the test request initiation path of the functional service to be tested that needs to perform mock operation, such as the interception interface address - http: / / 127.0.0.1:8080 / mock / test, and, 3), mock rules: conditions and return values, that is, when the request parameter a in the test request = 1, it returns "true", otherwise, it returns "false".

[0107] Step S70, obtaining client information transmitted by the client;

[0108] Before, during, or after configuring and generating the baffle rules for the functional service to be tested, the baffle server device acquires the client information transmitted by the client device through a communication connection established with the client device on which the functional service is installed.

[0109] It should be noted that, in the present embodiment, the client information is information used by the baffle server to actively push baffle rules according to the client information. For example, the client information may specifically be IP (Internet Protocol) address information and communication port information. It should be understood that, based on different design requirements of actual applications, in different feasible implementation methods, the client information may of course also be other information other than the IP address information and communication port information listed in the present embodiment, but which can also play the above-mentioned role. The testing method of the functional service of the present invention is not limited to the specific type of the client information.

[0110] Specifically, for example, after the client device establishes an HTTP network connection or an RMB communication connection with the baffle server device, it starts to collect IP address information and communication port information locally, and transmits the collected IP address information and communication port information to the baffle server device through the HTTP network connection or the RMB communication connection.

[0111] Step S80: Pushing the baffle rule to the client according to the client information, so that the client can locally generate a test result corresponding to the test request according to the baffle rule, wherein the test request is initiated for the functional service.

[0112] After receiving the client information transmitted by the client device, the baffle server device pushes the baffle rules for the functional service to be tested generated locally to the client device according to the client information, so that the client device directly intercepts the test request for the functional service triggered by the test staff locally, and after parsing the test request to obtain the request parameters, traverses the baffle rules to compare the request parameters, and then generates the test result of the test request for the functional service, and outputs the test result to the graphical user interface of the test staff through the service request.

[0113] Specifically, for example, please refer to Figure 4In the application process shown, the baffle server device (mock-admin) locally configures and generates baffle rules based on the rule configuration data input by the test staff, and after establishing an HTTP network connection or RMB communication connection with the client device (illustrated application system) that locally downloads and installs the functional service to be tested, among all the baffle rules that have been configured and generated, based on the IP address information and communication port information of the client device, queries the target baffle rules belonging to the functional service installed on the client device, and finally, actively pushes the target baffle rules to the client device or automatically pulls the target baffle rules by the client device, so that the client device can store the target baffle rules in the cache (SDK) that runs the functional service locally, and use them to call and generate test results when a test request for the functional service is intercepted.

[0114] Further, in a feasible embodiment, in the above step S80, the step of "pushing the baffle rule to the client according to the client information" may include:

[0115] Step S801, determining a new baffle rule after updating the baffle rule;

[0116] It should be noted that, in this embodiment, the baffle server device will modify the configured baffle rules to obtain new baffle rules, delete the original baffle rules, or add new baffle rules based on the rule configuration data newly input by the tester.

[0117] Each time the baffle server device pushes baffle rules to the client device, it detects all baffle rules locally in advance, and modifies the already configured baffle rules based on the new rule configuration data input by the tester to obtain new baffle rules and add new baffle rules.

[0118] Specifically, for example, each time the baffle server device modifies the already configured baffle rules based on the new rule configuration data input by the tester to obtain a new baffle rule, or each time a new baffle rule is locally configured based on the new rule configuration data, a specific identifier is added to the new baffle rule. Thus, each time the baffle server device pushes the baffle rule to the client device, it can detect the new baffle rule carrying the specific identifier among all the local baffle rules through the specific identifier.

[0119] Step S802: Push the new baffle rule to the client according to a preset second time period.

[0120] It should be noted that, in the present embodiment, the preset second time period is the time period for the baffle server device to push the new local baffle rules to the client device, so that the client device can update the pre-pulled baffle rules. It should be understood that based on the different design needs of actual applications, in different feasible embodiments, the baffle server device can of course use time periods of different sizes to push the new local baffle rules. The testing method of the functional service of the present invention is not limited to the specific size of the preset second time period.

[0121] The baffle server device detects all the baffle rules locally, modifies the already configured baffle rules based on the new rule configuration data input by the tester to obtain new baffle rules, and after adding the configured new baffle rules, pushes the new baffle rules to the client device through the communication connection established with the client device on which the functional service is installed, so that the client device directly intercepts the test request for the functional service triggered by the test staff locally, and after parsing the test request to obtain the request parameters, traverses the baffle rules to compare the request parameters, and then forms a test result for the test request for the functional service, and outputs the test result to the graphical user interface of the test staff through the service request.

[0122] In this embodiment, the baffle server device receives rule configuration data for configuring baffle rules for the functional service to be tested input by the testing staff through a graphical user interface output through a front-end screen, and then immediately locally configures and generates new baffle rules or updates the pre-configured baffle rules according to the rule configuration data; before, at the same time, or after configuring and generating baffle rules for the functional service to be tested, the baffle server device obtains the client information transmitted by the client device through a communication connection established with a client device on which the functional service is installed; after receiving the client information transmitted by the client device, the baffle server device pushes the baffle rules for the functional service to be tested generated in the local configuration to the client device according to the client information, so that the client device directly intercepts the test request for the functional service triggered by the testing staff locally, and after parsing the test request to obtain the request parameters, traverses the baffle rules to compare the request parameters, thereby forming a test result of the test request for the functional service, and outputs the test result through the graphical user interface of the service request to the testing staff.

[0123] Compared with the functional service testing method based on the traditional baffle testing technology - mock server, the present invention does not need to send the test request for the functional service to be tested to the baffle server. Therefore, even if other services that the functional service depends on do not provide external services or are not fully developed, the entire test process for the functional service to be tested can be completed directly on the client side, thereby improving the defect that the traditional baffle test cannot simulate the baffle to complete the functional service test, and improving the test efficiency of the functional service test.

[0124] Furthermore, the present invention also provides a functional service testing system, the functional service testing system comprising a client. Figure 8 , Figure 8 A schematic diagram of the functional modules of an embodiment of a test system serving the functions of the present invention. Figure 8 As shown, the client includes:

[0125] A first acquisition module 10 is used to acquire a baffle rule of the functional service, wherein the baffle rule is configured in a baffle server connected to the client;

[0126] The interception module 20 is used to intercept the test request initiated for the functional service and parse the test request to obtain request parameters;

[0127] A test module 30, configured to compare the request parameters locally according to the baffle rule to generate a test result;

[0128] The test system for the functional service of the present invention also includes a baffle service end, such as Figure 8 As shown, the baffle service end includes:

[0129] A rule configuration module 40, configured to generate a baffle rule for the functional service according to preset rule configuration data, wherein the rule configuration data is received based on a graphical user interface;

[0130] A second acquisition module 50 is used to acquire the client information transmitted by the client;

[0131] The rule push module 60 is used to push the baffle rule to the client according to the client information, so that the client can locally generate a test result corresponding to the test request according to the baffle rule, wherein the test request is initiated for the functional service.

[0132] Furthermore, the rule push module 60 includes:

[0133] A determination unit, configured to determine a new baffle rule after updating the baffle rule;

[0134] A pushing unit is used to push the new baffle rule to the client according to a preset second time period.

[0135] Furthermore, the first acquisition module 10 is further configured to acquire the baffle rule configured for the functional service from the baffle server when detecting that the functional service is started, and store the baffle rule in a local cache.

[0136] Furthermore, the test module 30 includes:

[0137] A rule traversal unit, used for traversing the baffle rules in the local cache;

[0138] The result generating unit is used for comparing the request parameter with the baffle rule in the process of traversing the baffle rule to dynamically generate a test result.

[0139] Furthermore, the testing system of the functional service of the present invention further includes:

[0140] A storage module, used for storing the baffle rule in a local memory and updating the baffle rule according to a preset first time period;

[0141] The test module 30 is further configured to traverse the baffle rules in the local memory, and in the process of traversing the baffle rules, compare the request parameters with the baffle rules to dynamically generate a test result.

[0142] Furthermore, the testing system of the functional service of the present invention further includes:

[0143] A detection unit, used to detect whether the test request is the same as the original test request;

[0144] The result feedback unit is used to locally index the original test result corresponding to the original test request, and feed back the original test result as the test result corresponding to the test request.

[0145] Furthermore, the testing system of the functional service of the present invention further includes:

[0146] The information collection module is used to collect client information and transmit the client information to the baffle server so that the baffle server can push the baffle rules according to the client information.

[0147] Among them, the functional implementation of each module in the test system of the above-mentioned functional service corresponds to the various steps in the embodiment of the test method of the above-mentioned functional service, and its functions and implementation processes will not be repeated here one by one.

[0148] The present invention also provides a computer storage medium storing a test program for a functional service. When the test program for the functional service is executed by a processor, the steps of the test method for the functional service described in any of the above embodiments are implemented.

[0149] The specific embodiments of the computer storage medium of the present invention are basically the same as the embodiments of the testing method of the above-mentioned functional services, and will not be described in detail here.

[0150] The present invention also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the method for testing the functional service described in any of the above embodiments are implemented.

[0151] The specific embodiments of the computer storage medium of the present invention are basically the same as the embodiments of the testing method of the above-mentioned functional services, and will not be described in detail here.

[0152] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0153] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0154] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0155] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for testing a functional service, characterized in that: The testing method of the functional service is applied to the client, and the testing method of the functional service includes: Acquire a baffle rule of the functional service, wherein the baffle rule is configured in a baffle server connected to the client; Intercepting a test request initiated for the functional service, and detecting whether the test request is the same as the original test request; If yes, the original test result corresponding to the original test request is locally indexed, and the original test result is fed back as the test result corresponding to the test request; Parsing the test request to obtain request parameters; The request parameters are compared locally according to the baffle rules to generate a test result, and the test request and the test result are stored in association, wherein, when it is compared that the request parameters recorded in the baffle rules are the same as the request parameters obtained by parsing, the response values ​​corresponding to the request parameters recorded in the baffle rules are encapsulated into the test result of the test request based on the groovyshell language.

2. The method for testing a functional service according to claim 1, characterized in that: The step of obtaining the baffle rule of the functional service includes: When it is detected that the functional service is started, the baffle rule configured for the functional service is obtained from the baffle server, and the baffle rule is stored in a local cache.

3. The method for testing a functional service according to claim 2, characterized in that: The step of locally comparing the request parameters according to the baffle rule to generate a test result includes: Traversing the baffle rules in the local cache; In the process of traversing the baffle rules, the request parameters are compared with the baffle rules to dynamically generate a test result.

4. The method for testing a functional service according to claim 1, wherein: The testing method of the functional service also includes: Storing the baffle rule in a local memory, and updating the baffle rule according to a preset first time period; The step of locally comparing the request parameters according to the baffle rule to generate a test result also includes: The baffle rules are traversed in the local memory, and in the process of traversing the baffle rules, the request parameters are compared with the baffle rules to dynamically generate a test result.

5. The method for testing a functional service according to any one of claims 1 to 4, characterized in that: Before the step of obtaining the baffle rule of the functional service, the method further includes: Client information is collected and transmitted to the baffle server, so that the baffle server can push the baffle rules according to the client information.

6. A method for testing a functional service, characterized in that: The testing method of the functional service is applied to a baffle server, the baffle server is connected to a client according to any one of claims 1 to 5, and the testing method of the functional service comprises: Generating a baffle rule for the functional service according to preset rule configuration data, wherein the rule configuration data is received based on a graphical user interface; Obtaining client information transmitted by the client; The baffle rule is pushed to the client according to the client information, so that the client can locally generate a test result corresponding to the test request according to the baffle rule, and store the test request and the test result in association with each other. When it is detected that the test request is the same as the original test request, the original test result corresponding to the original test request is indexed locally, and the original test result is fed back as the test result corresponding to the test request, wherein the test request is initiated for the functional service, and when it is compared that the request parameters recorded in the baffle rule are the same as the request parameters parsed from the test request, the response value corresponding to the request parameter recorded in the baffle rule is encapsulated as the test result of the test request based on the groovyshell language.

7. The method for testing a functional service according to claim 6, characterized in that: The step of pushing the baffle rule to the client according to the client information includes: Determine a new baffle rule after updating the baffle rule; The new baffle rule is pushed to the client according to a preset second time period.

8. A functional service testing system, characterized in that: The testing system of the functional service includes a client, and the client includes: A first acquisition module, used for acquiring a baffle rule of the functional service, wherein the baffle rule is configured in a baffle server connected to the client; An interception module, used to intercept the test request initiated for the functional service, and parse the test request to obtain request parameters; A test module, used for comparing the request parameters locally according to the baffle rules to generate a test result, wherein when the request parameters recorded in the baffle rules are compared to the request parameters obtained by parsing, the response values ​​corresponding to the request parameters recorded in the baffle rules are encapsulated into the test result of the test request based on the groovyshell language; The client is further used to: store the test request and the test result in association; The testing system for the functional service also includes: A detection unit, used to detect whether the test request is the same as the original test request; A result feedback unit, configured to, when the test request is the same as the original test request, locally index an original test result corresponding to the original test request, and feed back the original test result as the test result corresponding to the test request; The functional service testing system further includes a baffle service end, and the baffle service end includes: A rule configuration module, configured to generate a baffle rule for the functional service according to preset rule configuration data, wherein the rule configuration data is received based on a graphical user interface; A second acquisition module, used to acquire the client information transmitted by the client; A rule push module is used to push the baffle rule to the client according to the client information, so that the client can locally generate a test result corresponding to the test request according to the baffle rule, wherein the test request is initiated for the functional service.

9. A terminal device, characterized in that: The terminal device includes: a memory, a processor, and a test program for functional services stored in the memory and executable on the processor. When the test program for functional services is executed by the processor, the steps of the test method for functional services as described in any one of claims 1 to 5 and claims 6 to 7 are implemented.