Business test method and device, equipment and storage medium

Create an agent through Java agent and use simulated testing rules to perform business tests in the microservice architecture, solving the problems of business code complexity and low testing efficiency, and achieving efficient and independent business testing.

CN120448252APending Publication Date: 2025-08-08BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510355878.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

In microservice architecture, it is difficult to conduct efficient and accurate testing independently of relying on services during business testing. In the prior art, business code is highly complex, readable and maintainable, and the testing process is time-consuming and inefficient.

Method used

Create an agent through Java agent, which is independent of the business program, uses simulation test rules to process, generate simulation processing results, and realize independent business testing.

Benefits of technology

It reduces the complexity of business code, improves the readability and maintainability of the code, reduces the cost of testing time, and improves the efficiency of testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448252A_ABST
    Figure CN120448252A_ABST
Patent Text Reader

Abstract

The invention relates to a service testing method and device, equipment and a storage medium. The service test method comprises the following steps: receiving a test request for a first service, and determining at least one second service based on the test request, the second service being a dependent service involved by the first service in a target test scene; a pre-configured simulation test rule of the first service is acquired, and the simulation test rule defines simulation behaviors of at least one dependent service of the first service in different test scenes; under the condition that the at least one second service hits the simulation test rule, processing is carried out according to the simulation test rule, and a simulation processing result is generated; and testing the first service based on the simulation processing result, and generating a test result of the first service. According to the method provided by the invention, the test time cost is reduced, and the test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a service testing method, device, equipment and storage medium. Background Art

[0002] In a microservices architecture, testing a specific business often involves other dependent businesses, such as databases. Therefore, ensuring efficient and accurate independent testing without the impact of these other dependent businesses is crucial. However, in related technologies, when conducting business testing, the business code often incorporates test code unrelated to the business logic, increasing its complexity and reducing its readability and maintainability. Furthermore, during testing, the code often needs to be repeatedly modified to adapt to different test scenarios, further increasing testing time and reducing testing efficiency. Summary of the Invention

[0003] In order to solve the above technical problems, the embodiments of the present disclosure provide a service testing method, apparatus, device and storage medium.

[0004] In a first aspect, an embodiment of the present disclosure provides a service testing method, including:

[0005] receiving a test request for a first service, and determining at least one second service based on the test request, where the second service refers to a dependent service involved in a target test scenario by the first service;

[0006] Obtaining pre-configured simulation test rules for the first service, wherein the simulation test rules define simulation behaviors of at least one dependent service of the first service under different test scenarios;

[0007] When the at least one second service matches the simulation test rule, processing is performed according to the simulation test rule to generate a simulation processing result;

[0008] The first service is tested based on the simulation processing result to generate a test result of the first service.

[0009] Optionally, before receiving the test request for the first service, the method further includes:

[0010] Creating an agent program through a Java agent, wherein the agent program is independent of the business program of the first business and is used to complete the test process of the first business;

[0011] The receiving a test request for the first service includes:

[0012] A test request for a first service is received through the agent program.

[0013] Optionally, before obtaining the pre-configured simulation test rules for the first service, the method further includes:

[0014] It is determined whether the test request includes a preset identifier, wherein the preset identifier represents a target test process for the first service.

[0015] Optionally, obtaining a pre-configured simulation test rule for the first service includes:

[0016] In a case where the test request includes the preset identifier, determining the simulation test process as the target test process;

[0017] Execute the target test process, obtain simulation test rules applicable to the simulation test process, and generate simulation processing results based on the simulation test rules, wherein the simulation test process refers to a test process for completing the first business through the simulation processing results.

[0018] Optionally, after determining whether the test request includes a preset identifier, the method further includes:

[0019] In a case where the test request does not include the preset identifier, determining the actual test process as the target test process;

[0020] Execute the target test process and send the test request to the at least one second business to obtain the real processing result generated by the at least one second business in response to the test request, wherein the real test process refers to the test process of completing the first business through the real processing result.

[0021] Optionally, the processing according to the simulation test rules to generate simulation processing results includes:

[0022] Obtaining a simulation address in the simulation test rule, and replacing the request address in the test request with the simulation address to obtain a replaced test request;

[0023] The replaced test request is executed to process the simulated service of the at least one second service at the simulated address and generate a simulated processing result.

