A service testing method, device, computer equipment and storage medium
By recording and integrating the traffic data of the target service, generating test cases and directly testing under the target version, the problem of low testing efficiency of software service is solved, and an efficient testing process is achieved, avoiding additional testing environment construction and data preparation. .
Patent Information
- Application Number
- CN202011073856.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-09
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2040-10-09
AI Technical Summary
Software service testing is inefficient and requires tedious work steps such as making test function templates, defining input and output rules, and building a test environment, resulting in low testing efficiency.
By recording the traffic data of the target service in the initial version, generating a traffic recording file, and integrating data based on test requests in the target version, generating test cases, injecting services under the target version for testing, comparing the running results With the expected results, determine the test results.
There is no need to create a test function template or define input and output rules, and use real traffic data for testing, which can accurately restore the site under the initial version, improve testing efficiency, and avoid building a test environment and preparing additional data.
Smart Images

Figure CN114328172B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a service testing method, apparatus, computer equipment and storage medium. Background Art
[0002] Software testing is a process used to promote the identification of the correctness, integrity, security and quality of software. Therefore, software testing is one of the important means of software quality assurance. The common software testing method is to provide multiple test function templates, generate test cases by following the input and output rules in the templates, and perform testing through the generated test cases.
[0003] In the process of research and practice of related technologies, the inventors of the present application found that testing software services requires tedious work in multiple links, such as the need to create test function templates and define test input and output rules, the need to generate test requests by analyzing input and output rules, the need to prepare a distributed test environment and test data processed by the test requests, etc., which makes the testing efficiency of software services need to be improved. Summary of the invention
[0004] The embodiments of the present application provide a service testing method, apparatus, computer equipment and storage medium, which can improve the efficiency of testing services.
[0005] The present application provides a service testing method, including:
[0006] Recording the traffic data of the target service in the initial version to obtain a traffic recording file of the target service;
[0007] Obtain a test request for the target service at the target version;
[0008] Based on the test request, data integration processing is performed on the traffic recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data;
[0009] Injecting the test input data into the target service under the target version to obtain service operation result data of the target service under the target version for the test input data;
[0010] Comparing the service operation result data with the test expected result data;
[0011] Based on the comparison result, a test result of the target service at the target version is determined.
[0012] Accordingly, the embodiment of the present application further provides a service testing device, including:
[0013] A recording unit, used to record the traffic data of the target service in the initial version to obtain a traffic recording file of the target service;
[0014] An acquisition unit, used to acquire a test request for the target service at a target version;
[0015] An integration unit, configured to perform data integration processing on the traffic recording file based on the test request to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data;
[0016] An injection unit, used to inject the test input data into a target service under the target version, and obtain service operation result data of the target service under the target version for the test input data;
[0017] A comparison unit, used for comparing the service operation result data with the test expected result data;
[0018] A determination unit is used to determine a test result of the target service at the target version based on the comparison result.
[0019] In one embodiment, the traffic recording file includes a parameter recording file of at least one service call instance, and the parameter recording file includes at least one service call parameter in a target format; the integration unit includes:
[0020] A file selection subunit, used for selecting a parameter recording file required for generating a test case from the traffic recording file based on the test request;
[0021] A parameter extraction subunit, configured to extract parameters from the parameter recording file based on the parameter category corresponding to the parameter recording file, and obtain the extracted service call parameters;
[0022] A data integration subunit is used to perform data integration processing on the extracted service call parameters to obtain integrated test cases;
[0023] The use case combination subunit is used to combine the integrated test cases to obtain a combined traffic playback file.
[0024] In one embodiment, the service call parameter before extraction carries a parameter call sequence flag; the parameter extraction subunit is used to:
[0025] Based on the parameter call sequence flag, a parameter extraction specification of the parameter recording file under the parameter category is determined; by following the parameter extraction specification, the parameter recording file under the parameter category is extracted to obtain the extracted service call parameters.
[0026] In one embodiment, the parameter extraction subunit is used to:
[0027] According to the parameter call sequence flag, the parameter transfer logic of the service call parameter in the service call instance is determined; based on the parameter transfer logic, the parameter extraction specification of the parameter recording file under the parameter category is generated.
[0028] In one embodiment, the data integration subunit is used to:
[0029] Determine the test association attributes of the extracted service call parameters; based on the test association attributes, perform data integration processing on the extracted service call parameters to obtain integrated test input data and test expected result data; and generate a test case corresponding to the service call instance based on the test input data and the test expected result data.
[0030] In one embodiment, the data integration subunit is further used for:
[0031] Acquire a data editor corresponding to the target format; and edit the integrated test input data and test result expected data through the data editor to obtain edited test input data and test result expected data.
[0032] In one embodiment, the recording unit includes:
[0033] A traffic acquisition subunit, configured to acquire traffic data of a target service under the initial version, wherein the traffic data includes at least one service call instance;
[0034] A parameter parsing subunit, used to parse the service call instance to obtain the service call parameters in a target format;
[0035] A file generating subunit, configured to generate a parameter recording file of the service calling instance corresponding to the parameter category based on the parameter category to which the service calling parameter belongs;
[0036] The file combination subunit is used to combine the generated parameter recording files to generate the traffic recording file of the target service.
[0037] In one embodiment, the parameter parsing subunit is used to:
[0038] Obtain traffic data of the target service under the initial version, wherein the traffic data includes at least one service call instance; perform parameter parsing on the service call instance to obtain service call parameters under the target format; based on the parameter category to which the service call parameters belong, generate a parameter recording file of the service call instance corresponding to the parameter category; combine the generated parameter recording files to generate a traffic recording file of the target service.
[0039] In one embodiment, the parameter parsing subunit is used to:
[0040] The original service call parameters are collected from the service call instance; the type of the original service call parameters is identified; and based on the identification result, the original service call parameters are parsed into service call parameters in a target format.
[0041] In one embodiment, the parameter parsing subunit is used to:
[0042] Determine the parameter category to which the service call parameter belongs; and group the service call parameters according to the parameter category to obtain a parameter recording file of the service call instance corresponding to the parameter category.
[0043] In one embodiment, the injection unit comprises:
[0044] A parameter parsing subunit, used to parse the test input data to obtain the service call test parameters required to generate the service call test interface;
[0045] An interface generation subunit, used to generate a service call test interface for a target service under the target version according to the service call test parameters;
[0046] A data injection subunit, configured to inject the test data into a target service under the target version by calling the service call test interface;
[0047] The result acquisition subunit is used to obtain service running result data of the target service under the target version for the test input data.
[0048] In one embodiment, the service testing device further includes:
[0049] A test case generating unit, configured to generate a test case using the test input data and the service operation result data;
[0050] An updating unit is used to update the test case set of the target service based on the generated test case.
[0051] Correspondingly, an embodiment of the present application further provides a storage medium on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the service testing method shown in the embodiment of the present application are implemented.
[0052] Correspondingly, an embodiment of the present application also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the service testing method shown in the embodiment of the present application are implemented.
[0053] The embodiment of the present application can record the traffic data of the target service in the initial version to obtain the traffic recording file of the target service; obtain the test request of the target service in the target version; based on the test request, perform data integration processing on the traffic recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data; inject the test input data into the target service under the target version to obtain the service operation result data of the target service under the target version for the test input data; compare the service operation result data with the test expected result data; based on the comparison result, determine the test result of the target service at the target version.
[0054] The scheme obtains the real traffic data of the target service by recording the traffic data of the target service under the initial version, so that when the target service under the target version needs to be tested, the real traffic data can be used as test data to test the target service. In this way, there is no need to make a test function template for the target service or define the input and output rules of the test, but to replace it with the recorded real traffic data. Secondly, when the scheme obtains the test request of the target service at the target version, it can integrate the real traffic data of the target service to obtain multiple test cases required for the test. Further, by injecting the generated test case into the target service under the target version, the target service under the target version can be tested, and the scene when the target service under the initial version is called can be restored, so that the target service under the target version can be tested more accurately, so that there is no need to build a test environment or prepare additional test data. Therefore, the scheme improves the testing technology from many aspects and can effectively improve the efficiency of testing the target service. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0056] Figure 1 It is a scenario diagram of the service testing method provided in the embodiment of the present application;
[0057] Figure 2 is a flow chart of the service testing method provided in an embodiment of the present application;
[0058] Figure 3 It is a data simulation schematic diagram of the service testing method provided in the embodiment of the present application;
[0059] Figure 4 is another flow chart of the service testing method provided in the embodiment of the present application;
[0060] Figure 5 It is a flow recording schematic diagram of the service testing method provided in the embodiment of the present application;
[0061] Figure 6 It is a flow playback schematic diagram of the service testing method provided in the embodiment of the present application;
[0062] Figure 7 is a schematic diagram of the structure of a service testing device provided in an embodiment of the present application;
[0063] Figure 8 is another structural schematic diagram of the service testing device provided in an embodiment of the present application;
[0064] Fig. 9 is another structural schematic diagram of the service testing device provided in an embodiment of the present application;
[0065] Fig.10 is another structural schematic diagram of the service testing device provided in an embodiment of the present application;
[0066] Fig.11 is another structural schematic diagram of the service testing device provided in an embodiment of the present application;
[0067] Fig.12 It is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0069] The embodiment of the present application provides a service testing method and device. Specifically, the embodiment of the present application provides a service testing device suitable for a computer device. The computer device may be a terminal or a server, and the terminal may be a mobile phone, a tablet computer, a laptop computer, or other devices. The server may be a single server or a server cluster consisting of multiple servers.
[0070] The embodiment of the present application will be introduced by taking the service testing method executed by a server as an example.
[0071] refer to Figure 1 , a target service may be run on the server 10, and the target service may be continuously improved and iterated by developing the target service step by step, for example, by developing multiple versions of the target service. When the target service is changed from the initial version to the target version, the target service under the target version needs to be tested to confirm that the modification does not introduce new errors or cause other codes to generate tests.
[0072] Specifically, the server 10 can record the traffic data of the target service in the initial version to obtain the traffic recording file of the target service. When the server 10 obtains the test request of the target service in the target version, the traffic recording file can be integrated based on the test request to obtain an integrated traffic playback file. It is worth noting that the obtained traffic playback file may include at least one test case, and the test case may include test input data and test expected result data.
[0073] Furthermore, the server 10 can inject the test input data into the target service under the target version to obtain the service operation result data of the target service for the test input data, so that the test result of the target service under the target version can be determined by comparing the service operation result data with the test expected result data. In other words, the test result of the target service under the target version is determined by comparing the actual output of the target service under the target version with the expected output.
[0074] In another embodiment, the service testing method is described by taking the example that the server and the terminal execute the method together.
[0075] refer to Figure 1, the target service can run on the server 10, and the server 10 can record the traffic data of the target service under the initial version to obtain the traffic recording file of the target service. It is worth noting that the recording of traffic data can be performed in the existing network to obtain the real traffic data of the target service; it can also be performed in a test environment to obtain the test traffic data of the target service. After the server 10 obtains the traffic recording file of the target service, the tester can initiate a test request for the target service under the target version at the terminal 20; accordingly, the server 10 can obtain the test request, and based on the test request, integrate the traffic recording file to obtain a traffic playback file including at least one test case, wherein the test case may include test input data and test expected result data.
[0076] Optionally, the tester can use a data editor on the terminal 10 to edit the integrated test input data and the test expected result data to generate more test cases, thereby increasing the diversity of the test cases.
[0077] Furthermore, the server 10 may inject the test input data in the test case into the target service under the target version to obtain the service operation result data of the target service under the target version for the test input data. Furthermore, the server 10 may compare the service operation result data with the test expected result data of the test case to determine the test result of the target service under the target version based on the comparison result.
[0078] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0079] The embodiment of the present application provides a service testing method, which can be executed by a terminal or a server, or by both the terminal and the server. The embodiment of the present application takes the service testing method executed by the server as an example for explanation. Specifically, the service testing method is executed by a service testing device integrated in the server, such as Figure 2 The specific process of the service testing method may be as follows:
[0080] 101. Record the traffic data of the target service in the initial version to obtain a traffic recording file of the target service.
[0081] Among them, a service can be a type of application that uses computers, communication networks and other technologies to produce, collect, process, process, store, transport, retrieve and use information to provide functional support or business assistance to programs or users. Therefore, the target service can be a program, routine or process that performs a specified system function in the operating system; for example, the target service can be an application running in the terminal background or server end, which can usually provide some functions to other applications or users locally or through the network, etc.
[0082] The input of a service can be a service request, a reply from a downstream dependent service, or other input that affects the control calculation, such as configuration; the output of a service can be a service response, or a request to a downstream dependent service, etc.
[0083] In one embodiment, the target service may be an application on a terminal, or an application on a server, or an application on a Web server, or an application on a database server, or other server-based applications; for example, the target service may be an information system that provides a series of functions, etc.
[0084] Among them, the process of developing the target service is often not accomplished overnight, and it often requires multiple versions of iteration and update to continuously improve the target service. Therefore, even after the target service is launched or delivered, it is usually necessary to iterate and upgrade or even reconstruct it, and it is also necessary to ensure the correctness of the original architecture of the target service. In this embodiment, the flow data can be recorded when the target service is in the initial version to obtain the flow recording file of the target service under the initial version.
[0085] It is worth noting that the initial version can be any version of the target service, and this application does not limit this.
[0086] The traffic data may include input data when requesting the target service, and output data of the target service in response to the request. It is worth noting that the input data and output data do not only include the input data and output data that can be intercepted when the target service is treated as a black box. For example, the input data may be HTTP (Hypertext Transfer Protocol, the full name in English is HyperText Transfer Protocol) request data, TCP (Transmission Control Protocol, the full name in English is Transmission Control Protocol) request data, link layer request data, etc. Correspondingly, the output data may be HTTP response data, TCP response data, link layer response data, etc.
[0087] In addition, traffic data can also include input data and output data between sub-services in the target service when the sub-services interact or call each other through data transmission. For example, the input data can be the input data when the communication call occurs within the sub-service of the target service, such as RPC (Remote Procedure Call) request data, and the corresponding output data can be RPC response data; and so on.
[0088] Among them, recording the traffic data can intercept and record the input data and output data of the target service to obtain the traffic recording file of the target service.
[0089] The data included in the traffic recording file can be organized in various forms. For example, a parameter recording file can be generated according to the service call parameters in the traffic data, and a traffic recording file can be further obtained based on the parameter recording file. Specifically, the step of "recording the traffic data of the target service at the initial version to obtain the traffic recording file of the target service" can include:
[0090] Obtaining traffic data of a target service under an initial version, wherein the traffic data includes at least one service call instance;
[0091] Parse the parameters of the service call instance to obtain the service call parameters in the target format;
[0092] Based on the parameter category to which the service call parameter belongs, generating a parameter recording file corresponding to the parameter category of the service call instance;
[0093] The generated parameter recording files are combined to generate a traffic recording file of the target service.
[0094] When a user or a program requests a target service and the target service responds to the request, the process can be abstracted to obtain a service call instance corresponding to the target service call process.
[0095] When the target service is in the initial version, multiple service calls will occur. Therefore, the traffic data of the target service in the initial version is recorded. First, multiple service call instances of the target service in the initial version can be recorded.
[0096] In this embodiment, the traffic data of the target service in the initial version is recorded. First, the traffic data of the target service in the initial version including multiple service call instances can be obtained by recording.
[0097] In one embodiment, the traffic data of the target service under the initial version includes two service call instances: an HTTP call instance and an RPC call instance, wherein the HTTP call instance records the process when the user calls the target service under the initial version, and the RPC call instance records the communication call process between sub-services within the target service under the initial version.
[0098] The service call parameters may be related parameters in the service call process. For example, the service call parameters may include service request parameters, service intermediate parameters, and call result parameters, etc.
[0099] The recorded service call parameters can be data of various types, for example, standard basic types in programming languages, or protobuf (an efficient and lightweight structured data storage method, the full name of which is ProtocolBuffer) type, or XML (eXtensible Markup Language) type, or JSON (JavaScript Object Notation) type, or user-defined type, etc.
[0100] The parameter parsing may be a combination of a series of steps, for example, it may include the steps of collecting the original service call instance from the service call instance and parsing the collected original service call instance into the service call parameters in the target format. Specifically, the step of "parsing the service call instance to obtain the service call parameters in the target format" may include:
[0101] Collecting original service call parameters from the service call instance;
[0102] Perform type identification on the original service call parameter;
[0103] Based on the recognition result, the original service call parameter is parsed into a service call parameter in a target format.
[0104] The original service call parameters may be service call parameters collected from the service call instance and not converted into a format. For example, the original service call parameters may be service call parameters of a standard basic type, or service call parameters of a protobuf type, or service call parameters of an XML type, or service call parameters of a JSON type, or service call parameters of a user-defined type, etc.
[0105] After collecting the original service call parameters from the service call instance, the collected original service call parameters can be further type identified to determine the parameter type of the original service call parameters, such as protobuf type, XML type, JSON type, or user-defined type, etc.
[0106] The target format may be a text format or other data format that is convenient for editing data.
[0107] Based on the type identification result of the original service call parameter, there are multiple ways to parse the collected original service call parameter into a target format. In one embodiment, the target format is a text format, and:
[0108] In this embodiment, a set of APIs (Application Programming Interface) can be designed to record and parse the original service call parameters of various types, such as standard basic types, protobuf types, XML types, JSON types, and user-defined types in the service call instance into text format for subsequent steps.
[0109] In one embodiment, the HTTP call instance of the target service in the initial version can be parsed to obtain data including the request URL (Uniform Resource Locator), request parameters, request header, etc., and these data can be converted into text format to obtain service call parameters in text format.
[0110] In another embodiment, the RPC call instance of the target service in the initial version can be parameter parsed to obtain data including RPC request parameters and RPC response parameters, and these data can be converted into text format to obtain service call parameters in text format.
[0111] After parsing the parameters of the service call instance and obtaining the service call parameters in the target format, a parameter recording file corresponding to the parameter category of the service call instance can be generated based on the parameter category to which the service call parameters belong.
[0112] Among them, the parameter category can be used to classify the service call parameters obtained by parsing, so as to generate an orderly and easy-to-reorganize parameter recording file, so that a traffic recording file can be obtained based on the parameter recording file, so that the target service can be tested subsequently using the traffic recording file.
[0113] The parameter category may include multiple categories, for example, it may include an input parameter category, an output parameter category, and a function execution result category. Therefore, after parsing the service call parameters of the service call instance, a parameter recording file corresponding to the parameter category of the service call instance may be generated based on the parameter category described in the service call parameters. Specifically, the step of "generating a parameter recording file corresponding to the parameter category of the service call instance based on the parameter category to which the service call parameters belong" may include:
[0114] Determine the parameter category to which the service call parameter belongs;
[0115] According to the parameter category, the service call parameters are grouped and processed to obtain a parameter recording file of the service call instance corresponding to the parameter category.
[0116] There are many ways to determine the parameter category to which a service call parameter belongs. For example, by referring to the role of the service call parameter in data transmission and information transmission during the process of the target service being called, it can be determined whether the service call parameter belongs to the input parameter category, the output parameter category, or the function execution result category.
[0117] After determining the parameter category to which the service call parameter belongs, each service call parameter can be divided into parameter recording files under different parameter categories through grouping processing to obtain the parameter recording files corresponding to each parameter category of the service call instance.
[0118] In one embodiment, after performing parameter parsing on a service call instance of a target service under an initial version, the service call parameters of the service call instance can be obtained, and according to the parameter categories corresponding to the service call parameters, an input parameter file corresponding to the input parameter category, an output parameter file corresponding to the output parameter category, and a result file corresponding to the function execution result category can be generated.
[0119] It is worth noting that after generating the input parameter file, output parameter file and result file of the service call instance, each file can be stored independently according to the session to which the service call instance belongs, as well as the call interface, call sequence number and parameter sequence number.
[0120] After generating the parameter recording files corresponding to each parameter category of the service call instance, the traffic recording file of the target service can be generated by combining the generated parameter recording files. Specifically, since the traffic data of the target service under the initial version may include multiple service call instances, after obtaining the parameter recording file of a service call instance, the parameter recording files of other service call instances can be obtained in the same way. Furthermore, the traffic recording file of the target service under the initial version can be generated by combining these generated parameter recording files.
[0121] There are many ways to combine. For example, based on the target service and service call instance to which the parameter recording files belong, the parameter recording files belonging to the same target service and the same service call instance can be combined to obtain an instance recording file. Furthermore, multiple instance recording files belonging to the same target service can be combined to obtain a traffic recording file of the target service.
[0122] For another example, when the target service can provide multiple callable interfaces, and each service call instance has a corresponding call sequence number, an input parameter file can be generated according to the call interface, call sequence number, and input parameter sequence number; an output parameter file can be generated according to the call interface, call sequence number, and output parameter sequence number; a result file can be generated according to the call interface, call requirements, and function execution results. After obtaining multiple input parameter files, multiple output parameter files, and multiple result files of the target service, the traffic recording file of the target service is obtained. There can be many ways to combine parameter recording files, and this application does not limit this.
[0123] 102. Obtain a test request for the target service at the target version.
[0124] For any version of the target service, as long as it is changed compared to the initial version, whether it is the addition or reduction of functions or adjustments in technical implementation, errors or exceptions may be introduced. Therefore, the target service under the target version needs to be tested.
[0125] This embodiment takes the target service running on the server side as an example. Therefore, the test request for the target service in the target version can be generated in the server or sent by the tester at the terminal, and the server side can obtain the test request accordingly to perform the test of the target service under the target version.
[0126] For example, since the target service may provide multiple external calling interfaces, corresponding test requests may be generated for different calling interfaces of the target service under the target version, that is, the test request may carry interface identification information of the calling interface.
[0127] 103. Based on the test request, perform data integration processing on the traffic recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data.
[0128] Among them, a test case is a description of a test task for a specific software product, reflecting the test plan, method, technology and strategy. Its content may include test objectives, test environment, test input data, test steps, test expected result data, test scripts, etc., and can eventually be documented. Simply put, a test case is a set of test inputs, execution conditions and test expected results compiled for a special goal, used to verify whether a specific software requirement is met.
[0129] Since the parameter recording files corresponding to each parameter category of each service call instance are obtained when the traffic data of the target service in the initial version is recorded, and the parameter recording files include the service call parameters of the service call instance in the parameter category, when the traffic recording files are used to test the target service in the target version, the traffic recording files can be integrated to obtain a traffic playback file that can include multiple test cases.
[0130] Among them, since the traffic data of the target service in the initial version records the scenario when the target service is called, by "feeding" multiple test cases generated based on the traffic data to the target service in the target version, the effect of replaying the scenario when the target service in the initial version is achieved.
[0131] Therefore, the traffic playback file can be a data file generated based on the traffic data of the target service under the initial version, which can play back the scene when the target service under the initial version is called, or can reproduce the scene when the target service under the initial version is called. In this embodiment, the traffic playback file can include multiple test cases, and the scene can be played back through these test cases to determine whether errors or exceptions will occur when the target service under the target version is placed in the scene of the target service under the initial version, so as to achieve the purpose of testing the target service under the target version.
[0132] The integration process may include multiple data processing steps to enable the generation of a traffic playback file based on the traffic data file. Since the traffic playback file may include multiple test cases, the integration process may perform several data processing steps on the traffic data file to generate at least one test case.
[0133] Since the traffic recording file includes a parameter recording file of at least one service call instance, and the parameter recording file includes at least one service call parameter in a target format, specifically, the step of "based on the test request, performing data integration processing on the traffic recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data" may include:
[0134] Based on the test request, select the parameter recording file required to generate the test case from the traffic recording file;
[0135] Based on the parameter category corresponding to the parameter recording file, extract the parameters of the parameter recording file to obtain the extracted service call parameters;
[0136] Perform data integration processing on the extracted service call parameters to obtain integrated test cases;
[0137] The integrated test cases are combined to obtain a combined traffic playback file.
[0138] There can be many ways to select parameter recording files based on test requests. For example, since the target service can provide multiple external calling interfaces, and when the test request carries interface identification information of the interface to be tested, a parameter recording file that matches the interface identification information can be selected from the traffic recording file to obtain the parameter recording file required to generate a test case for testing the interface to be tested of the target service under the target version.
[0139] For example, since each service call instance of the target service in the initial version has a corresponding call sequence number, in addition to taking the interface identification information into consideration, the call sequence number can also be taken into consideration, and the parameter recording file required to generate the test case can be selected based on the interface identification information and the call sequence number.
[0140] For another example, since the parameter recording file has a corresponding parameter category, in addition to taking the interface flag information and the call sequence number into consideration, the parameter category can also be taken into consideration; for example, the output parameter file, input parameter file and result file of the service call instance corresponding to the call interface 1 and with a call sequence number range of 1 to 1000 can be selected from the traffic recording file according to the interface flag information, the call sequence number and the parameter category as the parameter recording file required to generate the test case. There are many ways to select parameter recording files based on test requests, which will not be elaborated here.
[0141] After selecting the parameter recording file required to generate the test case, the parameter recording file can be further extracted to obtain the extracted service call parameters, and the extracted service call parameters can be integrated to obtain the integrated test case. For ease of understanding, the step "based on the parameter category corresponding to the parameter recording file, extract the parameters of the parameter recording file to obtain the extracted service call parameters" is further explained below, and then the step "data integration processing of the extracted service call parameters to obtain the integrated test case" is further explained later.
[0142] The process of a service call instance calling a target service may include the transmission and reception of multiple service call parameters. Therefore, when recording traffic data, the calling order of the service call parameters can be recorded so that the scene can be restored accurately based on the calling order later.
[0143] For example, in one embodiment, the target service is an order system, and the order system deploys multiple distributed servers. When requesting the target service to provide an order details viewing function, mutual calls between distributed systems will occur through RPC, that is, multiple RPC requests and responses will occur between distributed systems. When recording the request parameters and response parameters in each RPC request and response process, the order in which each parameter is called can be recorded in the form of a parameter call sequence mark, so that the RPC request and response process can be reproduced based on the parameter call sequence mark later, so that the test result of the target service under the target version can be judged based on the process.
[0144] Since the service call parameters before extraction carry the parameter call sequence flag, it is possible to determine how to extract the service call parameters from the parameter recording files under each parameter category according to the parameter call sequence flag. Specifically, the step of "extracting parameters from the parameter recording file based on the parameter category corresponding to the parameter recording file to obtain the extracted service call parameters" may include:
[0145] Based on the parameter call sequence flag, determining a parameter extraction specification of the parameter recording file under the parameter category;
[0146] By following the parameter extraction specification, the parameter recording file under the parameter category is extracted to obtain the extracted service call parameters.
[0147] Among them, the parameter call sequence mark can be in multiple forms, for example, it can be expressed in the form of a string including numbers, letters, or symbols; for example, the parameter call sequence mark of the service call parameter can be marked in the form of a timestamp when the service call parameter is specifically called; and so on.
[0148] Among them, the parameter extraction specification can be used to describe the specifications that should be followed when extracting service call parameters from the parameter recording files under each parameter category of the service call instance. By following the parameter extraction specification, the scene when the target service is called under the initial version can be better restored.
[0149] For example, the parameter extraction specification may stipulate that for the parameter recording files of service call instances under each parameter category, in addition to ensuring that the service call parameters of each parameter category are extracted, the parameter call sequence flag of each service call parameter must also be taken into account so that the extracted service call parameters are consistent with the call sequence during recording. And so on.
[0150] Since the parameter call sequence flag of the service call parameter before extraction is taken into consideration, the parameter extraction specification can be more specific and accurate. Specifically, the step of "determining the parameter extraction specification of the parameter recording file under the parameter category based on the parameter call sequence flag" may include:
[0151] Determine the parameter transfer logic of the service call parameter in the service call instance according to the parameter call sequence flag;
[0152] Based on the parameter transfer logic, a parameter extraction specification of the parameter recording file under the parameter category is generated.
[0153] The parameter transfer logic can describe the transfer logic of the service call parameters in the service call instance in the target service when the service call instance calls the target service. Since the parameter call sequence mark only records the call sequence of the service call parameters, after determining the parameter transfer logic, the scenario of the service call instance can be restored more accurately.
[0154] For example, when the service call instance records the process of the terminal calling the target service of the server, the parameter call sequence flag can be used to determine the parameter transfer logic between the terminal and the server to determine the interactive process of data request and response between the terminal and the server.
[0155] For example, when a service call instance records the mutual calling process within a target service system deployed on multiple distributed servers, the parameter call sequence flag can be used to determine the parameter passing logic within the target service system, such as the RPC call and response process, to determine the specific interaction process within the target service system.
[0156] After determining the parameter passing logic, a parameter extraction specification that can be used to guide the extraction of service call parameters can be generated. For example, the parameter extraction specification can be generated in a reviewable document format for testers to review; or, as another example, the parameter extraction specification can be generated in an executable code format so that by calling the parameter extraction specification, parameter recording files under each parameter category can be extracted to obtain the extracted service call parameters.
[0157] After confirming the parameter extraction specification, the parameter recording files under each parameter category can be extracted by following the parameter extraction specification to obtain service call parameters that can be used to restore the target service call process.
[0158] For example, when the target service depends on the response of its downstream dependent service, when recording the actual traffic of the target service under the initial version, the target service under the initial version needs to call its downstream dependent service to obtain the information replied by the downstream dependent service. When we determine the parameter extraction specification and extract the service call parameters that can be used for scene recovery through the parameter extraction specification, we can test it by injecting the extracted service call parameters into the target service under the target version, without the need for the target service under the target version to actually call its downstream dependent service. In this way, by reusing the traffic data recorded by the target service under the initial version, the traffic scenario at that time is reproduced. Subsequently, you only need to place the target service under the target version to be tested in the reproduced traffic scenario to conveniently test the target service under the target version.
[0159] After explaining the step of "extracting parameters from the parameter recording file based on the parameter category corresponding to the parameter recording file to obtain the extracted service call parameters", the step of "performing data integration processing on the extracted service call parameters to obtain integrated test cases" is further explained below. Specifically, the step of "performing data integration processing on the extracted service call parameters to obtain integrated test cases" may include:
[0160] Determine test-related attributes of the extracted service call parameters;
[0161] Based on the test association attribute, data integration processing is performed on the extracted service call parameters to obtain integrated test input data and test expected result data;
[0162] Generate test cases corresponding to service call instances based on test input data and test expected result data.
[0163] Among them, the test association attributes can be used to describe the relationship between service call parameters and test cases when generating test cases using service call parameters. For example, since the test case can include test input data and test expected result data, the test association attributes can be set accordingly to include test input and test expected results.
[0164] After determining the test-related attributes of the service call parameters, the extracted service call parameters can be subjected to data integration processing. For example, the service call parameters whose test-related attributes are test input can be integrated into test input data, and the service call parameters whose test-related attributes are test expected results can be integrated into test expected result data.
[0165] It is worth noting that the data integration process can be a combination of a series of steps, so that after executing the combination of steps, the test input data and the test expected result data required for generating the test case can be obtained. For example, the data integration process may include determining whether the extracted service call parameters belong to the test input data or the test expected result data in the test case, and for the service call parameters belonging to the test input data, organizing them in a way that is convenient for subsequent data injection, so that the obtained test input data is more convenient to use.
[0166] For example, data integration processing may include determining whether the extracted service call parameters belong to test input data or test expected result data in the test case, and, for the service call parameters that belong to the test expected result data, organizing them in a manner that is convenient for subsequent data comparison, so that the obtained test expected result data is easier to use.
[0167] After obtaining the test input data and the test expected result data, a test case corresponding to the service call instance can be generated according to the test input data and the test expected result data.
[0168] After generating the test cases required for testing the target service under the target version based on the recorded traffic data, the test cases can also be edited to increase the diversity of the test cases. Specifically, after the step of "performing data integration processing on the extracted service call parameters to obtain integrated test cases", the following can also be included:
[0169] Get the data editor corresponding to the target format;
[0170] The integrated test input data and the test result expected data are edited by a data editor to obtain the edited test input data and the test result expected data.
[0171] The data editor may be used to edit the service call parameters in the target format, such as creating, updating, reading, or deleting, etc. For example, the target format may be a text format, and the data editor corresponding to the text format may be VIM, a text editor for Unix and Unix-like systems.
[0172] In one embodiment, the tester can use VIM to edit the test input data or the test expected result data in the generated test case to obtain the edited test input data and the test expected result data, and generate a new test case based on the edited test input data and the test expected result data, thereby increasing the diversity of the test cases.
[0173] After generating the test cases required for testing the target service under the target version, these test cases can be combined to obtain a combined traffic playback file.
[0174] There are many ways to combine. For example, test cases can be classified according to their test objectives, and test cases with the same or similar test objectives can be combined into a test case set. For another example, test cases can be grouped in chronological order, complexity order, etc.
[0175] 104. Inject the test input data into the target service under the target version to obtain service operation result data of the target service under the target version for the test input data.
[0176] Since the traffic replay file includes at least one test case, and the test case includes test input data and test expected result data, to use the traffic replay file to perform service testing on the target service under the target version, the test input data can be first injected into the target service under the target version. Specifically, the step of "injecting the test input data into the target service under the target version to obtain the service running result data of the target service under the target version for the test input data" can include:
[0177] Parse the service call test parameters required to generate the service call test interface from the test input data;
[0178] Generate a service call test interface for the target service under the target version according to the service call test parameters;
[0179] Call the test interface through the calling service and inject the test data into the target service under the target version;
[0180] Gets the service running result data of the target service under the target version for the test input data.
[0181] Among them, the service call test interface can be an interface designed for testing the target service under the target version. Specifically, the service call test parameters can be passed into the service call test interface so that the target service under the target version can be called through the service call test interface, and the service operation result data of the target service under the target version can be obtained accordingly.
[0182] Therefore, to use the service call test interface as a channel for injecting test input data, the service call test parameters required to generate the service call test interface can first be parsed from the test input data of the test case.
[0183] In one embodiment, when recording the traffic data of the target service under the initial version, the service call parameters such as the request URL, request parameters, and request header in the HTTP request process are collected, and when the test case is subsequently generated, these service call parameters are added to the test input data of the test case. Then, when the service call test parameters required to generate the service call test interface are parsed from the test input data, the service call test parameters such as the request URL, request parameters, and request header can be parsed out, and the service call test interface of the target service under the target version can be generated by passing the parsed service call test parameters into the service call test interface.
[0184] Subsequently, the test data can be injected into the target service under the target version through the calling service call test interface, and the service operation result data of the target service under the target version for the test input data can be obtained. It is worth noting that by generating a service call test interface, when testing the target service under the target version, the generated service call test interface can be used to simulate the dependent interfaces that need to be called by the target service under the target version, for example, the downstream dependent services of the target service under the target version. Therefore, by the same token, the dependent interfaces of the target service under the target version can all be simulated, thereby greatly reducing the difficulty of testing the target service under the target version, and there is no need to prepare a test environment.
[0185] In one embodiment, reference Figure 3 For the target service module under the target version, it can be mocked by calling the service test interface method. Specifically, mock can refer to the use of a virtual object to create some objects that are not easy to construct or obtain for testing during the test process. It is worth noting that this solution uses the method of injection during recording and playback to mock out various data required for testing the target service at the target version with the real traffic data of the target service at the initial version, such as the cross-session data required when the target service under the target version needs to be cross-session, and various data of the target service in the session process under the target version, such as display input, cross-session data, rep implicit output and rsp implicit input during RPC calls, input during non-RPC calls, and other outputs, etc.
[0186] 105. Compare the service operation result data with the test expected result data.
[0187] Among them, the comparison can be used to detect whether the service operation result data is the same as the test expected result data, or whether they are consistent within a preset threshold range. Therefore, by comparing the service operation result data with the test expected result data, it can be determined whether the target service has any abnormalities or errors during the iteration process.
[0188] For example, the service operation result data of each test case can be compared with the expected test result data of the test case to obtain the test case pass rate of the target service under the target version, and the comparison result of the target service under the target version can be determined based on the test case pass rate.
[0189] Optionally, after obtaining the comparison result, the comparison result may be analyzed and reported.
[0190] 106. Based on the comparison results, determine the test results of the target service at the target version.
[0191] There can be many methods for determining the test results of the target service under the target version based on the comparison results. For example, the test result can be determined as passed when the comparison results are completely consistent, otherwise it is determined as failed. For another example, it can be set that when the comparison result is within a preset threshold range, the test result is determined as passed, otherwise it is transferred to the manual judgment unit; and so on.
[0192] The specific method of mapping the comparison results to the test results of the target service under the target version can be adjusted according to business needs, and this application does not impose any restrictions here.
[0193] Since the target service under the target version may have a certain degree of change compared to the target service under the initial version, when the target service under the target version is tested using a test case, for the test input data in the test case, the service operation result data of the target service under the target version may be consistent with the test expected result data, or may be inconsistent with the test expected result data. However, in any case, it is a record of the operation status of the target service under the target version. Therefore, new test cases can be generated using these data. Specifically, the service testing method described in the present application may also include:
[0194] Generate a test case using the test input data and the service operation result data;
[0195] Based on the generated test cases, the test case set for the target service is updated.
[0196] Therefore, after generating a new test case using the test input data and the service operation result data generated by the target service under the target version for the test input data, the generated test case can be used to update the test case set of the target service, for example, to add or replace it. This way, in addition to completing the service testing task, the service testing process can also record new test cases that appear during the service testing process, so that subsequent testing of target services under other versions can provide strong support.
[0197] As can be seen from the above, this embodiment can record the traffic data of the target service in the initial version to obtain the traffic recording file of the target service; obtain the test request of the target service in the target version; based on the test request, perform data integration processing on the traffic recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data; inject the test input data into the target service under the target version to obtain the service operation result data of the target service under the target version for the test input data; compare the service operation result data with the test expected result data; based on the comparison result, determine the test result of the target service at the target version.
[0198] The scheme obtains the real traffic data of the target service by recording the traffic data of the target service under the initial version, so that when the target service under the target version needs to be tested, the real traffic data can be used as test data to test the target service. In this way, there is no need to make a test function template for the target service or define the input and output rules of the test, but to replace it with the recorded real traffic data. Secondly, when the scheme obtains the test request of the target service at the target version, it can integrate the real traffic data of the target service to obtain multiple test cases required for the test. Further, by injecting the generated test case into the target service under the target version, the target service under the target version can be tested, and the scene when the target service under the initial version is called can be restored, so that the target service under the target version can be tested more accurately, so that there is no need to build a test environment or prepare additional test data. Therefore, the scheme improves the testing technology from many aspects and can effectively improve the efficiency of testing the target service.
[0199] Secondly, when generating the traffic recording file of the target service under the initial version, the solution analyzes the parameter categories to which the service call parameters in each service call instance belong, and when generating the traffic recording file, generates the corresponding parameter recording file according to the parameter category, so that the traffic recording file obtained by combining the parameter recording files is more organized, and also provides support for the subsequent steps of integrating the data of the traffic recording file to generate a traffic playback file, thereby contributing to improving the testing efficiency of the target service globally.
[0200] In addition, when generating a traffic playback file and injecting the traffic playback file into the target service under the target version, the solution ensures that the scene where the target service was called in the initial version can be accurately restored later by determining the extraction specifications of the parameter recording files under each parameter category, thereby improving the test efficiency of the target service under the target version. In addition, by generating a method for service call test interface, when performing service testing on the target service under the target version, there is no need to actually call the service interface of its upstream and downstream dependent services, which greatly facilitates the service testing of the target service.
[0201] According to the method described in the above embodiment, the following will give an example to further illustrate in detail.
[0202] In this embodiment, the service testing device is integrated in a server and a terminal as an example for explanation. The server can be a single server or a server cluster composed of multiple servers; the terminal can be a mobile phone, a tablet computer, a laptop computer and other devices.
[0203] like Figure 4 As shown, a service testing method, the specific process is as follows:
[0204] 201. The server records the traffic data of the target service in the initial version to obtain a traffic recording file of the target service.
[0205] In one embodiment, reference Figure 5 The service module in the figure is the target service in the initial version. The server can record the traffic data of the target service in the initial version by designing and developing a hook function, and can collect the input parameters, output parameters and function execution results of each service call instance by recording the traffic data.
[0206] In addition, reference Figure 5 It can also provide a use case management function to manage the data recorded at different recording points in the same session, thereby improving the management efficiency of the traffic data of the target service in the initial version.
[0207] Furthermore, in order to obtain the traffic recording file, the type of the collected traffic data can also be identified. Figure 5In this embodiment, service call parameters of standard basic type, protobuf type, XML type, JSON type, and user-defined type are identified from the traffic data. Subsequently, based on the parameter category to which each service call parameter belongs, an input parameter file can be generated according to the service interface, call interface, call sequence number, and input parameter sequence number; an output parameter file can be generated according to the service interface, call interface, call sequence number, and output parameter sequence number; a result file can be generated according to the service interface, call interface, call sequence number, and execution result. Furthermore, based on the generated input parameter file, output parameter file, and result file, the traffic recording file of the target service in the initial version can be obtained.
[0208] It is worth noting that in this embodiment, for non-protobuf type service call parameters, such as standard basic types, XML types, JSON types, and user-defined types, they can also be converted into protobuf types through protobuf converters and stored in text format. In addition, after the collected service call parameters of various types are converted into protobuf types, when the converted service call parameters need to be transmitted, the protobuf text can be converted into a byte sequence through protobuf text format serialization, and the byte sequence can be restored to protobuf text through deserialization to improve data transmission efficiency.
[0209] 202. The terminal sends a test request for a target service in a target version to the server.
[0210] When the target service is iterated to the target version, the tester can send a test request for the target service under the target version to the server through the terminal.
[0211] 203. The server obtains a test request for the target service at the target version.
[0212] 204. Based on the test request, the server performs data integration processing on the traffic recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data.
[0213] After obtaining the traffic recording file, it is also necessary to generate a traffic playback file including several test cases before testing the target service under the target version. Specifically, based on the test request obtained by the server, the parameter recording file required to generate the test case can be selected from the traffic recording file, and based on the parameter category corresponding to the parameter recording file, the parameter recording file is extracted to obtain the extracted service call parameters. Furthermore, the extracted service call parameters can be processed by data integration to obtain the integrated test case, and the integrated test case can be combined to finally obtain the traffic playback file.
[0214] 205. The server injects the test input data into the target service under the target version, and obtains service operation result data of the target service under the target version for the test input data.
[0215] In one embodiment, reference Figure 6 , you can design a tool called playback_tools that can replay service call requests, and determine which test case in the traffic playback file to replay by passing in the test case name.
[0216] After determining the test case to be replayed, the service call test parameters required to generate the service call test interface can be parsed from the test input data of the test case to generate the service call test interface for testing. Figure 6 In the figure, mock(name, input, output & result) is the generated service call test interface. The "name", "input", "output", and "result" in the service call test interface are the service call test parameters parsed from the test input data of the test case.
[0217] The test input data can be injected into the target service under the target version by calling the generated service call test interface, and the service operation result data of the target service under the target version for the test input data can be obtained accordingly.
[0218] It is worth noting that reference Figure 6 When injecting test input data, that is, restoring the scenario in which the target service was called in the initial version, the relevant logic calculations will be performed to accurately restore the scenario at that time. For example, the call logic during the RPC call can be calculated to accurately restore the scenario in which the target service made an RPC call in the initial version.
[0219] 206. The server compares the service operation result data with the test expected result data.
[0220] After obtaining the service running result data of the target service for the test input data, the server can compare the service running result data with the expected test result data in the test case, so that the test result of the target service in the target version can be further determined based on the comparison result.
[0221] 207. The server determines the test result of the target service at the target version based on the comparison result, and sends the test result to the terminal.
[0222] In this embodiment, reference Figure 6 After the terminal obtains the test results, the tester can also edit the existing test cases by using the data editor VIM corresponding to the text format. For example, the existing test cases can be edited by using the change command of VIM, so that the edited test input data and the expected test result data can be obtained, and a new test case can be generated according to the edited test input data and the expected test result data. Therefore, the test case set of the target service can be updated, and the edited test case can be used as an available test case for the next service test.
[0223] As can be seen from the above, the embodiment of the present application can obtain the real flow data of the target service by recording the flow data of the target service under the initial version, so that when the target service under the target version needs to be tested, the real flow data can be used as test data to test the target service. In this case, there is no need to make a test function template for the target service or define the input and output rules of the test, but to replace it with the real flow data obtained by recording. Secondly, when the test request of the target service at the target version is obtained, the embodiment of the present application can be processed by data integration of the real flow data of the target service, so as to obtain multiple test cases required for testing. Further, by injecting the generated test case into the target service under the target version, the target service under the target version is tested, and the scene when the target service under the initial version is called can be restored, so that the target service under the target version can be tested more accurately, so that there is no need to build a test environment or prepare additional test data. Therefore, the embodiment of the present application improves the testing technology from many aspects, which can effectively improve the efficiency of testing the target service.
[0224] In addition, the solution can output the collected service call parameters into text format, and reconstruct the input and output by analyzing the text format, so that they can be accurately injected into the target service under the target version during playback. Moreover, the text format can support users to form different inputs through data editing, so as to obtain different test cases, increasing the diversity of test cases.
[0225] In order to better implement the above method, the embodiment of the present application also provides a service testing device, wherein the service testing device can be integrated in a server or a terminal. The server can be a single server or a server cluster composed of multiple servers; the terminal can be a mobile phone, a tablet computer, a laptop computer, and other devices.
[0226] For example, Figure 7 As shown, the service testing device may include a recording unit 301, an acquisition unit 302, an integration unit 303, an injection unit 304, a comparison unit 305 and a determination unit 306, as follows:
[0227] The recording unit 301 is used to record the traffic data of the target service in the initial version to obtain a traffic recording file of the target service;
[0228] An acquisition unit 302 is used to acquire a test request of the target service at a target version;
[0229] An integration unit 303 is used to perform data integration processing on the traffic recording file based on the test request to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data;
[0230] An injection unit 304 is used to inject the test input data into the target service under the target version to obtain service operation result data of the target service under the target version for the test input data;
[0231] A comparison unit 305, used to compare the service operation result data with the test expected result data;
[0232] The determination unit 306 is configured to determine a test result of the target service at the target version based on the comparison result.
[0233] In one embodiment, reference Figure 8 , the traffic recording file includes a parameter recording file of at least one service call instance, and the parameter recording file includes at least one service call parameter in a target format; the integration unit 303 may include:
[0234] The file selection subunit 3031 may be used to select a parameter recording file required to generate a test case from the traffic recording file based on the test request;
[0235] The parameter extraction subunit 3032 may be used to extract parameters from the parameter recording file based on the parameter category corresponding to the parameter recording file to obtain the extracted service call parameters;
[0236] The data integration subunit 3033 may be used to perform data integration processing on the extracted service call parameters to obtain integrated test cases;
[0237] The use case combination subunit 3034 can be used to combine the integrated test cases to obtain a combined traffic playback file.
[0238] In one embodiment, the service call parameter before extraction carries a parameter call sequence flag; the parameter extraction subunit 3032 can be used to:
[0239] Based on the parameter call sequence flag, a parameter extraction specification of the parameter recording file under the parameter category is determined; by following the parameter extraction specification, the parameter recording file under the parameter category is extracted to obtain the extracted service call parameters.
[0240] In one embodiment, the parameter extraction subunit 3032 may be specifically used for:
[0241] According to the parameter call sequence flag, the parameter transfer logic of the service call parameter in the service call instance is determined; based on the parameter transfer logic, the parameter extraction specification of the parameter recording file under the parameter category is generated.
[0242] In one embodiment, the data integration subunit 3033 may be used to:
[0243] Determine the test association attributes of the extracted service call parameters; based on the test association attributes, perform data integration processing on the extracted service call parameters to obtain integrated test input data and test expected result data; and generate a test case corresponding to the service call instance based on the test input data and the test expected result data.
[0244] In one embodiment, the data integration subunit 3033 may also be used to:
[0245] Acquire a data editor corresponding to the target format; and edit the integrated test input data and test result expected data through the data editor to obtain edited test input data and test result expected data.
[0246] In one embodiment, reference Fig. 9 , the recording unit 301 may include:
[0247] The traffic acquisition subunit 3011 may be used to acquire traffic data of a target service under the initial version, wherein the traffic data includes at least one service call instance;
[0248] The parameter parsing subunit 3012 may be used to parse the service call instance to obtain the service call parameters in the target format;
[0249] The file generation subunit 3013 may be used to generate a parameter recording file of the service call instance corresponding to the parameter category based on the parameter category to which the service call parameter belongs;
[0250] The file combination subunit 3014 can be used to combine the generated parameter recording files to generate the traffic recording file of the target service.
[0251] In one embodiment, the parameter parsing subunit 3012 may be used to:
[0252] Obtain traffic data of the target service under the initial version, wherein the traffic data includes at least one service call instance; perform parameter parsing on the service call instance to obtain service call parameters under the target format; based on the parameter category to which the service call parameters belong, generate a parameter recording file of the service call instance corresponding to the parameter category; combine the generated parameter recording files to generate a traffic recording file of the target service.
[0253] In one embodiment, the parameter parsing subunit 3012 may be specifically used for:
[0254] The original service call parameters are collected from the service call instance; the type of the original service call parameters is identified; and based on the identification result, the original service call parameters are parsed into service call parameters in a target format.
[0255] In one embodiment, the parameter parsing subunit 3012 may be specifically used for:
[0256] Determine the parameter category to which the service call parameter belongs; and group the service call parameters according to the parameter category to obtain a parameter recording file of the service call instance corresponding to the parameter category.
[0257] In one embodiment, reference Fig.10 , the injection unit 304 may include:
[0258] The parameter parsing subunit 3041 may be used to parse the test input data to obtain the service call test parameters required to generate the service call test interface;
[0259] The interface generation subunit 3042 may be used to generate a service call test interface of the target service under the target version according to the service call test parameters;
[0260] The data injection subunit 3043 may be used to inject the test data into the target service under the target version by calling the service call test interface;
[0261] The result acquisition subunit 3044 may be used to acquire service operation result data of the target service under the target version for the test input data.
[0262] In one embodiment, reference Fig.11 , the service testing device may further include:
[0263] A test case generating unit 307 may be used to generate a test case using the test input data and the service operation result data;
[0264] The updating unit 308 may be configured to update the test case set of the target service based on the generated test case.
[0265] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0266] As can be seen from the above, in the service testing device of this embodiment, the recording unit 301 records the traffic data of the target service at the initial version to obtain the traffic recording file of the target service; the acquisition unit 302 obtains the test request of the target service at the target version; the integration unit 303 performs data integration processing on the traffic recording file based on the test request to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data; the injection unit 304 injects the test input data into the target service under the target version to obtain the service operation result data of the target service under the target version for the test input data; the comparison unit 305 compares the service operation result data with the test expected result data; the determination unit 306 determines the test result of the target service at the target version based on the comparison result.
[0267] The scheme obtains the real traffic data of the target service by recording the traffic data of the target service under the initial version, so that when the target service under the target version needs to be tested, the real traffic data can be used as test data to test the target service. In this way, there is no need to make a test function template for the target service or define the input and output rules of the test, but to replace it with the recorded real traffic data. Secondly, when the scheme obtains the test request of the target service at the target version, it can integrate the real traffic data of the target service to obtain multiple test cases required for the test. Further, by injecting the generated test case into the target service under the target version, the target service under the target version can be tested, and the scene when the target service under the initial version is called can be restored, so that the target service under the target version can be tested more accurately, so that there is no need to build a test environment or prepare additional test data. Therefore, the scheme improves the testing technology from many aspects and can effectively improve the efficiency of testing the target service.
[0268] In addition, the embodiment of the present application also provides a computer device, which can be a server or a terminal. Fig.12 As shown, it shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application, specifically:
[0269] The computer device may include a memory 401 having one or more computer-readable storage media, an input unit 402, a display unit 403, a processor 404 having one or more processing cores, and a power supply 405. Those skilled in the art will appreciate that Fig.12 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
[0270] The memory 401 can be used to store software programs and modules, and the processor 404 executes various functional applications and data processing by running the software programs and modules stored in the memory 401. The memory 401 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device (such as audio data, a phone book, etc.), etc. In addition, the memory 401 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 401 may also include a memory controller to provide the processor 404 and the input unit 402 with access to the memory 401.
[0271] The input unit 402 can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Specifically, in a specific embodiment, the input unit 402 may include a touch-sensitive surface and other input devices. The touch-sensitive surface, also known as a touch display screen or a touch pad, can collect the user's touch operations on or near it (such as the user's operation on or near the touch-sensitive surface using any suitable object or accessory such as a finger, a stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch-sensitive surface may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 404, and can receive and execute the command sent by the processor 404. In addition, the touch-sensitive surface can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch-sensitive surface, the input unit 402 may also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0272] The display unit 403 can be used to display information input by the user or information provided to the user and various graphical user interfaces of the computer device, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit 403 may include a display panel. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch-sensitive surface may cover the display panel. When the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor 404 to determine the type of touch event. Subsequently, the processor 404 provides a corresponding visual output on the display panel according to the type of touch event. Although in Figure 6 In the embodiment, the touch-sensitive surface and the display panel are used as two independent components to realize input and output functions, but in some embodiments, the touch-sensitive surface and the display panel can be integrated to realize input and output functions.
[0273] The processor 404 is the control center of the computer device, which uses various interfaces and lines to connect various parts of the entire mobile phone, and executes various functions of the computer device and processes data by running or executing software programs and / or modules stored in the memory 401, and calling data stored in the memory 401. Optionally, the processor 404 may include one or more processing cores; preferably, the processor 404 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 404.
[0274] The computer device also includes a power supply 405 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 404 through a power management system, so that the power management system can manage charging, discharging, and power consumption management. The power supply 405 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0275] Although not shown, the computer device may also include a camera, a Bluetooth module, etc., which will not be described in detail here. Specifically in this embodiment, the processor 404 in the computer device will load the executable files corresponding to the processes of one or more application programs into the memory 401 according to the following instructions, and the processor 404 will run the application programs stored in the memory 401 to achieve various functions, as follows:
[0276] Record the traffic data of the target service in the initial version to obtain the traffic recording file of the target service; obtain the test request of the target service in the target version; based on the test request, perform data integration processing on the traffic recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data; inject the test input data into the target service under the target version to obtain the service operation result data of the target service under the target version for the test input data; compare the service operation result data with the test expected result data; based on the comparison result, determine the test result of the target service in the target version.
[0277] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0278] As can be seen from the above, the computer device of this embodiment can obtain the real traffic data of the target service by recording the traffic data of the target service under the initial version, so that when the target service under the target version needs to be tested, the real traffic data can be used as test data to test the target service. In this case, there is no need to make a test function template for the target service or define the input and output rules of the test, but to replace it with the real traffic data obtained by recording. Secondly, when the computer device of this embodiment obtains the test request of the target service at the target version, it can perform data integration processing on the real traffic data of the target service to obtain multiple test cases required for testing. Further, by injecting the generated test case into the target service under the target version, the target service under the target version is tested, and the scene when the target service under the initial version is called can be restored, so that the target service under the target version can be tested more accurately, so that there is no need to build a test environment or prepare additional test data. Therefore, the computer device of this embodiment improves the testing technology from many aspects, which can effectively improve the efficiency of testing the target service.
[0279] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0280] To this end, an embodiment of the present application provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any service testing method provided in the embodiment of the present application. For example, the instructions can execute the following steps:
[0281] Record the traffic data of the target service in the initial version to obtain the traffic recording file of the target service; obtain the test request of the target service in the target version; based on the test request, perform data integration processing on the traffic recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data; inject the test input data into the target service under the target version to obtain the service operation result data of the target service under the target version for the test input data; compare the service operation result data with the test expected result data; based on the comparison result, determine the test result of the target service in the target version.
[0282] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0283] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0284] Since the instructions stored in the storage medium can execute the steps in any service testing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any service testing method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0285] According to one aspect of the present application, a computer program product or computer program is provided, which includes computer instructions, which are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in various optional implementations of the above-mentioned service testing. The above is a detailed introduction to a service testing method, device and system provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the ideas of the present application, there will be changes in the specific implementation methods and scope of application. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A service testing method, characterized in that: include: Obtaining traffic data of a target service in an existing network under an initial version, wherein the target service includes multiple call interfaces, the traffic data includes multiple service call instances, and the service call instances have corresponding call sequence numbers; Collecting original service call parameters from the service call instance, and parsing the original service call parameters into service call parameters in a target format; Based on the parameter category to which the service call parameter belongs, the service call parameter is grouped and processed to obtain a parameter recording file of the service call instance corresponding to the parameter category, wherein the parameter category includes an input parameter category, an output parameter category, and a function execution result category, and the parameter recording file includes at least one service call parameter, and the service call parameter carries a parameter call sequence flag; Combining the parameter recording files to generate a traffic recording file of the target service, the traffic recording file including a parameter recording file of at least one service call instance; Obtaining a test request for the target service at the target version, the test request carrying interface identification information of at least one calling interface; From the traffic recording file, select a target parameter recording file of a target service call instance whose call interface information matches the interface identification information and whose call sequence number belongs to a call sequence number range; Based on the parameter call sequence flag of the service call parameter in the target parameter recording file, extract the parameters of the target parameter recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data; Parsing the service call test parameters required to generate the service call test interface from the test input data; Generate a service call test interface for the target service under the target version according to the service call test parameters; Injecting the test input data into the target service under the target version by calling the service call test interface; Obtain service operation result data of the target service under the target version for the test input data; Comparing the service operation result data with the test expected result data; Based on the comparison result, a test result of the target service at the target version is determined.
2. The service testing method according to claim 1, characterized in that: The step of extracting parameters from the target parameter recording file based on the parameter call sequence flag of the service call parameter in the target parameter recording file to obtain an integrated traffic playback file includes: Based on the parameter call sequence flag of the service call parameter in the target parameter recording file, extract the parameters of the target parameter recording file to obtain the extracted service call parameters; Performing data integration processing on the extracted service call parameters to obtain integrated test cases; The integrated test cases are combined to obtain a combined traffic playback file.
3. The service testing method according to claim 2, characterized in that: Based on the parameter call sequence mark of the service call parameter in the target parameter recording file, the target parameter recording file is subjected to parameter extraction to obtain the extracted service call parameter, including: Determining a parameter extraction specification of a target parameter recording file under the parameter category based on the parameter call sequence flag; By following the parameter extraction specification, the target parameter recording file under the parameter category is subjected to parameter extraction to obtain the extracted service call parameters.
4. The service testing method according to claim 3, characterized in that: Determining a parameter extraction specification of a target parameter recording file under the parameter category based on the parameter call sequence flag includes: Determining the parameter transfer logic of the service call parameter in the target service call instance according to the parameter call sequence flag; Based on the parameter transfer logic, a parameter extraction specification of the target parameter recording file under the parameter category is generated.
5. The service testing method according to claim 2, characterized in that: Performing data integration processing on the extracted service call parameters to obtain integrated test cases, including: Determining a test-related attribute of the extracted service call parameter; Based on the test association attributes, data integration processing is performed on the extracted service call parameters to obtain integrated test input data and test expected result data; A test case corresponding to the service call instance is generated according to the test input data and the test expected result data.
6. The service testing method according to claim 5, characterized in that: After performing data integration processing on the extracted service call parameters based on the test association attributes to obtain integrated test input data and test expected result data, the method further includes: Obtaining a data editor corresponding to the target format; The integrated test input data and test result expected data are edited by the data editor to obtain edited test input data and test result expected data.
7. The service testing method according to claim 1, characterized in that: The step of parsing the original service call parameters into service call parameters in a target format includes: Performing type identification on the original service call parameter; Based on the recognition result, the original service call parameters are parsed into service call parameters in a target format.
8. The service testing method according to claim 1, characterized in that: The method further comprises: Generate a new test case using the test input data and the service operation result data; Based on the newly added test case, the test case set of the target service is updated.
9. A service testing device, characterized in that: include: A recording unit, used for obtaining traffic data of a target service in an existing network under an initial version, wherein the target service includes a plurality of call interfaces, the traffic data includes a plurality of service call instances, and the service call instances have corresponding call sequence numbers; collecting original service call parameters from the service call instances, and parsing the original service call parameters into service call parameters under a target format; grouping the service call parameters based on the parameter categories to which the service call parameters belong, and obtaining a parameter recording file of the service call instance corresponding to the parameter category, wherein the parameter category includes an input parameter category, an output parameter category, and a function execution result category, and the parameter recording file includes at least one service call parameter, and the service call parameter carries a parameter call sequence flag; combining the parameter recording files to generate a traffic recording file of the target service, wherein the traffic recording file includes a parameter recording file of at least one service call instance; An acquisition unit, configured to acquire a test request for the target service at a target version, wherein the test request carries interface identification information of at least one calling interface; An integration unit is used to select, from the traffic recording file, a target parameter recording file of a target service calling instance whose calling interface information matches the interface identification information and whose calling sequence number belongs to a calling sequence number range; Based on the parameter call sequence flag of the service call parameter in the target parameter recording file, extract the parameters of the target parameter recording file to obtain an integrated traffic playback file, wherein the traffic playback file includes at least one test case, and the test case includes test input data and test expected result data; An injection unit is used to parse the service call test parameters required to generate the service call test interface from the test input data; generate the service call test interface of the target service under the target version according to the service call test parameters; inject the test input data into the target service under the target version by calling the service call test interface; and obtain the service operation result data of the target service under the target version for the test input data; A comparison unit, used for comparing the service operation result data with the test expected result data; The determination unit is used to determine the test result of the target service at the target version based on the comparison result.
10. A computer device, characterized in that: It comprises a memory and a processor; the memory stores an application program, and the processor is used to run the application program in the memory to execute the operations in the service testing method according to any one of claims 1 to 8.
11. A storage medium, characterized in that: The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the service testing method according to any one of claims 1 to 8.
