Data processing method, device, electronic device and storage medium
By filtering and replaying the historical service data corresponding to the test scenarios, the problems of low interface testing effectiveness and resource utilization in the existing technology are solved, and more efficient interface testing is achieved.
Patent Information
- Application Number
- CN202310169189.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-14
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2043-02-14
AI Technical Summary
In the prior art, online traffic recording and playback are used for interface testing, but due to the randomness of traffic, the test effectiveness and utilization of traffic resources are low.
By obtaining the test scenario configuration information and historical service data of the target service interface, the target test scenario is determined based on this information, and the historical service data is filtered, the test data set corresponding to the target test scenario is obtained, and the test data is played back to obtain the test results.
It improves the effectiveness and efficiency of interface testing, improves the utilization rate of test data, and avoids the waste of test resources.
Smart Images

Figure CN116112751B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of testing technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art
[0002] In the related art, in order to determine whether there is a problem with the interface code, online traffic can be recorded and replayed to reduce the test cost. However, the recorded online traffic is random, resulting in low test effectiveness and low utilization of traffic resources. Summary of the invention
[0003] The present disclosure provides a data processing method, device, electronic device and storage medium to at least solve the problems of low test effectiveness and low utilization of traffic resources in related technologies. The technical solution of the present disclosure is as follows:
[0004] According to a first aspect of an embodiment of the present disclosure, there is provided a data processing method, including:
[0005] Obtain test scenario configuration information and multiple historical business data of the target business interface;
[0006] Determine a target test scenario based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each of the configuration objects;
[0007] Based on the target test scenario, the multiple pieces of historical business data are screened to obtain a test data set corresponding to the target test scenario; each of the at least one piece of test data included in the test data set is a piece of historical business data among the multiple pieces of historical business data;
[0008] A test data set corresponding to the target test scenario is replayed to obtain a test result for the service interface to be tested under the target test scenario.
[0009] Optionally, each of the test data in the test data set includes historical request data and historical response data; and the replaying test of the test data set corresponding to the target test scenario to obtain a test result for the service interface to be tested under the target test scenario includes:
[0010] Sending historical request data of each test data in the test data set to the service interface to be tested, and obtaining test response data output by the service interface to be tested;
[0011] Based on the historical response data of each of the test data in the test data set and the test response data, the test result for the service interface to be tested in the target test scenario is determined.
[0012] Optionally, determining the target test scenario based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each configuration object includes:
[0013] Determine a set of attribute values for each of the configuration objects based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each of the configuration objects;
[0014] Cartesian product processing is performed on the attribute value sets of each of the configuration objects to obtain at least one attribute value combination; the at least one attribute value combination includes a target attribute value combination, and the target attribute value combination indicates the target test scenario.
[0015] Optionally, the filtering of the plurality of historical business data based on the target test scenario to obtain a test data set corresponding to the target test scenario includes:
[0016] Determine attribute information of target historical business data; the target historical business data is any one of the multiple historical business data;
[0017] In a case where the attribute information of the target historical business data matches the target attribute value combination corresponding to the target test scenario, the target historical business data is used as a piece of test data in the test data set.
[0018] Optionally, the method further includes:
[0019] Determine the test data upper limit threshold corresponding to the target test scenario;
[0020] When the number of at least one test data item included in the test data set reaches the test data upper limit threshold, the test data set is saved.
[0021] Optionally, the method further includes:
[0022] Determining a validity period of the test data set based on a life cycle of each of the test data in the test data set;
[0023] When the validity period of the test data set indicates that the test data set is in a valid state, the test data set is used as a reusable test data set in the target test scenario.
[0024] Optionally, the method further includes:
[0025] Determining at least one piece of business-valid test data from the test data set based on the business validity identifier of each of the test data in the test data set;
[0026] The at least one piece of valid service test data is used as recommended test data.
[0027] According to a second aspect of an embodiment of the present disclosure, there is provided a data processing device, including:
[0028] An acquisition module is configured to acquire test scenario configuration information and multiple pieces of historical business data of a target business interface;
[0029] A scenario determination module, configured to determine a target test scenario based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each of the configuration objects;
[0030] The data screening module is configured to perform screening on the multiple historical business data based on the target test scenario to obtain a test data set corresponding to the target test scenario; each of the at least one test data included in the test data set is a historical business data among the multiple historical business data.
[0031] The test module is configured to perform a playback test on a test data set corresponding to the target test scenario to obtain a test result for the service interface to be tested under the target test scenario.
[0032] Optionally, the test module includes:
[0033] A data interaction unit is configured to send the historical request data of each test data in the test data set to the service interface to be tested, and obtain the test response data output by the service interface to be tested;
[0034] The comparison unit is configured to determine the test result for the service interface to be tested in the target test scenario based on the historical response data and the test response data of each test data in the test data set.
[0035] Optionally, the scene determination module includes:
[0036] a configuration object attribute value set determining unit, configured to determine an attribute value set of each configuration object based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each configuration object;
[0037] The target test scenario determination unit is configured to perform Cartesian product processing according to the attribute value sets of each configuration object to obtain at least one attribute value combination; the at least one attribute value combination includes a target attribute value combination, and the target attribute value combination indicates the target test scenario.
[0038] Optionally, the data screening module includes:
[0039] An attribute information determining unit is configured to determine attribute information of target historical business data; the target historical business data is any one of the multiple historical business data;
[0040] The attribute matching unit is configured to execute, when the attribute information of the target historical business data matches the target attribute value combination corresponding to the target test scenario, using the target historical business data as a test data in the test data set.
[0041] Optionally, the device further comprises:
[0042] A threshold determination unit, configured to determine an upper threshold of the test data corresponding to the target test scenario;
[0043] The test data set determining unit is configured to save the test data set when the number of at least one test data included in the test data set reaches the test data upper limit threshold.
[0044] Optionally, the device further comprises:
[0045] a validity period determination unit, configured to determine the validity period of the test data set based on the life cycle of each of the test data in the test data set;
[0046] The reuse determination unit is configured to use the test data set as a reusable test data set in the target test scenario when the validity period of the test data set indicates that the test data set is in a valid state.
[0047] Optionally, the device further comprises:
[0048] A service validity determination unit, configured to execute a service validity identification based on each of the test data in the test data set, and determine at least one service valid test data from the test data set;
[0049] The recommendation determination unit is configured to execute the at least one valid service test data as the recommended test data.
[0050] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement any data processing method described in the first aspect of the embodiment of the present disclosure.
[0051] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute a data processing method as described in any one of the first aspect of the embodiments of the present disclosure.
[0052] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement a data processing method as described in any one of the first aspect of the embodiments of the present disclosure.
[0053] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0054] The technical solution provided by the embodiment of the present disclosure determines the target test scenario based on at least one configuration object in the test scenario configuration information and the configuration conditions corresponding to each configuration object; then based on the target test scenario, multiple historical business data of the target business interface are screened to obtain a test data set corresponding to the target test scenario, and each test data included in the test data set is a historical business data among the multiple historical business data; thus, the test data set corresponding to the target test scenario can be replayed to obtain the test results for the business interface to be tested under the target test scenario. The technical solution provided by the embodiment of the present disclosure screens out the test data set corresponding to the target test scenario, so that the target test scenario can be effectively covered during the playback test, thereby improving the effectiveness of the interface test, and also effectively improving the interface test efficiency and the utilization rate of the test data, avoiding the waste of test resources.
[0055] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0057] Figure 1 is a schematic diagram of an application environment according to an exemplary embodiment;
[0058] Figure 2 is a flowchart of a data processing method according to an exemplary embodiment;
[0059] Figure 3 is a flowchart of another data processing method according to an exemplary embodiment;
[0060] Figure 4is a schematic diagram of a test scenario indicated by a combination of attribute values according to an exemplary embodiment;
[0061] Figure 5 is a block diagram of a data processing device according to an exemplary embodiment;
[0062] Figure 6 is a block diagram of an electronic device for implementing a data processing method according to an exemplary embodiment;
[0063] Figure 7 is a block diagram of another electronic device for implementing a data processing method according to an exemplary embodiment. DETAILED DESCRIPTION
[0064] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0065] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0066] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0067] See also Figure 1 , which is a schematic diagram of an application environment of a data processing method according to an exemplary embodiment, the application environment may include a terminal 110, a server 120, a server 130 and a server 140, the terminal 110 and the server 120 may be connected via a wired network or a wireless network, and the servers 120, the server 130 and the server 140 may be connected via a wired network or a wireless network.
[0068] The terminal 110 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc., but is not limited thereto. An application (Application, referred to as App) may be installed in the terminal 110. The application may be an independent application or a subroutine in an independent application. The user of the terminal 110 may log in to the application through pre-registered user information, which may include an account number and a password. The server 120 may be a server that provides background services for the application in the terminal 110, or may be other servers that are connected and communicated with the background service server of the application. It may be a single server or a server cluster composed of multiple servers. The server 140 may be a server that provides services to be tested, and may be a single server or a server cluster composed of multiple servers. The server 130 may be a server that provides interface testing services, and may be a single server or a server cluster composed of multiple servers.
[0069] In the embodiment of the present disclosure, the terminal 110 generates historical business data when communicating with the server 120, and the historical business data may include historical request data and historical response data. The server 130 copies and stores a plurality of historical business data, and determines the specific test scenario to be covered based on the test scenario configuration information, that is, the target test scenario, and then can filter out part of the historical business data from the plurality of historical business data to form a test data set corresponding to the target test scenario. The server 130 sends the test data set corresponding to the target test scenario to the server 140 to simulate the terminal's request to the server 140, and obtains the test response data returned by the server 140. The server 130 compares the historical response data and the test response data in the test data set, so as to determine the test result of the service interface to be tested in the server 140 under the target test scenario. In the embodiment of the present disclosure, the historical business data is used as the test data, which reduces the construction cost of the test data, and can ensure that the target test scenario is covered during the interface test, improves the effectiveness of the interface test, and effectively improves the interface test efficiency and the utilization rate of the test data.
[0070] In addition, it should be noted that Figure 1 What is shown is only one application environment provided by the present disclosure. In actual application, other application environments may also be included. For example, the server 120, the server 130 and the server 140 are the same server.
[0071] Figure 2 is a flow chart of a data processing method according to an exemplary embodiment. Figure 2 As shown, the method may include the following steps:
[0072] In step S210, test scenario configuration information and multiple pieces of historical business data of the target business interface are obtained.
[0073] In the disclosed embodiment, the data processing method is implemented based on traffic recording and playback. Traffic recording and playback is a method of recording the real request traffic and real response traffic of the online interface, simulating it in other environments, and comparing the request results (i.e., responses) in different environments to determine whether there is a problem with the interface code. The test data used for traffic recording and playback is real, which can reduce the construction cost of the test data.
[0074] In the embodiment of the present disclosure, the multiple historical service data of the target service interface are the real request traffic and the real response traffic recorded in the traffic recording playback, such as Figure 3 As shown, each piece of historical business data may include request data and response data corresponding to the request data.
[0075] In the disclosed embodiments, the test scenario configuration information is pre-configured information for describing the test scenarios to be covered, and may include at least one configuration object and configuration conditions corresponding to each configuration object. The configuration object and its configuration conditions may indicate characteristics of a specific test environment, and may also serve as rules for screening multiple historical business data, thereby screening out historical business data that matches a specific test environment as test data under the specific test environment, thereby ensuring coverage of specific test scenarios in playback testing. At the same time, the test scenario configuration information based on the configuration objects and configuration conditions is easily extensible, making it convenient for staff to add, delete or modify the test scenario configuration information for different interface testing tasks.
[0076] In step S230, a target test scenario is determined based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each configuration object.
[0077] In the disclosed embodiment, the configuration object may be a request header, a response header, a request parameter or a response parameter, etc. The configuration condition is a limitation on the attribute value of the configuration object. The configuration object and its configuration condition may indicate the characteristics of a specific test environment, that is, may indicate the target test environment. Therefore, in the disclosed embodiment, the staff can formulate a specific test scenario by designing the configuration objects and configuration conditions in the test scenario configuration information, so that the specified business scenario can be accurately covered without manual retesting, which effectively improves the efficiency of interface testing and avoids the waste of testing resources.
[0078] In one embodiment of the present disclosure, Figure 3As shown, by combining at least one configuration object and the configuration conditions corresponding to each configuration object, multiple test scenarios can be determined, and the multiple test scenarios include the target test scenario.
[0079] In step S231, based on at least one configuration object in the test scenario configuration information and the configuration conditions corresponding to each configuration object, a set of attribute values of each configuration object is determined.
[0080] It can be understood that the configuration condition is a limitation on the attribute value of the configuration object, and the configuration condition may include but is not limited to equal / not equal, contain / not contain, belong / not belong, greater than / not greater than, less than / not less than, empty / not empty, set size matching, rounding matching of specified digits, regular matching, etc. Taking a configuration object as an example, under the limitation of the corresponding configuration condition, the attribute value of the configuration object may have one or more, so that one or more attribute values constitute the attribute value set of the configuration object.
[0081] In step S233, Cartesian product processing is performed on the attribute value sets of each configuration object to obtain at least one attribute value combination; the at least one attribute value combination includes a target attribute value combination, and the target attribute value combination indicates a target test scenario.
[0082] The Cartesian product is the direct product of multiple sets. For example, the Cartesian product of two sets X and Y can be expressed as X×Y. The result of the Cartesian product is all possible ordered pairs where the first object is a member of X and the second object is a member of Y. For example, Figure 3 As shown, the corresponding attribute value set S of configuration object A under the limitation of configuration condition 1 A For 1 , A 2}, that is, the attribute value of configuration object A can be A1 or A2, then configuration object A can divide the test scenarios into two categories, and the corresponding attribute value set S of configuration object B under the limitation of configuration condition 2 B For {B 1 , B 2 , B 3}, then configuration object B can divide the test scenarios into three categories. Similarly, after the attribute value sets of N configuration objects are processed by Cartesian product, an N-ary Cartesian product can be obtained:
[0083] A×B...×N={(a,b,...,n)|a∈S A ∧b∈S B ...∧n∈S N}; (1)
[0084] Among them, (a, b, ..., n) is any possible combination of attribute values, corresponding to a type of test scenario, that is, a combination of attribute values can describe the characteristics of the corresponding test scenario. In this way, multiple test scenarios can be indicated at the same time. Figure 3 The test scenarios 1, 2 and 3 shown are only examples and are not the only limitation on the number of test scenarios. The target test scenario can be any test scenario among the multiple test scenarios.
[0085] Furthermore, each attribute value combination in the obtained at least one attribute value combination may correspond to a test scenario, but not every test scenario corresponds to an actual business, so at least one attribute value combination may be screened to eliminate test scenarios that will not appear in actual business. Figure 4 is a schematic diagram of a test scenario indicated by a combination of attribute values according to an exemplary embodiment. Figure 4 As shown, the configuration object A and the corresponding configuration condition 1 can constitute a screening rule for historical business data. Among all the test scenarios indicated by A×B...×Z, some of them are invalid scenarios, that is, Figure 4 The test scene in the dashed box.
[0086] In the above embodiment, by utilizing the Cartesian product combination method, at least one attribute value combination can be determined based on at least one configuration object in the test scenario configuration information and the configuration conditions corresponding to each configuration object. Each attribute value combination can indicate a type of test scenario, thereby realizing the designation of a specific test scenario. At the same time, each attribute value combination can be used as a rule for subsequent screening of historical business data. In addition, the test scenario configuration information composed of configuration objects and configuration conditions is easily extensible, which is convenient for staff to add, delete or modify configuration objects and configuration conditions for different interface testing tasks.
[0087] In step S250, based on the target test scenario, multiple historical business data are screened to obtain a test data set corresponding to the target test scenario; each of the at least one test data included in the test data set is a historical business data among the multiple historical business data.
[0088] In the disclosed embodiment, multiple pieces of historical business data of a target business interface are screened to obtain a test data set corresponding to a target test scenario, so that a playback test in the target test scenario can be implemented using the test data set.
[0089] In one embodiment of the present disclosure, step S250 may specifically include:
[0090] In step S251, attribute information of target historical business data is determined; the target historical business data is any one of multiple historical business data.
[0091] The target historical business data, as any one of the multiple historical business data, may include request data and response data. The request data may include a request header and attribute values of each request parameter, and the response data may include a response header and attribute values of each response parameter. The attribute information of the target historical business data may include part or all of the request header, attribute values of each request parameter, response header, and attribute values of each response parameter.
[0092] In step S253, when the attribute information of the target historical business data matches the target attribute value combination corresponding to the target test scenario, the target historical business data is used as a piece of test data in the test data set.
[0093] Based on the embodiments provided by step S231 and step S233, the target attribute value combination includes the target attribute values corresponding to each configuration object, which can indicate the target test scenario. The attribute information of the target historical business data can include the historical attribute values corresponding to each configuration object. When the historical attribute values corresponding to each configuration object in the attribute information of the target historical business data are consistent with the target attribute values corresponding to each configuration object included in the target attribute value combination, it is deemed that the attribute information of the target historical business data matches the target attribute value combination corresponding to the target test scenario, and the target historical business data can be used as a test data in the test data set corresponding to the target test scenario.
[0094] In the above embodiment, by using the attribute information of each historical business data and the target attribute value combination corresponding to the target test scenario, some or all of the historical business data that match the target test scenario can be screened out from multiple historical business data, thereby forming a test data set corresponding to the target test scenario, and constructing test data for the target test scenario to meet the test requirements of the specific scenario. The above embodiment can effectively reduce the construction cost of the test data, and there is no need to use all the historical business data as test data to ensure the test coverage of the specific scenario, which reduces the test workload, improves the test efficiency, and also avoids the waste of resources for the test business.
[0095] In one embodiment of the present disclosure, in actual testing work, the test data in different test scenarios needs to meet a certain quantity requirement to ensure the effectiveness and accuracy of the test.
[0096] In step S255, the test data upper limit threshold corresponding to the target test scenario is determined.
[0097] In step S257 , when the number of at least one test data included in the test data set reaches the test data upper limit threshold, the test data set is saved.
[0098] It can be understood that in the current data screening, if there are many test data matching the target test scenario, only a limited number of test data specified by the test data upper limit threshold will be retained as the test data under the target test scenario, and the redundant test data will be eliminated.
[0099] In the above embodiment, by limiting the amount of test data, the actual test needs are met, excessive testing in the same target test scenario is avoided, and the waste of resources of the service to be tested is also avoided.
[0100] In one embodiment of the present disclosure, the above method may further include:
[0101] In step S261, based on the life cycle of each test data in the test data set, the validity period of the test data set is determined.
[0102] It is feasible that the life cycle of the test data in the test data set starts when the test data is filtered into the test data set by default, and the validity period of the life cycle can be 7*24*60*60 seconds, that is, a validity period of 7 days.
[0103] It is feasible to determine the validity period of the test data set based on the time when each test data is filtered into the test data set and the validity period of the life cycle of each test data.
[0104] In step S263, when the validity period of the test data set indicates that the test data set is in a valid state, the test data set is used as a reusable test data set in the target test scenario.
[0105] It is feasible that when the validity period of the test data set represents that the number of valid (or surviving) test data in the test data set meets the preset lower limit threshold in the next round of interface testing, the test data set can be regarded as valid. If the number of test data corresponding to the target test scenario is insufficient in the next round of interface testing, the test data set generated in the current round can be reused.
[0106] In the above embodiment, during the current round of interface testing, in addition to generating a test data set corresponding to the target test scenario, if the amount of test data corresponding to the target test scenario is insufficient in the next round of interface testing, the test data set generated in the current round and still in a valid state can be reused, thereby improving the utilization rate of the test data and ensuring the coverage of the target test scenarios in different rounds of interface testing.
[0107] In one embodiment of the present disclosure, if the amount of test data corresponding to the target test scenario is extremely small, a business validity flag can be set for the test data to retain the test data, thereby meeting the coverage requirements of subsequent rounds of interface testing for the target test scenario.
[0108] In step S265, at least one piece of business-valid test data is determined from the test data set based on the business validity identifier of each test data in the test data set.
[0109] It is feasible that each test data in the test data set can be marked with a business validity mark in addition to having a life cycle, and the business validity mark can be marked by the staff according to the actual business scenario.
[0110] In step S267, at least one piece of valid business test data is used as recommended test data.
[0111] In the above embodiment, even after the life cycle of the test data ends, it can still be retained as recommended test data so as to be recommended to staff in subsequent rounds of interface testing to meet the coverage requirements of subsequent rounds of interface testing for target test scenarios, while also improving the utilization rate of test data.
[0112] Figure 3 As shown, in the test data obtained in the data screening phase, ○ represents the historical business data that matches the test scenario in this round of data screening, Represents historical business data that matches the test scenario in this round of data screening but is discarded because the number exceeds the threshold. Represents the historical business data that matches the corresponding test scenario in the previous data screening process and whose life cycle has not ended, so as to make up for the problem of insufficient test data corresponding to the corresponding test scenario in the current data screening link. The historical business data that matches the corresponding test scenario in the previous data screening process and has ended its life cycle but has business validity can also make up for the problem of insufficient test data corresponding to the corresponding test scenario in the current data screening process. Similarly, in this round of data screening, some historical business data will be used as reusable test data and recommended test data.
[0113] In step S270, a test data set corresponding to the target test scenario is replayed to obtain a test result for the service interface to be tested under the target test scenario.
[0114] In the embodiment of the present disclosure, the playback test is to send the real online request recorded in the traffic recording playback to the business interface to be tested and obtain the test response returned by the business interface to be tested, and compare the recorded real online response with the test response to determine whether there is a problem with the interface code of the business interface to be tested.
[0115] Preferably, each test data in the test data set includes historical request data and historical response data, and step S270 may be specifically implemented as follows:
[0116] In step S271, historical request data of each test data in the test data set is sent to the service interface to be tested, and test response data output by the service interface to be tested is obtained.
[0117] It is feasible that the business to be tested corresponding to the business interface to be tested performs business processing according to the historical request data, obtains response test data, and outputs it through the business interface to be tested.
[0118] In step S273, based on the historical response data and the test response data of each test data in the test data set, the test result for the service interface to be tested in the target test scenario is determined.
[0119] like Figure 3 As shown, it is feasible to compare the similarities and differences between the historical response data and the test response data corresponding to the historical request data in each test data, and obtain the test results of the business interface to be tested in the target test scenario. The test result can indicate whether the consistency between the historical response data and the test response data corresponding to the historical request data in each test data meets the preset conditions, and then generate a test report indicating whether the current round of interface testing has passed.
[0120] In the above embodiment, the target service corresponding to the target service interface and the service to be tested corresponding to the service to be tested interface may be different services, and the service to be tested may also be an upgraded version or a replacement version of the target service, which is not limited here.
[0121] In the above embodiment, by performing playback testing on the test data set corresponding to the target test scenario, the coverage of the target test scenario is ensured, which can effectively improve the coverage and targeting of the test scenario without performing playback testing on all historical business data, and can also avoid wasting processing resources for the business to be tested.
[0122] It can be seen from the technical solutions provided by the above embodiments of this specification that the technical solutions provided by the embodiments of the present disclosure determine the target test scenario based on at least one configuration object in the test scenario configuration information and the configuration conditions corresponding to each configuration object; then based on the target test scenario, multiple historical business data of the target business interface are screened to obtain a test data set corresponding to the target test scenario, and each test data included in the test data set is a historical business data among the multiple historical business data; thus, the test data set corresponding to the target test scenario can be replayed to obtain the test results for the business interface to be tested under the target test scenario. The technical solutions provided by the embodiments of the present disclosure screen out the test data set corresponding to the target test scenario, so that the target test scenario can be effectively covered during the playback test, thereby improving the effectiveness of the interface test, and also effectively improving the efficiency of the interface test and the utilization rate of the test data, avoiding the waste of test resources.
[0123] Figure 5 FIG. 5 is a block diagram of a data processing device 500 according to an exemplary embodiment. Figure 5 As shown, the data processing device 500 includes:
[0124] An acquisition module 510 is configured to acquire test scenario configuration information and multiple pieces of historical business data of a target business interface;
[0125] A scenario determination module 520 is configured to determine a target test scenario based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each of the configuration objects;
[0126] The data screening module 530 is configured to perform screening on the multiple historical business data based on the target test scenario to obtain a test data set corresponding to the target test scenario; each of the at least one test data included in the test data set is a historical business data among the multiple historical business data.
[0127] The testing module 540 is configured to perform a playback test on the test data set corresponding to the target test scenario to obtain a test result for the service interface to be tested under the target test scenario.
[0128] In one embodiment of the present disclosure, the testing module 540 includes:
[0129] A data interaction unit is configured to send the historical request data of each test data in the test data set to the service interface to be tested, and obtain the test response data output by the service interface to be tested;
[0130] The comparison unit is configured to determine the test result for the service interface to be tested in the target test scenario based on the historical response data and the test response data of each test data in the test data set.
[0131] In one embodiment of the present disclosure, the scene determination module 520 includes:
[0132] a configuration object attribute value set determining unit, configured to determine an attribute value set of each configuration object based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each configuration object;
[0133] The target test scenario determination unit is configured to perform Cartesian product processing according to the attribute value sets of each configuration object to obtain at least one attribute value combination; the at least one attribute value combination includes a target attribute value combination, and the target attribute value combination indicates the target test scenario.
[0134] In one embodiment of the present disclosure, the data screening module 530 includes:
[0135] An attribute information determining unit is configured to determine attribute information of target historical business data; the target historical business data is any one of the multiple historical business data;
[0136] The attribute matching unit is configured to execute, when the attribute information of the target historical business data matches the target attribute value combination corresponding to the target test scenario, using the target historical business data as a test data in the test data set.
[0137] In one embodiment of the present disclosure, the device further includes:
[0138] A threshold determination unit, configured to determine an upper threshold of the test data corresponding to the target test scenario;
[0139] The test data set determining unit is configured to save the test data set when the number of at least one test data included in the test data set reaches the test data upper limit threshold.
[0140] In one embodiment of the present disclosure, the device further includes:
[0141] a validity period determination unit, configured to determine the validity period of the test data set based on the life cycle of each of the test data in the test data set;
[0142] The reuse determination unit is configured to use the test data set as a reusable test data set in the target test scenario when the validity period of the test data set indicates that the test data set is in a valid state.
[0143] In one embodiment of the present disclosure, the device further includes:
[0144] A service validity determination unit, configured to execute a service validity identification based on each of the test data in the test data set, and determine at least one service valid test data from the test data set;
[0145] The recommendation determination unit is configured to execute the at least one valid service test data as the recommended test data.
[0146] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0147] In an exemplary embodiment of the present disclosure, an electronic device is further provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the data processing method in the embodiment of the present disclosure.
[0148] Figure 6 is a block diagram of an electronic device for implementing a data processing method according to an exemplary embodiment. The electronic device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 6 As shown. The electronic device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a data processing method is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a key, trackball or touchpad provided on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.
[0149] Figure 7 is a block diagram of an electronic device for implementing a data processing method according to an exemplary embodiment. The electronic device may be a server, and its internal structure diagram may be as shown in FIG. Figure 7 As shown. The electronic device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data processing method is implemented.
[0150] Those skilled in the art will understand that Figure 6 and Figure 7 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present disclosure, and does not constitute a limitation on the electronic device to which the scheme of the present disclosure is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0151] In an exemplary embodiment of the present disclosure, a computer-readable storage medium including instructions is further provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute a data processing method in an embodiment of the present disclosure.
[0152] In an exemplary embodiment of the present disclosure, a computer program product is further provided, including computer instructions, and when the computer instructions are executed by a processor, a data processing method in an embodiment of the present disclosure is implemented.
[0153] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0154] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0155] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A data processing method, characterized in that: The method comprises: Obtain test scenario configuration information and multiple historical business data of the target business interface; Determine a set of attribute values for each of the configuration objects based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each of the configuration objects; Cartesian product processing is performed on the attribute value sets of each of the configuration objects to obtain a plurality of attribute value combinations; the plurality of attribute value combinations correspond to a plurality of test scenarios, the plurality of attribute value combinations include a target attribute value combination, the target attribute value combination indicates a target test scenario, and the target test scenario is any test scenario among the plurality of test scenarios; Based on the target test scenario, the multiple pieces of historical business data are screened to obtain a test data set corresponding to the target test scenario; each of the at least one piece of test data included in the test data set is a piece of historical business data among the multiple pieces of historical business data; Performing a playback test on a test data set corresponding to the target test scenario to obtain a test result for the service interface to be tested under the target test scenario; When the life cycle of the test data ends and the test data is provided with a corresponding business validity identifier, the test data is used as recommended test data.
2. The data processing method according to claim 1, characterized in that: Each of the test data in the test data set includes historical request data and historical response data; the test data set corresponding to the target test scenario is replayed for testing to obtain a test result for the service interface to be tested under the target test scenario, including: Sending historical request data of each test data in the test data set to the service interface to be tested, and obtaining test response data output by the service interface to be tested; Based on the historical response data of each of the test data in the test data set and the test response data, the test result for the service interface to be tested in the target test scenario is determined.
3. The data processing method according to claim 2, characterized in that: The screening of the plurality of historical business data based on the target test scenario to obtain a test data set corresponding to the target test scenario includes: Determine attribute information of target historical business data; the target historical business data is any one of the multiple historical business data; In a case where the attribute information of the target historical business data matches the target attribute value combination corresponding to the target test scenario, the target historical business data is used as a piece of test data in the test data set.
4. The data processing method according to claim 3, characterized in that: The method further comprises: Determine the test data upper limit threshold corresponding to the target test scenario; When the number of at least one test data item included in the test data set reaches the test data upper limit threshold, the test data set is saved.
5. The data processing method according to claim 1, characterized in that: The method further comprises: Determining a validity period of the test data set based on a life cycle of each of the test data in the test data set; When the validity period of the test data set indicates that the test data set is in a valid state, the test data set is used as a reusable test data set in the target test scenario.
6. A data processing device, characterized in that: The device comprises: An acquisition module is configured to acquire test scenario configuration information and multiple pieces of historical business data of a target business interface; an attribute value set acquisition module, configured to determine an attribute value set of each configuration object based on at least one configuration object in the test scenario configuration information and a configuration condition corresponding to each configuration object; A target test scenario determination module is configured to perform Cartesian product processing according to the attribute value sets of each of the configuration objects to obtain a plurality of attribute value combinations; the plurality of attribute value combinations correspond to a plurality of test scenarios, the plurality of attribute value combinations include a target attribute value combination, the target attribute value combination indicates a target test scenario, and the target test scenario is any test scenario among the plurality of test scenarios; a data screening module configured to screen the plurality of historical business data based on the target test scenario to obtain a test data set corresponding to the target test scenario; each of the at least one test data included in the test data set is a piece of historical business data among the plurality of historical business data; A test module is configured to perform a playback test on a test data set corresponding to the target test scenario to obtain a test result for the service interface to be tested under the target test scenario; The recommended test data generating module is configured to use the test data as recommended test data when the life cycle of the test data ends and the test data is provided with a corresponding business validity identifier.
7. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the data processing method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the data processing method as claimed in any one of claims 1 to 5.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the data processing method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Playback method and device of interface test scene
CN112100052A
Automatic test method and device, storage medium and electronic equipment
CN112463605A
Automatic interface testing method and device, equipment and storage medium
CN114691519A