[0024] Optionally, the processing according to the simulation test rules to generate simulation processing results includes:

[0025] Obtaining a configuration result in the simulation test rule, wherein the configuration result is an expected behavior result of the at least one second service predefined according to the test requirements;

[0026] A simulation processing result is generated according to the configuration result.

[0027] Optionally, after creating the agent program through the Java agent, the method further includes:

[0028] A test request for a third service is received through the agent program to complete a simulation test process of the third service, wherein the agent program is independent of a service program of the third service, and the third service is different from the first service.

[0029] Optionally, before obtaining the pre-configured simulation test rules for the first service, the method further includes:

[0030] defining an interface of the at least one dependent service;

[0031] Configuring corresponding simulation test rules for at least one test scenario involved in the first service, wherein the simulation test rules define a forwarding path and / or output result of the interface;

[0032] Use the Mock framework to set up simulation behaviors, and write test cases based on the simulation test rules and the simulation behaviors;

[0033] Run the test case, and when the verification result of the test case is verification passed, complete the configuration of the simulation test rule.

[0034] In a second aspect, an embodiment of the present disclosure provides a service testing device, including:

[0035] a receiving unit, configured to receive a test request for a first service, and determine at least one second service based on the test request, where the second service refers to a dependent service involved in a target test scenario by the first service;

[0036] an acquiring unit, configured to acquire a pre-configured simulation test rule for the first service, wherein the simulation test rule defines a simulation behavior of at least one dependent service of the first service under different test scenarios;

[0037] A processing unit, configured to, when the at least one second service matches the simulation test rule, perform processing according to the simulation test rule and generate a simulation processing result;

[0038] A generating unit is used to test the first service based on the simulation processing result and generate a test result of the first service.

[0039] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0040] Memory;

[0041] processor; and

[0042] computer programs;

[0043] The computer program is stored in the memory and is configured to be executed by the processor to implement the method of the first aspect as described above.

[0044] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method of the first aspect described above when the computer program is executed by a processor.

[0045] The business testing method provided by the present disclosure includes: receiving a test request for a first business, and determining at least one second business based on the test request, wherein the second business refers to a dependent business involved in the target test scenario of the first business; obtaining a pre-configured simulation test rule for the first business, wherein the simulation test rule defines the simulation behavior of at least one dependent business of the first business under different test scenarios; in the case where the at least one second business hits the simulation test rule, processing is performed in accordance with the simulation test rule to generate a simulation processing result; testing the first business based on the simulation processing result to generate a test result of the first business. The method provided by the present application, through pre-configured simulation test rules for different test scenarios, processes in accordance with the simulation test rules, thereby avoiding writing test code unrelated to the business logic in the business code to the greatest extent, reducing the complexity of the business code, and increasing the readability and maintainability of the business code. In the subsequent comprehensive testing of the business, by adjusting the simulation test rules, the time for repeated modifications is reduced, further reducing the time cost of testing and improving testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0047] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0048] Figure 1 A flowchart of a service testing method provided by an embodiment of the present disclosure;

[0049] Figure 2A schematic diagram of the structure of a service testing system provided in an embodiment of the present disclosure;

[0050] Figure 3 A flowchart of another service testing method provided by an embodiment of the present disclosure;

[0051] Figure 4 A flowchart of another service testing method provided in an embodiment of the present disclosure;

[0052] Figure 5 A schematic diagram of the structure of a service testing device provided in an embodiment of the present disclosure;

[0053] Figure 6 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0054] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0055] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0056] Specifically, after the application is developed, it needs to be functionally tested before the service is launched. The daily work of test engineers is to perform functional testing on the applications developed by R&D engineers. Among them, functional testing is divided into interface testing and integration testing. When performing interface testing in a microservice architecture, each interface may depend on the interfaces of many other service components, such as databases, message queues, etc., or interfaces that depend on downstream services. Moreover, in most cases, the components or services that the interface depends on are not yet suitable for testing. In this case, it is very difficult to ensure that the interface can be tested independently and verify the correctness of its functions. The relevant technology is to mock the dependent components. Among them, mock (simulation) technology in the microservice architecture can help isolate the system under test from other external dependent businesses (such as databases, third-party APIs, message queues, etc.), so as to focus on verifying the business logic and functions of the system.

