Method and device for testing service function, program product and storage medium
By obtaining the target test information from the test case library and sending an indicative response message to the target test server, the problem of being unable to accurately test business functions with logical relationships in the existing technology is solved, and efficient and accurate business function testing is achieved.
Patent Information
- Application Number
- CN202411374750.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-21
AI Technical Summary
Existing automation testing tools are difficult to accurately test business functions with logical relationships and cannot effectively conduct system-level automation testing.
By obtaining the target request message, target preset response message and target test parameters of the target test case from the test case library, send the first response message to the target test server to indicate the test operation, and receive and filter the response from the business system Messages are compared to determine the function of the target service.
It achieves accurate testing of business functions with logical relationships, improves testing efficiency and stability, and ensures the continuity and stability of the business system.
Smart Images

Figure CN119336605A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a method and device for testing a business function, a program product, and a storage medium. Background Art
[0002] With the continuous upgrading of the technical architecture of enterprise business systems and the increasing prominence of security issues, business personnel are faced with increasingly heavy testing tasks. In order to improve testing efficiency, reduce risks and ensure business continuity and stability, it is necessary to develop and use more advanced automated testing tools. However, most of the current automated testing tools are based on the application programming interface (API) automated testing, lacking product-level or system-level automated testing methods, and unable to test businesses with logical relationships. Summary of the invention
[0003] The embodiments of the present application provide a method and apparatus, a program product, and a storage medium for testing business functions, so as to solve the problem that the related art cannot accurately test businesses with logical relationships.
[0004] According to an embodiment of the present application, a method for testing a business function is provided, comprising: obtaining target test information of a target test case from a test case library, wherein the test case library includes multiple test information of multiple test cases, the target test case is any one of the multiple test cases, the target test information includes a target request message, a target preset response message and a target test parameter, and the target test case is used to test a target business in a business system; in a case where the target test parameter includes a first response message, sending the first response message to a target test server to instruct the target test server to perform a test on the target business based on the first response message. The service performs a test operation and generates a second response message, wherein the first response message is used to indicate that there is an association relationship between the target service and the target test server; sends the target request message to the service system, and receives the second response message sent by the service system in response to the target request message, wherein the second response message is a message obtained by the service system from the target test server based on the target request message; performs a filtering operation on the second response message, and compares the second response message after the filtering operation with the target preset response message to obtain a first test result, wherein the first test result is used to determine the function of the target service.
[0005] In an exemplary embodiment, before obtaining the target test information of the target test case from the test case library, the method further includes: performing a pre-test operation on multiple services included in the business system, wherein the pre-test operation is a test operation in which the test result of each of the services meets a preset condition; in the process of performing the pre-test operation, intercepting the request message and the preset response message of each of the services to obtain a request message set and a preset response message set, wherein the request message set includes multiple request messages, and the preset response message set includes multiple preset response messages; establishing an association relationship between the identification information of each of the request messages in the request message set and the identification information of each of the preset response messages in the preset response message set to obtain an association file, wherein the association file includes test parameters, and the test parameters are used to associate the identification information of the request message with the identification information of the preset response message; integrating the request message set, the preset response message set and the association file to obtain the test case library.
[0006] In an exemplary embodiment, when the target test parameters include a first response message, the first response message is sent to the target test server to instruct the target test server to perform a test operation on the target business based on the first response message, and before generating a second response message, the method further includes: when it is determined that the target test parameters include a first setting parameter, setting the target business information of the target business, wherein the first setting parameter is used to indicate that the target business information is not included in the business system; and testing the target business through the target test case and based on the target business information.
[0007] In an exemplary embodiment, a filtering operation is performed on the second response message, and the second response message after the filtering operation is compared with the target preset response message to obtain a first test result, including: determining the non-business critical fields of the target preset response message from the target test parameters, wherein the non-business critical fields are message fields that are not related to the target business; based on the coding information in the target test parameters, performing a format conversion operation on the second response message to obtain the first message field of the second response message; using the coding information to perform the format conversion operation on the target preset response message to obtain the second message field of the target preset response message; performing the filtering operation on the first message field to delete the non-business critical fields from the first message field to obtain the first target message field; comparing the first target message field with the second message field to obtain the first test result.
[0008] In an exemplary embodiment, a filtering operation is performed on the second response message, and the second response message after the filtering operation is compared with the target preset response message to obtain a first test result to determine the function of the target business. The method further includes: when the target test parameters include a second setting parameter, deleting the first target business information of the target business, wherein the second setting parameter is used to indicate that the first target business information is redundant business information in the business system.
[0009] In an exemplary embodiment, after obtaining the target test information of the target test case from the test case library, the method further includes: when the first response message is not found from the target test parameters, sending the target request message to the business system to instruct the business system to perform a test operation on the target business based on the target request message to obtain a third response message; performing the filtering operation on the third response message, and comparing the third response message after the filtering operation with the target preset response message to obtain a second test result; and determining the function of the target business using the test result.
[0010] According to one embodiment of the present application, a device for testing a business function includes: a first acquisition module, which is used to acquire target test information of a target test case from a test case library, wherein the test case library includes multiple test information of multiple test cases, the target test case is any one of the multiple test cases, the target test information includes a target request message, a target preset response message and a target test parameter, and the target test case is used to test a target business in a business system; a first sending module, which is used to send the first response message to a target test server when the target test parameter includes a first response message, so as to instruct the target test server to perform a test on the target business based on the first response message. Execute a test operation and generate a second response message, wherein the first response message is used to indicate that there is an association relationship between the target business and the target test server; a first receiving module is used to send the target request message to the business system, and receive the second response message sent by the business system in response to the target request message, wherein the second response message is a message obtained by the business system from the target test server based on the target request message; a first execution module is used to perform a filtering operation on the second response message, and compare the second response message after the filtering operation with the target preset response message to obtain a first test result, wherein the first test result is used to determine the function of the target business.
[0011] In an exemplary embodiment, the device further includes: a second execution module, which is used to perform a pre-test operation on multiple services included in the business system before obtaining the target test information of the target test case from the test case library, wherein the pre-test operation is a test operation in which the test result of each of the above services meets a preset condition; a first interception module, which is used to intercept the request message and the preset response message of each of the above services during the execution of the pre-test operation to obtain a request message set and a preset response message set, wherein the request message set includes multiple request messages, and the preset response message set includes multiple preset response messages; a first establishment module, which is used to establish an association relationship between the identification information of each of the above request messages in the request message set and the identification information of each of the above preset response messages in the preset response message set to obtain an association file, wherein the association file includes test parameters, and the test parameters are used to associate the identification information of the request message with the identification information of the preset response message; a first integration module, which is used to integrate the request message set, the preset response message set and the association file to obtain the test case library.
[0012] In an exemplary embodiment, the above-mentioned device also includes: a first setting module, which is used to send the above-mentioned first response message to the target test server when the above-mentioned target test parameters include the first response message, so as to instruct the above-mentioned target test server to perform a test operation on the above-mentioned target business based on the above-mentioned first response message, and before generating a second response message, when it is determined that the above-mentioned target test parameters include the first setting parameters, set the target business information of the above-mentioned target business, wherein the above-mentioned first setting parameter is used to indicate that the above-mentioned business system does not include the above-mentioned target business information; a first test module, which is used to pass the above-mentioned target test case and test the above-mentioned target business based on the target business information.
[0013] In an exemplary embodiment, the above-mentioned first execution module includes: a first determination submodule, used to determine the non-business critical fields of the above-mentioned target preset response message from the above-mentioned target test parameters, wherein the above-mentioned non-business critical fields are message fields that are not related to the above-mentioned target business; a first execution submodule, used to perform a format conversion operation on the above-mentioned second response message based on the encoding information in the above-mentioned target test parameters, and obtain the first message field of the above-mentioned second response message; a second execution submodule, used to perform the above-mentioned format conversion operation on the above-mentioned target preset response message using the above-mentioned encoding information, and obtain the second message field of the above-mentioned target preset response message; a third execution submodule, used to perform the above-mentioned filtering operation on the above-mentioned first message field to delete the above-mentioned non-business critical fields from the above-mentioned first message field to obtain the first target message field; a first comparison submodule, used to compare the above-mentioned first target message field with the above-mentioned second message field to obtain the above-mentioned first test result.
[0014] In an exemplary embodiment, the above-mentioned device also includes: a first deletion module, which is used to perform a filtering operation on the above-mentioned second response message, and compare the second response message after the filtering operation with the above-mentioned target preset response message to obtain a first test result to determine the function of the above-mentioned target business. When the above-mentioned target test parameters include a second setting parameter, the first target business information of the above-mentioned target business is deleted, wherein the above-mentioned second setting parameter is used to indicate that the above-mentioned first target business information is redundant business information in the above-mentioned business system.
[0015] In an exemplary embodiment, the above-mentioned device also includes: a third execution module, which is used to obtain the target test information of the target test case from the test case library, and when the above-mentioned first response message is not queried from the above-mentioned target test parameters, send the above-mentioned target request message to the above-mentioned business system to instruct the above-mentioned business system to perform a test operation on the above-mentioned target business based on the above-mentioned target request message to obtain a third response message; a fourth execution module, which is used to perform the above-mentioned filtering operation on the above-mentioned third response message, and compare the third response message after the filtering operation is performed with the above-mentioned target preset response message to obtain a second test result; and use the above-mentioned test result to determine the function of the above-mentioned target business.
[0016] According to another embodiment of the present application, a computer program product is provided, including a computer program, wherein the computer program is configured for a processor to execute the steps of any of the above method embodiments.
[0017] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to enable a processor to execute the steps in any of the above method embodiments.
[0018] According to another embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor is configured to execute the computer program to perform the steps in any one of the method embodiments.
[0019] Through the present application, when testing the target business in the business system, the target request message, target preset response message and target test parameters of the target test case are obtained from the test case library; when there is an association relationship between the target business and the target test server, the target test server performs a test operation on the target business based on the first response message and generates a second response message; and receives the second response message obtained by the business system from the target test server based on the target request message; compares the second response message after the filtering operation with the target preset response message to obtain the first test result. Since the present application obtains the preset response message when testing the target business, and filters the second response message generated by the test, the stability and consistency of the comparison result between the filtered second response message and the target preset response message are guaranteed to the maximum extent. Therefore, the problem that the related art cannot accurately test businesses with logical relationships is solved, and the effect of accurately testing businesses with logical relationships is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a hardware structure block diagram of a mobile terminal of a method for testing service functions in an embodiment of the present application;
[0021] Figure 2 is a flow chart of a method for testing a service function according to an embodiment of the present application;
[0022] Figure 3 This is a process of a method for testing business functions in a specific embodiment of the present application Figure 1 ;
[0023] Figure 4 This is a process of a method for testing business functions in a specific embodiment of the present application Figure 2 ;
[0024] Figure 5 It is a structural block diagram of a device for testing business functions according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0027] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 1 is a hardware structure block diagram of a mobile terminal of a method for testing service functions in an embodiment of the present application. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0028] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as a computer program corresponding to a method for testing business functions in an embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0029] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0030] In this embodiment, a method for testing a service function is provided. Figure 2 is a flow chart of a method for testing a service function according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0031] Step S202, obtaining target test information of a target test case from a test case library, wherein the test case library includes multiple test information of multiple test cases, the target test case is any one of the multiple test cases, the target test information includes a target request message, a target preset response message and a target test parameter, and the target test case is used to test a target business in a business system;
[0032] Optionally, the business system belongs to fields including but not limited to finance, healthcare, retail, manufacturing, education, and telecommunications. For example, business systems in the financial field include but are not limited to online banking systems, transaction systems, risk management systems, credit approval systems, and asset management systems.
[0033] Optionally, the target test parameters include but are not limited to the network information of the business system, the transaction request protocol of the target business, the encryption information of the message, the setting parameters, the message encoding information, and the test time interval between test cases, wherein the network information includes but is not limited to the host Internet Protocol (IP) address of the business system, the port number of the business system, and the request address of the business system.
[0034] Step S204: in the case where the target test parameters include a first response message, the first response message is sent to the target test server to instruct the target test server to perform a test operation on the target service based on the first response message, and to generate a second response message, wherein the first response message is used to indicate that there is an association relationship between the target service and the target test server;
[0035] Optionally, when the target business involves a third-party system in actual application, the target test server needs to ensure that each test of the target business is independent, and does not need to rely on the result of the previous request when processing each test request. The target test server can be a baffle server. During the test, the baffle server opens the service port, receives the first response message, simulates the response of the third-party system to the test operation performed on the target business based on the first response message, and generates a second response message.
[0036] Step S206, sending the target request message to the business system, and receiving the second response message sent by the business system in response to the target request message, wherein the second response message is a message obtained by the business system from the target test server based on the target request message;
[0037] Optionally, assume that a payment service is tested to ensure that when a user completes a purchase on an online shopping platform and selects a third-party payment method, the service can be processed correctly and the user can receive correct confirmation information.
[0038] First, the automated testing tool obtains the target request message of the payment service, the target preset response message, the host IP of the online shopping platform, the port number of the online shopping platform, the request address of the online shopping platform, the request protocol of the payment service, and the encoding information of the message from the test case library of the online shopping platform.
[0039] Then, the automated testing tool sends a first response message of the payment service to the baffle server based on the request protocol of the payment service and the encoding information of the message. The baffle server simulates the payment service of the third-party system and generates a second response message of successful payment.
[0040] Finally, the automated testing tool sends a target request message for payment services to the online shopping platform based on the host IP and port number of the online shopping platform. The online shopping platform sends a get request to the baffle server based on the target request message. The baffle server responds to the get request and feeds back a second response message of successful payment to the online shopping platform based on the request address of the online shopping platform. The online shopping platform then feeds back the second response message of successful payment to the automated testing tool.
[0041] Step S208, performing a filtering operation on the second response message, and comparing the second response message after the filtering operation with the target preset response message to obtain a first test result, wherein the first test result is used to determine the function of the target service.
[0042] In this embodiment, the execution subject of the above steps can be a terminal, a server, a specific processor set in the terminal or server, or a processor or processing device set relatively independently from the terminal or server, but is not limited thereto.
[0043] Through the above steps, when testing the target business in the business system, the target request message, target preset response message and target test parameters of the target test case are obtained from the test case library; when there is an association relationship between the target business and the target test server, the target test server performs a test operation on the target business based on the first response message and generates a second response message; and receives the second response message obtained by the business system from the target test server based on the target request message; compares the second response message after the filtering operation with the target preset response message to obtain the first test result. Since the present application obtains the preset response message when testing the target business, and filters the second response message generated by the test, the stability and consistency of the comparison results between the filtered second response message and the target preset response message are guaranteed to the maximum extent. Therefore, the problem that the related technology cannot accurately test businesses with logical relationships is solved, and the effect of accurately testing businesses with logical relationships is achieved.
[0044] In an exemplary embodiment, before obtaining the target test information of the target test case from the test case library, the method further includes: performing a pre-test operation on multiple services included in the business system, wherein the pre-test operation is a test operation in which the test result of each of the services meets a preset condition; in the process of performing the pre-test operation, intercepting the request message and the preset response message of each of the services to obtain a request message set and a preset response message set, wherein the request message set includes multiple request messages, and the preset response message set includes multiple preset response messages; establishing an association relationship between the identification information of each of the request messages in the request message set and the identification information of each of the preset response messages in the preset response message set to obtain an association file, wherein the association file includes test parameters, and the test parameters are used to associate the identification information of the request message with the identification information of the preset response message; integrating the request message set, the preset response message set and the association file to obtain the test case library.
[0045] Optionally, through an automated message interception tool, the message formed during the test process of the pre-test operation whose test results meet the expectations is automatically intercepted to obtain a request message and a preset response message. The test case library includes a request message set and a preset response message set, as well as an associated file associating the request message and the preset response message. The identification information is used to uniquely identify the request message and the preset response message, such as the file name of the request message and the file name of the preset response message. The test parameters include the file name of the request message in the request message set, the file name of the preset response message in the preset response message set, and the association relationship between the messages. For example, the association file represents the association relationship between the request message and the preset response message in the form of business 1-request message 1-preset response message 1 (file name 1 of the request message, file name 1 of the preset response message, first response message, network information of the business system, transaction request protocol of the target business, encryption information of the message, setting parameters, message encoding information, and test time interval between test cases and test cases). This embodiment achieves the purpose of automated testing and greatly reduces the workload of testers by generating a test case library and presetting messages.
[0046] In an exemplary embodiment, when the target test parameters include a first response message, the first response message is sent to the target test server to instruct the target test server to perform a test operation on the target business based on the first response message, and before generating a second response message, the method further includes: when it is determined that the target test parameters include a first setting parameter, setting the target business information of the target business, wherein the first setting parameter is used to indicate that the target business information is not included in the business system; and testing the target business through the target test case and based on the target business information.
[0047] Optionally, business systems usually have logical relationships. For example, if user information is to be modified, the user's information must exist in the business system, otherwise a misjudgment error result will occur when testing the modified business. Therefore, before performing a test operation on the target business, it is possible to detect whether the target test parameters contain a first setting parameter. If the target test parameters include the first setting parameter, it means that the target business information required for testing the target business does not exist in the business system, and the business information needs to be added to the business system. Specifically, a database execution script can be written in advance, such as a database statement that inserts a user information into the database. This embodiment achieves the purpose of improving test efficiency and accuracy when testing businesses with logical relationships by automatically pre-embedding test data before performing a test operation.
[0048] In an exemplary embodiment, a filtering operation is performed on the second response message, and the second response message after the filtering operation is compared with the target preset response message to obtain a first test result, including: determining the non-business critical fields of the target preset response message from the target test parameters, wherein the non-business critical fields are message fields that are not related to the target business; based on the coding information in the target test parameters, performing a format conversion operation on the second response message to obtain the first message field of the second response message; using the coding information to perform the format conversion operation on the target preset response message to obtain the second message field of the target preset response message; performing the filtering operation on the first message field to delete the non-business critical fields from the first message field to obtain the first target message field; comparing the first target message field with the second message field to obtain the first test result.
[0049] Optionally, this embodiment determines the test result based on comparing message fields, but there are some non-business key fields in the message field, which are irrelevant to the business but affect the test results, such as business execution time or date and other fields that are irrelevant to the business but affect the test results. Therefore, in order to ensure the stability and correctness of the test results, it is necessary to automatically filter out the non-business key fields in the second response message. Specifically, different businesses have different non-business key fields, and it is necessary to determine the non-business key fields corresponding to the preset response message from the test parameters in the test case library. For example, the non-business key fields of the preset response message of the payment service are the timestamp of the payment processing, the token for subsequent queries, and the time spent on the payment processing. The second response message and the target preset response message are formatted. The conversion operation is performed to obtain the first message field of the second response message: the identification number that uniquely identifies this transaction-1, indicating whether the payment is successful-successful, the amount of payment-100, the currency type used for payment-US dollars, the timestamp of the payment processing-2022.12.27, the token for subsequent queries, and the time spent on the payment processing-3 seconds. The second message field of the target preset response message: unique identification number for this transaction - 1, whether the payment is successful - success, the amount paid - 100, the currency type used for payment - US dollars, and the timestamp of payment processing - 2022.12.28. Perform a filtering operation on the first message field, delete the non-business key fields of the payment business, and obtain the first target message field: unique identification number for this transaction - 1, whether the payment is successful - success, the amount paid - 100, and the currency type used for payment - US dollars. Compare the first target message field and the second message field to obtain a successful test result.
[0050] In an exemplary embodiment, a filtering operation is performed on the second response message, and the second response message after the filtering operation is compared with the target preset response message to obtain a first test result to determine the function of the target business. The method further includes: when the target test parameters include a second setting parameter, deleting the first target business information of the target business, wherein the second setting parameter is used to indicate that the first target business information is redundant business information in the business system.
[0051] Optionally, business systems usually have logical relationships. For example, if new user information is created, then the business system must not have the information of the user, otherwise there will be erroneous results of misjudgment when testing the newly created business. Therefore, when performing repeated test operations on the target business, it is necessary to delete the user information newly created last time. It is possible to detect whether there is a second setting parameter in the target test parameter. If the target test parameter includes the second setting parameter, it means that there is redundant first target business information for testing the target business in the business system, and the business information needs to be deleted in the business system. Specifically, a database execution script can be written in advance, such as a database statement to delete a piece of user information from the database. This embodiment automatically deletes redundant test data after executing the test operation, without the need to manually clean up the test data, and achieves the purpose of improving test efficiency and accuracy when testing businesses with logical relationships.
[0052] In an exemplary embodiment, after obtaining the target test information of the target test case from the test case library, the method further includes: when the first response message is not found from the target test parameters, sending the target request message to the business system to instruct the business system to perform a test operation on the target business based on the target request message to obtain a third response message; performing the filtering operation on the third response message, and comparing the third response message after the filtering operation with the target preset response message to obtain a second test result; and determining the function of the target business using the test result.
[0053] Optionally, if the first response message is not found in the target test parameters, it means that the target service does not involve a third-party system in actual application, and there is no need to use the baffle server for testing. Assume that the deletion service is tested to ensure that the user information on the online shopping platform is correctly deleted. First, the automated testing tool obtains the target request message of the deletion service, the target preset response message and the host IP of the online shopping platform, the port number of the online shopping platform, the request address of the online shopping platform, the request protocol of the deletion service, and the encoding information of the message from the test case library of the online shopping platform.
[0054] Then, the automated testing tool sends a target request message for deleting the service to the online shopping platform based on the request protocol for deleting the service and the encoding information of the message. The online shopping platform deletes the information of user A on the shopping platform based on the target request message and generates a third response message indicating successful deletion.
[0055] Finally, the automated testing tool performs a filtering operation on the third response message, and compares the third response message after the filtering operation with the target preset response message to obtain a second test result, wherein the basic principle and purpose of the filtering operation are the same as those in the above embodiment and will not be repeated here.
[0056] The present invention will be described below in conjunction with specific embodiments:
[0057] This embodiment is described by testing the payment service involving a third-party system. Figure 3 This is a process of a method for testing business functions in a specific embodiment of the present application Figure 1 , including the following steps:
[0058] S302, reading the test information of the test case of the payment service in the case library: the target request message of the payment service, the target preset response message and the host IP of the online shopping platform, the port number of the online shopping platform, the request address of the online shopping platform, the request protocol of the payment service, the encoding information of the message, and the first setting parameter-no information of user A;
[0059] S304, the test parameters include the first setting parameter without information of user A, and the information of user A is added in the online shopping platform;
[0060] S306, based on the request protocol of the payment service and the encoding information of the message, sending the first response message of the payment service to the baffle server, and based on the host IP and port number of the online shopping platform, sending the target request message of the payment service to the online shopping platform;
[0061] S308, the baffle server simulates the payment service of the third-party system and generates a second response message indicating successful payment;
[0062] S310, the online shopping platform sends an acquisition request to the baffle server based on the target request message, and the baffle server responds to the acquisition request and feeds back a second response message indicating successful payment to the online shopping platform based on the request address of the online shopping platform;
[0063] S312, receiving a second response message from the online shopping platform;
[0064] S314, the non-business key fields of the preset response message of the payment service are the timestamp of the payment processing, the token for subsequent query, and the time taken for the payment processing. The second response message and the target preset response message are formatted and converted to obtain the first message field of the second response message: the identification number that uniquely identifies this transaction-1, indicating whether the payment is successful-success, the amount paid-100, the currency type used for payment-US dollars, the timestamp of the payment processing-2022.12.27, the token for subsequent query, and the time taken for the payment processing-3 seconds. The second message field of the target preset response message: the identification number that uniquely identifies this transaction-1, indicating whether the payment is successful-success, the amount paid-100, the currency type used for payment-US dollars, and the timestamp of the payment processing-2022.12.28. Perform a filtering operation on the first message field, delete the non-business key fields of the payment service, and obtain the first target message field: the identification number that uniquely identifies this transaction-1, indicating whether the payment is successful-success, the amount paid-100, and the currency type used for payment-US dollars. Comparing the first target message field with the second message field to obtain a successful test result;
[0065] S316, the test parameters do not include the second setting parameters, and there is no redundant target business information for the test payment business in the online shopping platform, so there is no need to delete the business information.
[0066] This embodiment is described by testing the deletion service that does not involve a third-party system. Figure 4 This is a process of a method for testing business functions in a specific embodiment of the present application Figure 2 , including the following steps:
[0067] S402, reading the test information of the test case of the deletion service in the case library: the target request message of the deletion service, the target preset response message and the host IP of the online shopping platform, the port number of the online shopping platform, the request address of the online shopping platform, the request protocol of the deletion service, the encoding information of the message, and the first setting parameter-no information of user A;
[0068] S404, the test parameters include the first setting parameter without information of user A, and the information of user A is added in the online shopping platform;
[0069] S406, based on the request protocol for deleting the service and the encoding information of the message, as well as the host IP and port number of the online shopping platform, sending a target request message for deleting the service to the online shopping platform;
[0070] S408, accepting the online shopping platform's request to delete the information of user A in the shopping platform, and generating a third response message indicating successful deletion;
[0071] S410, performing a filtering operation on the third response message, and comparing the third response message after the filtering operation is performed with the target preset response message to obtain a second test result, wherein the basic principle and purpose of the filtering operation are the same as those in the above embodiment, and are not described in detail here;
[0072] S412: The test parameters do not include the second setting parameters, and there is no redundant first target business information for the test payment business in the online shopping platform, so there is no need to delete the first target business information.
[0073] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment 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 application, 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), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0074] In the present embodiment, a device for testing business functions is also provided, and the device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made are not repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0075] Figure 5 is a structural block diagram of a device for testing service functions according to an embodiment of the present application, such as Figure 5 As shown, the device comprises:
[0076] A first acquisition module 502 is used to acquire target test information of a target test case from a test case library, wherein the test case library includes multiple test information of multiple test cases, the target test case is any one of the multiple test cases, the target test information includes a target request message, a target preset response message and a target test parameter, and the target test case is used to test a target business in a business system;
[0077] The first sending module 504 is used to send the first response message to the target test server when the target test parameters include the first response message, so as to instruct the target test server to perform a test operation on the target service based on the first response message, and generate a second response message, wherein the first response message is used to indicate that there is an association relationship between the target service and the target test server;
[0078] The first receiving module 506 is used to send the target request message to the business system, and receive the second response message sent by the business system in response to the target request message, wherein the second response message is a message obtained by the business system from the target test server based on the target request message;
[0079] The first execution module 508 is used to perform a filtering operation on the above-mentioned second response message, and compare the second response message after the filtering operation with the above-mentioned target preset response message to obtain a first test result, wherein the above-mentioned first test result is used to determine the function of the above-mentioned target business.
[0080] In an exemplary embodiment, the device further includes: a second execution module, which is used to perform a pre-test operation on multiple services included in the business system before obtaining the target test information of the target test case from the test case library, wherein the pre-test operation is a test operation in which the test result of each of the above services meets a preset condition; a first interception module, which is used to intercept the request message and the preset response message of each of the above services during the execution of the pre-test operation to obtain a request message set and a preset response message set, wherein the request message set includes multiple request messages, and the preset response message set includes multiple preset response messages; a first establishment module, which is used to establish an association relationship between the identification information of each of the above request messages in the request message set and the identification information of each of the above preset response messages in the preset response message set to obtain an association file, wherein the association file includes test parameters, and the test parameters are used to associate the identification information of the request message with the identification information of the preset response message; a first integration module, which is used to integrate the request message set, the preset response message set and the association file to obtain the test case library.
[0081] In an exemplary embodiment, the above-mentioned device also includes: a first setting module, which is used to send the above-mentioned first response message to the target test server when the above-mentioned target test parameters include the first response message, so as to instruct the above-mentioned target test server to perform a test operation on the above-mentioned target business based on the above-mentioned first response message, and before generating a second response message, when it is determined that the above-mentioned target test parameters include the first setting parameters, set the target business information of the above-mentioned target business, wherein the above-mentioned first setting parameter is used to indicate that the above-mentioned business system does not include the above-mentioned target business information; a first test module, which is used to pass the above-mentioned target test case and test the above-mentioned target business based on the target business information.
[0082] In an exemplary embodiment, the above-mentioned first execution module includes: a first determination submodule, used to determine the non-business critical fields of the above-mentioned target preset response message from the above-mentioned target test parameters, wherein the above-mentioned non-business critical fields are message fields that are not related to the above-mentioned target business; a first execution submodule, used to perform a format conversion operation on the above-mentioned second response message based on the encoding information in the above-mentioned target test parameters, and obtain the first message field of the above-mentioned second response message; a second execution submodule, used to perform the above-mentioned format conversion operation on the above-mentioned target preset response message using the above-mentioned encoding information, and obtain the second message field of the above-mentioned target preset response message; a third execution submodule, used to perform the above-mentioned filtering operation on the above-mentioned first message field to delete the above-mentioned non-business critical fields from the above-mentioned first message field to obtain the first target message field; a first comparison submodule, used to compare the above-mentioned first target message field with the above-mentioned second message field to obtain the above-mentioned first test result.
[0083] In an exemplary embodiment, the above-mentioned device also includes: a first deletion module, which is used to perform a filtering operation on the above-mentioned second response message, and compare the second response message after the filtering operation with the above-mentioned target preset response message to obtain a first test result to determine the function of the above-mentioned target business. When the above-mentioned target test parameters include a second setting parameter, the first target business information of the above-mentioned target business is deleted, wherein the above-mentioned second setting parameter is used to indicate that the above-mentioned first target business information is redundant business information in the above-mentioned business system.
[0084] In an exemplary embodiment, the above-mentioned device also includes: a third execution module, which is used to obtain the target test information of the target test case from the test case library, and when the above-mentioned first response message is not queried from the above-mentioned target test parameters, send the above-mentioned target request message to the above-mentioned business system to instruct the above-mentioned business system to perform a test operation on the above-mentioned target business based on the above-mentioned target request message to obtain a third response message; a fourth execution module, which is used to perform the above-mentioned filtering operation on the above-mentioned third response message, and compare the third response message after the filtering operation is performed with the above-mentioned target preset response message to obtain a second test result; and use the above-mentioned test result to determine the function of the above-mentioned target business.
[0085] An embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0086] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0087] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0088] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0089] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0090] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0091] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0092] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for testing a business function, characterized in that: include: Acquire target test information of a target test case from a test case library, wherein the test case library includes multiple test information of multiple test cases, the target test case is any one of the multiple test cases, the target test information includes a target request message, a target preset response message and a target test parameter, and the target test case is used to test a target business in a business system; In a case where the target test parameters include a first response message, sending the first response message to a target test server to instruct the target test server to perform a test operation on the target service based on the first response message and generate a second response message, wherein the first response message is used to indicate that there is an association relationship between the target service and the target test server; Sending the target request message to the business system, and receiving the second response message sent by the business system in response to the target request message, wherein the second response message is a message obtained by the business system from the target test server based on the target request message; A filtering operation is performed on the second response message, and the second response message after the filtering operation is compared with the target preset response message to obtain a first test result, wherein the first test result is used to determine the function of the target service.
2. The method according to claim 1, characterized in that Before acquiring target test information of a target test case from the test case library, the method further includes: Performing a pre-test operation on a plurality of services included in the service system, wherein the pre-test operation is a test operation in which a test result of each of the services meets a preset condition; In the process of performing the pre-test operation, intercepting the request message and the preset response message of each of the services to obtain a request message set and a preset response message set, wherein the request message set includes a plurality of the request messages, and the preset response message set includes a plurality of the preset response messages; Establishing an association relationship between the identification information of each request message in the request message set and the identification information of each preset response message in the preset response message set, and obtaining an association file, wherein the association file includes a test parameter, and the test parameter is used to associate the identification information of the request message with the identification information of the preset response message; The request message set, the preset response message set and the associated file are integrated to obtain the test case library.
3. The method according to claim 1, characterized in that In a case where the target test parameters include a first response message, before sending the first response message to the target test server to instruct the target test server to perform a test operation on the target service based on the first response message and generating a second response message, the method further includes: In a case where it is determined that the target test parameter includes a first setting parameter, setting target service information of the target service, wherein the first setting parameter is used to indicate that the service system does not include the target service information; The target service is tested through the target test case and based on the target service information.
4. The method according to claim 1, characterized in that: Performing a filtering operation on the second response message, and comparing the second response message after the filtering operation is performed with the target preset response message to obtain a first test result, including: Determining a non-business critical field of the target preset response message from the target test parameter, wherein the non-business critical field is a message field that is unrelated to the target business; Based on the encoding information in the target test parameter, performing a format conversion operation on the second response message to obtain a first message field of the second response message; Performing the format conversion operation on the target preset response message by using the encoding information to obtain a second message field of the target preset response message; Performing the filtering operation on the first message field to delete the non-business critical field from the first message field to obtain a first target message field; The first target message field and the second message field are compared to obtain the first test result.
5. The method according to claim 1, characterized in that After performing a filtering operation on the second response message and comparing the second response message after the filtering operation with the target preset response message to obtain a first test result to determine the function of the target service, the method further includes: In a case where the target test parameter includes a second setting parameter, first target business information of the target business is deleted, wherein the second setting parameter is used to indicate that the first target business information is redundant business information in the business system.
6. The method according to claim 1, characterized in that After acquiring target test information of the target test case from the test case library, the method further includes: In the case where the first response message is not found from the target test parameters, sending the target request message to the business system to instruct the business system to perform a test operation on the target business based on the target request message, and obtaining a third response message; Performing the filtering operation on the third response message, and comparing the third response message after the filtering operation is performed with the target preset response message to obtain a second test result; The function of the target service is determined using the test result.
7. A device for testing service functions, characterized in that: include: A first acquisition module is used to acquire target test information of a target test case from a test case library, wherein the test case library includes multiple test information of multiple test cases, the target test case is any case among the multiple test cases, the target test information includes a target request message, a target preset response message and a target test parameter, and the target test case is used to test a target business in a business system; a first sending module, configured to send a first response message to a target test server when the target test parameter includes the first response message, so as to instruct the target test server to perform a test operation on the target service based on the first response message, and to generate a second response message, wherein the first response message is used to indicate that there is an association relationship between the target service and the target test server; A first receiving module, used to send the target request message to the business system, and receive the second response message sent by the business system in response to the target request message, wherein the second response message is a message obtained by the business system from the target test server based on the target request message; The first execution module is used to perform a filtering operation on the second response message, and compare the second response message after the filtering operation with the target preset response message to obtain a first test result, wherein the first test result is used to determine the function of the target service.
8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 6 when executed by a processor.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 6 are implemented.