[0057] When conducting unit testing of a business, R&D engineers typically use mock libraries, such as MockIO, to mock dependent data and services. Implementing mock functionality for interfaces or databases also requires support from R&D engineers. For example, adding a specific header to an HTTP request requires the tester to identify the header and perform actions based on it, such as routing the dependent interface to a specific address or returning a specific result, in order to complete the functional test. However, these methods still have the following issues:

[0058] 1) In business programs, it is necessary to mix in a lot of test codes that are irrelevant to business logic, which makes the business code confusing and reduces the readability and maintainability of the code.

[0059] 2) The business logic code written in the business program is not flexible enough. Multiple strategies are usually required when conducting business testing. Each strategy may require modifying the business code, which may cause the business code to be modified due to non-business needs, which may introduce other code problems.

[0060] 3) In business programs, in order to verify various functions and ensure the correctness of the code, it may be necessary to construct various complex test scenarios when writing test code. Especially when the business logic is relatively complex and contains multiple conditional branches, constructing these scenarios will become very difficult and time-consuming.

[0061] To address the above technical issues, the present disclosure provides a service testing method, which will be described in detail through one or more of the following embodiments.

[0062] The service testing method provided by the embodiment of the present disclosure is applicable to service testing scenarios. The method can be performed by a service testing device, which can be implemented by software and / or hardware, and the device can be integrated into an electronic device. Among them, the electronic device can include but is not limited to mobile terminals such as smart phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Tablet Personal Computers, Tablet PCs), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, smart home devices, etc.

[0063] Before describing in detail a service testing method provided by an embodiment of the present disclosure, the test scenarios involved are described first. Service testing, program testing, and interface testing are different levels and perspectives in software testing. Specifically:

[0064] Business testing mainly focuses on verifying whether the software meets business requirements and user expectations, focusing on checking whether the software functions can correctly implement business logic and whether the user experience is good.

[0065] Program testing focuses on code-level testing, with the aim of verifying the correctness of the program's internal logic and ensuring that each module or component operates as designed. It is usually performed by R&D engineers and can also be understood as part of unit testing or integration testing.

[0066] Interface testing focuses on testing the interaction points between systems to ensure that different services or components can communicate and exchange data correctly. Interface testing can be calls between internal services or docking between external systems.

[0067] Among them, effective interface testing is one of the foundations of program testing, and good program testing results support the success of business testing. For example, only when the communication between various service interfaces is stable and reliable can the business logic of the entire system be correctly implemented. When testing the embodiments of the present disclosure, program testing and / or interface testing may also be involved, which can also be achieved through the following business testing methods.

[0068] Figure 1 A flow chart of a service testing method provided in an embodiment of the present disclosure, which is applied to a service testing system, specifically includes the following steps: Figure 1 The following steps are shown:

[0069] For example, see Figure 2 , Figure 2 This is a structural diagram of a business testing system provided in an embodiment of the present disclosure. The business testing system includes a test program, a first business, a configuration management platform, a mock platform, and a second business. The test program is used to send a test request to the first business. The first business refers to the business to be tested, and the second business is the dependent business involved in the testing process of the first business. The configuration management platform is a platform for configuring and publishing simulation test rules. The mock platform refers to a platform for mocking various businesses, applications, and interfaces.

[0070] Among them, business testing methods include:

[0071] S101: Receive a test request for a first service, and determine at least one second service based on the test request.

[0072] The second service is a dependent service involved in the target test scenario by the first service.

[0073] It is understandable that a test request for the first business is received. The test request may be issued by a test engineer through a test program, and the test request is used to request a business test for the first business. The test request represents the target test scenario, target test process, and at least one dependent business involved in the target test scenario when testing the first business. The target test scenario may be a unit test, an integration test, an end-to-end test, and other scenarios. The target test process may be a simulation test process and / or a real test process. The simulation test process refers to a simulation test performed through a Mock. A Mock refers to using virtual objects or data to replace real objects or data during the test process, so as to simulate situations that are difficult to reproduce in the real environment in the target test scenario. The real test process refers to a real test performed through a dependent business. A dependent business refers to a component or service that has a dependency relationship with the first business in the business logic, such as a database, a third-party API, a message queue, etc. Subsequently, based on the test request, at least one second business involved in the target test scenario of the first business can be determined. For example, when testing the playback business, its dependent business may be a login business, an authentication business, etc.

[0074] It is understandable that the business code of the first business may not include test logic unrelated to the business logic, or test code for specific test scenarios may be added according to business needs. This can effectively reduce the interweaving of business logic and test logic in the business code, simplify the code base, and improve the readability and maintainability of the business code.

[0075] It is understandable that the working conditions of the second business are not limited. For example, the second business does not have the conditions to support the testing of the first business at all. For example, the test requirement is to conduct an independent test on the first business, and there is no need to pay attention to the working conditions of the second business. For example, the test requirement is carried out under relatively extreme conditions for the second business, and this extreme condition cannot be achieved in a real environment. That is, when testing the first business, the test impact of the second business can be minimized to the greatest extent. Other situations of the second business are not elaborated.

[0076] It is understandable that, for all second businesses, one possible situation is that all second businesses are simulated tested through Mock, and the first business is tested through the simulated processing results. Another possible situation is that all second businesses are actually tested, and the first business is tested through the real processing results. Still another possible situation is that a part of the second businesses are simulated tested through Mock, and another part of the second businesses are actually tested, and the first business is tested through the real processing results and the simulated processing results.

[0077] Optionally, before receiving the test request for the first service, the method further includes:

[0078] An agent program is created through a Java agent, wherein the agent program is independent of the business program of the first business and is used to complete the test process of the first business.

[0079] As you can understand, by creating a proxy program using a Java agent, the proxy program is independent of the business program of the first business. This means that no code unrelated to the business logic itself, such as test code, needs to be included in the business code of the first business. Furthermore, in a microservices architecture, the interface of the first business may depend on the interfaces of multiple other businesses, making it difficult to independently test the interfaces of the first business. In this case, the created proxy program allows for code-free testing of the first business and mocking of the interfaces of dependent businesses, reducing dependency on other businesses and ensuring independent testing of the first business. The specific construction method of the proxy program is not detailed here.

[0080] Java agent is a Java probe technology provided by the Java Development Kit (JDK), based on the JVM tool interface (JVM TI, a standard interface provided by Java that allows tools to interact with the JVM). By combining Java agent technology with the Java Instrumentation API (application programming interface), it is possible to dynamically modify the functional classes of an application without directly changing the source code. This enables a variety of functions such as code debugging, diagnostic tools, and application enhancement logic. In other words, the agent allows the behavior of loaded classes to be dynamically modified or enhanced when new tests are needed or existing tests are modified, without directly modifying the business logic in the business code.

[0081] Optionally, the receiving a test request for the first service includes:

[0082] A test request for a first service is received through the agent program.

[0083] As can be understood, the proxy program receives test requests and can monitor the test requests issued by the test program and then execute the test process related to the first business based on the test request content. In other words, the proxy program can achieve non-invasiveness of business code and eliminate the need for R&D engineers to add code logic unrelated to the business code.

[0084] S102: Obtain pre-configured simulation test rules for the first service.

[0085] The simulation test rules define simulation behaviors of at least one dependent service of the first service under different test scenarios.

[0086] It is understandable that, based on the above S101, in order to conduct effective simulation testing of the first business under different test scenarios, it is usually necessary to configure and manage the simulation test rules of its dependent businesses. The simulation test rules define how to simulate the behavior of the dependent businesses in different test scenarios to ensure that the functions of the first business are fully verified.

[0087] Optionally, before obtaining the pre-configured simulation test rules for the first service, the method further includes:

[0088] Define the interface of at least one dependent business; configure corresponding simulation test rules for at least one test scenario involved in the first business, wherein the simulation test rules define the forwarding path and / or output result of the interface; use the Mock framework to set the simulation behavior, and write test cases according to the simulation test rules and the simulation behavior; run the test case, and complete the configuration of the simulation test rules if the verification result of the test case is verification passed.

[0089] Specifically, the steps for configuring simulation test rules through the configuration management platform are as follows: define an interface for each dependent business to facilitate subsequent replacement using the Mock framework; configure corresponding simulation test rules according to different test scenarios; use the Mock framework to set simulation behavior and write test cases; run the test cases and verify the results. Once the verification passes, the configuration of the simulation test rules is completed.

[0090] In one possible implementation scenario, the primary service is the order service, and its dependent services are the payment service and notification service. The interfaces for the payment and notification services are defined through the configuration management platform. The order service depends on the payment and notification services, and the business logic between them is established based on this. Based on different test scenarios, simulation test rules are configured, such as successful payment with notification, payment failure, successful payment but notification failure, etc. These test cases are run through the mock testing framework to ensure that all test cases pass correctly and verify the expected behavior. Subsequently, the primary service can be tested using mocks in different test scenarios.

[0091] Optionally, before obtaining the pre-configured simulation test rules for the first service, the method further includes:

[0092] It is determined whether the test request includes a preset identifier, wherein the preset identifier represents a target test process for the first service.

[0093] It is understood that after receiving the test request, the agent determines whether the test request includes a preset identifier, that is, whether the test request header carries the preset identifier. The preset identifier represents the target test process for the first service, and the agent executes the target test process to complete the test of the first service.

[0094] Optionally, obtaining pre-configured simulation test rules for the first service can be specifically achieved through the following steps:

[0095] When the test request includes the preset identifier, the simulation test process is determined as the target test process; the target test process is executed, and the simulation test rules applicable to the simulation test process are obtained to generate a simulation processing result based on the simulation test rules, wherein the simulation test process refers to the test process for completing the first business through the simulation processing result.

[0096] Understandably, the proxy intercepts the test request with a preset identifier and identifies the simulation test process as the target test process, that is, the simulation test process implemented by Mock. The simulation processing result is generated after the Mock framework executes the set simulation behavior. Among them, the simulation test rules can directly define the simulation processing results output by the interface, and can also define the path and address that the interface needs to forward, etc. After forwarding, the simulation processing result can be obtained, and the simulation processing result can be understood as the dependent business result. The simulation test process is usually used for isolation testing to ensure that the logic of the first business can be verified separately without being affected by the actual dependent business. It is mostly used when the dependent business does not have the conditions for testing.

[0097] Optionally, after determining whether the test request includes a preset identifier, the method further includes:

[0098] When the test request does not include the preset identifier, the real test process is determined as the target test process; the target test process is executed, and the test request is sent to the at least one second business to obtain the real processing result generated by the at least one second business in response to the test request, wherein the real test process refers to the test process of completing the first business through the real processing result.

[0099] Understandably, the proxy program did not intercept the test request with the preset identifier, and identified the real test process as the target test process. The real test process can be understood as completing the test of the first business through the real dependent business results (that is, the real processing results generated by at least one second business in response to the test request). The real test process is closer to the actual operation of the production environment, and can verify whether the interaction between the first business and the dependent business is normal. It is mostly used when the dependent business has the conditions for testing. Subsequently, in response to the test request, the second business is directly called, and the real data returned by the second business is used to verify the behavior of the first business.

[0100] S103: When the at least one second service matches the simulation test rule, perform processing according to the simulation test rule to generate a simulation processing result.

[0101] It is understandable that, based on the above S102, when at least one second business involved in the test request meets the preset simulation test rules, it is processed according to the simulation test rules and a corresponding simulation processing result is generated. Among them, the second business hits the simulation test rules means that the second business meets one or more preset rules in the simulation test rules. The rules define how to simulate the behavior of the second business under specific conditions, that is, define the simulation behavior for the second business. After determining that a second business hits a certain rule, the behavior of the second business is simulated according to the rules. For example, based on the above example, the rules define that the payment service (second business) should return a result of successful payment or failed payment. Subsequently, a corresponding simulation response is generated according to the rule, and the simulation processing result is usually the same as the actual response format of the second business, but the content therein is pre-set and meets the test requirements.

[0102] Optionally, processing is performed according to the simulation test rules to generate simulation processing results, which can be specifically achieved through the following steps:

[0103] Obtain the simulation address in the simulation test rule, and use the simulation address to replace the request address in the test request to obtain a replaced test request; execute the replaced test request to process the simulated business of at least one second business at the simulation address to generate a simulation processing result.

[0104] It is understandable that the simulation test rules include a simulation address, which can be understood as a Mock address. The request address in the test request is replaced by the simulation address to obtain a replaced test request, wherein the request address refers to the actual / real address of the second business. Subsequently, the replaced test request is executed, and the request will be sent to the simulation service instead of the actual service, wherein the simulation address points to the simulation service, and the request address points to the actual service. The simulation service can provide simulated behavior and response results of the second business, that is, request the Mock service to generate a simulation processing result. The simulation processing result is usually pre-configured and is used to simulate various possible responses of the actual dependent business. Subsequently, the simulation service returns the simulation processing result to the first business, and the first business continues to process based on the simulation processing result. Based on the above example, after returning the result of successful login, the video is played to test the playback function.

[0105] Optionally, processing is performed according to the simulation test rules to generate simulation processing results, which can be specifically achieved through the following steps:

[0106] Acquire a configuration result in the simulation test rule, wherein the configuration result is an expected behavior result of the at least one second service predefined according to the test requirements; and generate a simulation processing result according to the configuration result.

[0107] Understandably, simulation test rules also include configuration results, which are pre-defined based on specific test requirements and describe the expected behavior and response results of the second business in different test scenarios. Subsequently, corresponding simulation processing results are generated based on the configuration results to replace the response results of the actual dependent business. This method allows the business logic of the first business to be tested without relying on the actual second business, ensuring its correctness and stability under various preset conditions. It can also effectively isolate and verify the business logic of the first business while reducing dependence on external dependent businesses.

[0108] S104: Generate a test result of the first service based on the simulation processing result.

[0109] It is understandable that, based on the above S103, the simulation processing result is sent to the first business, and the first business will process the simulation processing result in the same way as the result returned by the real dependent business. Specifically, the first business executes its internal business logic based on the received simulation processing result. Based on the above example, if the simulation processing result indicates that the payment is successful, the first business may continue to process the order. If the simulation processing result indicates that the payment fails, the first business may throw an exception or record an error message. Subsequently, based on the first business's processing of the simulation processing result, the final test result is generated. Based on the above example, the test result includes whether the first business is successfully executed and log data, etc.

[0110] The disclosed embodiments provide a business testing method that uses Java agent technology to implement a business mock function without business code intrusion, enabling independent testing of complex businesses. Secondly, the Java agent decouples the test code from the business code, facilitating iterative upgrades. Subsequent testing of other businesses to be tested can also be performed using the agent. Furthermore, by configuring associations through a configuration management platform, test engineers can dynamically simulate test rules through the configuration management platform and construct various test scenarios that meet testing requirements, greatly improving test efficiency and reducing repetitive development work.

[0111] Based on the above embodiments, Figure 3 A flowchart of another business testing method provided by an embodiment of the present disclosure. Optionally, after creating an agent program through a Java agent, the business testing method further includes the following steps: Figure 3 The following steps are shown:

[0112] S301: Receive a test request for a third service through the agent program to complete a simulation test process of the third service.

[0113] The agent program is independent of the service program of the third service, and the third service includes at least one fourth service.

[0114] S302: Obtain pre-configured simulation test rules for the third service.

[0115] S303: When the at least one fourth service matches the simulation test rule, process the service according to the simulation test rule to generate a simulation processing result.

[0116] The fourth service refers to a dependent service involved in the test of the third service.

[0117] S304: Generate a test result of the third service based on the simulation processing result.

[0118] It is understandable that the description of the specific test process for the third service can be found in the above embodiment and will not be repeated here.

[0119] It is understandable that the first service and the third service waiting for testing can start the agent program by themselves to perform the test through the agent program.

[0120] The disclosed embodiments provide a business testing method that uses a Java agent to build an agent program independent of each business code, which can test most Java services and is not limited to a certain type of business testing. This improves the flexibility and universality of business testing and effectively reduces development costs.

[0121] Based on the above embodiments, Figure 4 A flow chart of another service testing method provided by the embodiment of the present disclosure is applied to the above-mentioned agent program, specifically including the following steps: Figure 4 Steps shown:

[0122] 1) Receive a test request from a third-party service; 2) Determine whether the test request header carries a preset identifier; 3) If the preset identifier does not exist in the test request, do not process the test request and directly execute the test request; 4) If the preset identifier exists in the test request, obtain the simulation configuration rules set by the test engineer from the configuration management platform; 5) Determine whether the dependent service in the test request hits the Mock rule in the simulation configuration rule; 6) If the dependent service does not hit the Mock rule, do not process the test request and directly execute the test request; 7) If the dependent service hits the Mock rule, obtain the Mock address in the Mock rule and replace the request address in the test request with the Mock address; 8) After replacing the request address in the test request, execute the test request.

[0123] It is understandable that the third-party service refers to the above-mentioned test program, and the test request is a request sent by the test engineer through the test program for the service to be tested. Specifically, through the proxy program, HTTP test requests with preset identifiers are detected in real time. After intercepting the HTTP test request, it is determined whether it matches the rules configured by the configuration management platform. After matching the rules, according to the configuration rules, the request address in the HTTP test request is converted into a mock address in the configuration rules, or the configuration result is returned. The specific implementation instructions of the above 1)-8) refer to the above embodiments and are not repeated here.

[0124] Figure 5 The schematic diagram of the structure of a service testing device provided by the embodiment of the present disclosure. The service testing device provided by the embodiment of the present disclosure can execute the processing flow provided by the service testing method embodiment, such as Figure 5As shown, the service testing device 500 includes a receiving unit 501, an acquiring unit 502, a processing unit 503 and a generating unit 504, wherein:

[0125] A receiving unit 501 is configured to receive a test request for a first service, and determine at least one second service based on the test request, where the second service refers to a dependent service involved in a target test scenario by the first service;

[0126] An acquiring unit 502 is configured to acquire a pre-configured simulation test rule for the first service, wherein the simulation test rule defines a simulation behavior of at least one dependent service of the first service under different test scenarios;

[0127] The processing unit 503 is configured to, when the at least one second service matches the simulation test rule, perform processing according to the simulation test rule and generate a simulation processing result;

[0128] The generating unit 504 is configured to test the first service based on the simulation processing result and generate a test result of the first service.

[0129] Optionally, the service testing device 500 is further configured to:

[0130] Creating an agent program through a Java agent, wherein the agent program is independent of the business program of the first business and is used to complete the test process of the first business;

[0131] Optionally, the receiving unit 501 is configured to:

[0132] A test request for a first service is received through the agent program.

[0133] Optionally, the service testing device 500 is further configured to:

[0134] Determining whether the test request includes a preset identifier, wherein the preset identifier represents a target test process for the first service;

[0135] Optionally, the acquiring unit 502 is configured to:

[0136] In a case where the test request includes the preset identifier, determining the simulation test process as the target test process;

[0137] Execute the target test process, obtain simulation test rules applicable to the simulation test process, and generate simulation processing results based on the simulation test rules, wherein the simulation test process refers to a test process for completing the first business through the simulation processing results.

[0138] Optionally, the processing unit 503 is configured to:

[0139] Obtaining a simulation address in the simulation test rule, and replacing the request address in the test request with the simulation address to obtain a replaced test request;

[0140] The replaced test request is executed to process the simulated service of the at least one second service at the simulated address and generate a simulated processing result.

[0141] Optionally, the processing unit 503 is configured to:

[0142] Obtaining a configuration result in the simulation test rule, wherein the configuration result is an expected behavior result of the at least one second service predefined according to the test requirements;

[0143] A simulation processing result is generated according to the configuration result.

[0144] Optionally, the service testing device 500 is further configured to:

[0145] A test request for a third service is received through the agent program to complete a test process of the third service, wherein the agent program is independent of a service program of the third service, and the third service is different from the first service.

[0146] Optionally, the service testing device 500 is further configured to:

[0147] defining an interface of the at least one dependent service;

[0148] Configuring corresponding simulation test rules for at least one test scenario involved in the first service, wherein the simulation test rules define a forwarding path and / or output result of the interface;

[0149] Use the Mock framework to set up simulation behaviors, and write test cases based on the simulation test rules and the simulation behaviors;

[0150] Run the test case, and when the verification result of the test case is verification passed, complete the configuration of the simulation test rule.

[0151] Figure 5 The service testing device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effects are similar and will not be described in detail here.

[0152] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the embodiment of the present disclosure. Figure 6, which shows a schematic structural diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. The electronic device 600 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable electronic devices, and the like, as well as fixed terminals such as digital TVs, desktop computers, smart home devices, and the like. Figure 6 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0153] like Figure 6 As shown, the electronic device 600 may include a processing device 601 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes to implement the service testing method of the embodiment described in the present disclosure according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage device 608 into the random access memory (RAM) 603. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0154] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.

[0155] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart, thereby implementing the business testing method described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0156] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. 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. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0157] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0158] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0159] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.

[0160] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0161] 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 disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than 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 and / or flowchart, and the combination of the boxes in the block diagram and / 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.

[0162] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit does not necessarily limit the unit itself.

[0163] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0164] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0165] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or gateway that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article or gateway. In the absence of further restrictions, the elements defined by the sentence "including a..." do not exclude the presence of other identical elements in the process, method, article or gateway that includes the elements.

[0166] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. A service testing method, characterized in that: include: receiving a test request for a first service, and determining at least one second service based on the test request, where the second service refers to a dependent service involved in a target test scenario by the first service; Obtaining pre-configured simulation test rules for the first service, wherein the simulation test rules define simulation behaviors of at least one dependent service of the first service under different test scenarios; When the at least one second service matches the simulation test rule, processing is performed according to the simulation test rule to generate a simulation processing result; The first service is tested based on the simulation processing result to generate a test result of the first service.

2. The method according to claim 1, characterized in that Before receiving the test request for the first service, the method further includes: Creating an agent program through a Java agent, wherein the agent program is independent of the business program of the first business and is used to complete the test process of the first business; The receiving a test request for the first service includes: A test request for a first service is received through the agent program.

3. The method according to claim 1, characterized in that Before obtaining the pre-configured simulation test rules for the first service, the method further includes: Determining whether the test request includes a preset identifier, wherein the preset identifier represents a target test process for the first service; The obtaining of a pre-configured simulation test rule for the first service includes: In a case where the test request includes the preset identifier, determining the simulation test process as the target test process; Execute the target test process, obtain simulation test rules applicable to the target test process, and generate simulation processing results based on the simulation test rules, wherein the simulation test process refers to a test process for completing the first business through the simulation processing results.

4. The method according to claim 1, wherein The processing according to the simulation test rules to generate simulation processing results includes: Obtaining a simulation address in the simulation test rule, and replacing the request address in the test request with the simulation address to obtain a replaced test request; The replaced test request is executed to process the simulated service of the at least one second service at the simulated address and generate a simulated processing result.

5. The method according to claim 1, wherein The processing according to the simulation test rules to generate simulation processing results includes: Obtaining a configuration result in the simulation test rule, wherein the configuration result is an expected behavior result of the at least one second service predefined according to the test requirements; A simulation processing result is generated according to the configuration result.

6. The method according to claim 2, characterized in that After creating the agent program through the Java agent, the method further includes: A test request for a third service is received through the agent program to complete a test process of the third service, wherein the agent program is independent of a service program of the third service, and the third service is different from the first service.

7. The method according to claim 1, characterized in that Before obtaining the pre-configured simulation test rules for the first service, the method further includes: defining an interface of the at least one dependent service; Configuring corresponding simulation test rules for at least one test scenario involved in the first service, wherein the simulation test rules define a forwarding path and / or output result of the interface; Use the Mock framework to set up simulation behaviors, and write test cases based on the simulation test rules and the simulation behaviors; Run the test case, and when the verification result of the test case is verification passed, complete the configuration of the simulation test rule.

8. A service testing device, characterized in that: include: a receiving unit, configured to receive a test request for a first service, and determine at least one second service based on the test request, where the second service refers to a dependent service involved in a target test scenario by the first service; an acquiring unit, configured to acquire a pre-configured simulation test rule for the first service, wherein the simulation test rule defines a simulation behavior of at least one dependent service of the first service under different test scenarios; A processing unit, configured to, when the at least one second service matches the simulation test rule, perform processing according to the simulation test rule and generate a simulation processing result; A generating unit is used to test the first service based on the simulation processing result and generate a test result of the first service.

9. An electronic device, characterized in that: include: Memory; processor; as well as computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the service testing method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the service testing method according to any one of claims 1 to 7 are implemented.