Test method, device, electronic device, and storage medium
By automating the processing of application protocol and resource data, generating diverse test data and obtaining response results, the problem of high cost and low coverage of manual testing is solved, achieving low-cost and high-coverage testing results.
Patent Information
- Application Number
- CN202211605549.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2042-12-14
AI Technical Summary
Current application testing mainly relies on manual testing, resulting in high testing costs and low coverage, and failing to effectively ensure the stability of the application after it goes live.
By automating the acquisition of server response requests, performing anomaly handling on protocol and resource data, generating diverse and comprehensive test data, automatically scheduling and sending it to the business layer, and obtaining the response results to obtain the test results.
This reduced testing costs, increased test coverage, and ensured the stability and robustness of the application before it went live.
Smart Images

Figure CN115964277B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computers, in particular to the field of testing of application programs, and can be applied in the fields of smart hardware, artificial intelligence, and Internet of Things. BACKGROUND
[0002] With the popularity of the Internet and smart devices, application programs provide more and more services, and the development cost is also increasing, which is affected by factors such as program size, personnel cooperation, program quality, detectability, and influence range of module changes. Therefore, before the application program is put online, it is usually necessary to test it to ensure its overall stability and avoid frequent abnormalities after being put online, which further increases the development cost.
[0003] However, the above testing is usually implemented manually. Therefore, not only is the testing cost high, but there is also a problem of low testing coverage. SUMMARY
[0004] The present disclosure provides a testing method and device, an electronic device, and a storage medium.
[0005] According to an aspect of the present disclosure, a testing method is provided, comprising:
[0006] obtaining a first request result returned by a server in response to a first service request, the first service request being a network request for a target service initiated based on a to-be-tested application program, and the first request result comprising first protocol data and first resource data;
[0007] performing abnormality processing on the first protocol data and the first resource data to generate a first number of groups of first test data;
[0008] in response to a first test request, sending a group of first test data to a service layer of the to-be-tested application program to obtain a first response result of the service layer, until a first number of first response results are obtained, the first test request being a network request for the target service initiated based on the to-be-tested application program;
[0009] obtaining a first test result of the service layer according to the first number of first response results.
[0010] According to a second aspect of the present disclosure, a testing device is provided, comprising:
[0011] a request result obtaining unit configured to obtain a first request result returned by a server in response to a first service request, the first service request being a network request for a target service initiated based on a to-be-tested application program, and the first request result comprising first protocol data and first resource data;
[0012] An exception processing unit is configured to perform exception processing on the first protocol data and the first resource data to generate a first quantity of first test data;
[0013] A response result acquisition unit is configured to, in response to a first test request, send a group of first test data to a service layer of the application under test to obtain a first response result of the service layer until a first quantity of first response results are obtained, the first test request being a network request initiated by the application under test and directed to a target service;
[0014] A test result acquisition unit is configured to obtain a first test result of the service layer according to the first quantity of first response results.
[0015] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0016] at least one processor;
[0017] a memory in communication with the at least one processor;
[0018] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method provided in the first aspect.
[0019] According to a fourth aspect of the present disclosure, a non-transitory computer readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to perform the method provided in the first aspect.
[0020] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the method provided in the first aspect.
[0021] The present disclosure can reduce the testing cost of the application program and improve the test coverage.
[0022] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present disclosure, nor to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0023] The accompanying drawings are used to better understand the present scheme and do not limit the present disclosure. Among them:
[0024] Figure 1 A flowchart of a test method provided by an embodiment of the present disclosure;
[0025] Figure 2 A complete flowchart of a test method provided by an embodiment of the present disclosure;
[0026] Figure 3 An application scenario diagram of a test method provided by an embodiment of the present disclosure is shown in FIG. 1.
[0027] Figure 4 A schematic structural block diagram of a test device provided by an embodiment of the present disclosure is shown in FIG. 2.
[0028] Figure 5 A schematic structural block diagram of an electronic device provided by an embodiment of the present disclosure is shown in FIG. 3. DETAILED DESCRIPTION
[0029] Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, which include various details of the embodiments of the present disclosure to assist in understanding, which should be considered in a descriptive sense only. Thus, it will be apparent to one of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present disclosure. Also, for the sake of brevity and clarity, descriptions of well-known functions and constructions are omitted from the following description.
[0030] As described in the background, with the popularity of the Internet and smart devices, the services provided by application programs (APPs) are more and more, and the development costs are also more and more, which are specifically affected by the program size, personnel cooperation, program quality, detectability, and influence range of module changes. Therefore, before a certain APP goes online, it is usually necessary to test to ensure its overall stability and avoid frequent abnormalities after going online, which further increases the development cost. Specifically, before a certain APP goes online, it is usually necessary to perform abnormal configuration on the communication protocol data between the APP and the server, obtain test data, and then test the business layer of the APP through the test data to find problems in the data processing layer of the business layer and adjust it, so as to ensure the stability and robustness of the business layer and the overall stability of the APP.
[0031] However, the above test is usually implemented manually. On the one hand, it consumes a large amount of human cost, and on the other hand, it cannot ensure the coverage of the test data for various abnormal situations. Therefore, not only is the test cost high, but there is also a problem of low test coverage.
[0032] Based on the above background, an embodiment of the present disclosure provides a test method, which can be applied to an electronic device. In the following, a test method provided by an embodiment of the present disclosure will be described in conjunction with the flowchart shown in FIG. 1. Figure 1 It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described can also be executed in other orders.
[0033] In step S101, a first request result returned by a server in response to a first service request is acquired, the first service request being a network request initiated by the to-be-tested APP for the target service, and the first request result including first protocol data and first resource data.
[0034] In step S102, the first protocol data and the first resource data are processed abnormally to generate a first quantity of first test data.
[0035] In step S103, in response to a first test request, a group of first test data is sent to a service layer of the to-be-tested APP to acquire a first response result of the service layer, until a first quantity of first response results are acquired, the first test request being a network request initiated by the to-be-tested APP for the target service.
[0036] In step S104, the first test result of the service layer is obtained according to the first quantity of first response results.
[0037] The to-be-tested APP can be an APP of a shopping type, a search type, a communication type, a news consultation type, etc., and the target service can be any service provided by the to-be-tested APP. In a specific example, the to-be-tested APP is a search type APP, and the target service can be a webpage search, a consultation search, a video search, a picture search, a map query, etc., or a lower sub-service of any of the foregoing services, and can involve different service scenarios. That is, the test method provided by the embodiments of the present disclosure is not for a specific service scenario, a specific service, or a specific APP, and has good service expandability.
[0038] The first service request can include one or at least two network requests. In the case where the first service request includes at least two network requests, the at least two network requests can be sent synchronously and nested, or can be sent in order, and the embodiments of the present disclosure do not make specific limitations in this regard.
[0039] The first protocol data can be communication protocol data between the to-be-tested APP and the server, and the first resource data can be resource type data corresponding to the target service. For example, the to-be-tested APP is a search type APP, and the target service is a picture search service, and then the first resource data can include resource type data such as a picture resource file, a page description file, and a script file.
[0040] After the first protocol data and the first resource data are acquired, the data generator can perform abnormality processing on the first protocol data and the first resource data to generate a first number of groups of first test data. Specifically, a first number of groups of different first test data can be generated to ensure the diversity and comprehensiveness of the first test data, so as to ensure the coverability of the first test data for various abnormal conditions. The abnormality processing on the first protocol data and the first resource data can be a variety of transformation processing on the initial fields in the first protocol data to generate a plurality of groups of protocol test data, or can be null processing on the first resource data in combination with the first protocol data to generate at least one group of resource test data. The present embodiment does not make a specific limitation on this. In addition, the first number can be set according to the data structure of the first protocol data, the number of initial resource files included in the first resource data, and the actual application requirements. The present embodiment also does not make a specific limitation on this.
[0041] After the first number of groups of first test data are generated, the automatic scheduling module can control the service layer to intermittently initiate a first test request. Thereafter, the network proxy module intercepts the first test request and sends a group of first test data to the service layer of the to-be-tested APP in response to the first test request. The report generation module obtains a first response result of the service layer until a first number of first response results are obtained. According to the first number of first response results, a first test result of the service layer is obtained to represent the stability and robustness of the service layer. The network proxy module can be a newly added module between the service layer and the network layer of the to-be-tested APP, which is independent of the network layer, or can be a newly added module in the network layer, which belongs to the network layer. The present embodiment does not make a specific limitation on this. In addition, the first response result can be response data, a response screenshot, etc. of the service layer.
[0042] By adopting the embodiment of the present disclosure, the first request result returned by the server in response to the first service request can be acquired, the first service request is a network request initiated based on the to-be-tested APP and directed to the target service, the first request result includes first protocol data and first resource data, the first protocol data and the first resource data are subjected to abnormality processing to generate a first quantity of groups of first test data, a group of first test data is sent to the service layer of the to-be-tested APP in response to a first test request to acquire a first response result of the service layer until the first quantity of first response results are acquired, the first test request is a network request initiated based on the to-be-tested APP and directed to the target service, and the first test result of the service layer is obtained according to the first quantity of first response results. On the one hand, in the embodiment of the present disclosure, the first protocol data and the first resource data can be subjected to abnormality processing to generate the first quantity of groups of first test data automatically, and therefore, compared with the prior art, a large amount of human cost can be saved, and the test cost of the target application program can be reduced. On the other hand, in the embodiment of the present disclosure, the first protocol data and the first resource data are subjected to abnormality processing to generate the first quantity of groups of first test data, and as described above, the first quantity of groups of different first test data can be generated, so that the diversity and comprehensiveness of the first test data are ensured to ensure the coverability of the first test data for various abnormal conditions, and therefore, compared with the prior art, the test coverage can be improved.
[0043] In addition, it needs to be noted that in the embodiment of the present disclosure, the first start test instruction carrying the test identifier can be used to control the service layer to initiate the first service request by the automatic scheduling module. In a specific example, the start test instruction can be “open: / / A?netdebug=1”, wherein “netdebug=1” is the test identifier, and correspondingly, the first service request can also carry the test identifier to represent that the first request result returned by the server in response to the first service request is needed to test the service layer of the to-be-tested APP. Specifically, the first service request can include the following three network requests:
[0044] test.com / res.json;
[0045] search.com / script.js;
[0046] test.com / image.jpg.
[0047] Then, after carrying the test identifier, the above three network requests can be transformed into:
[0048] test.com / res.json?netdebug=1;
[0049] search.com / script.js?netdebug=1;
[0050] test.com / image.jpg?netdebug=1.
[0051] After determining that the first service request includes the test identifier "netdebug=1" through the network proxy module, a uniform resource locator (URL) of the first service request can be recorded to obtain first URL information, and then the first service request is sent to the server in a synchronous nested sending or front-back ordered sending manner, and a first request result returned by the server is received. The first URL information includes "test.com / res.json", "search.com / script.js", and "test.com / image.jpg". Taking the network proxy module sending the first service request to the server in the front-back ordered sending manner as an example. First, "test.com / res.json?netdebug=1" can be sent to the server, and communication protocol data A1 returned by the server in response to "test.com / res.json?netdebug=1" is received, including res.json. Thereafter, "search.com / script.js?netdebug=1" can be sent to the server, and initial resource file A2 returned by the server in response to "search.com / script.js?netdebug=1" is received, including script.js. Finally, "test.com / image.jpg?netdebug=1" can be sent to the server, and initial resource file A3 returned by the server in response to "test.com / image.jpg?netdebug=1" is received, including image.jpg.
[0052] In this example, the communication protocol data A1 (res.json), the initial resource file A2 (script.js), and the initial resource file A3 (image.jpg) together constitute the first request result, and the communication protocol data A1 (res.json) is the first protocol data, and the initial resource file A2 (script.js) and the initial resource file A3 (image.jpg) together constitute the first resource data. Thereafter, the first protocol data and the first resource data are processed abnormally to generate a first number of first test data, and in response to the first test request, a group of first test data is sent to the business layer of the APP under test to obtain the first response result of the business layer, until the first number of first response results are obtained, and according to the first number of first response results, the first test result of the business layer is obtained.
[0053] It can be understood that in the embodiments of the present disclosure, the second start test instruction carrying the test identifier can also be used to control the business layer to initiate the first test request through the automatic scheduling module. Continuing the foregoing example, the test identifier is "netdebug=1". Since the first test request is the same as the first business request, both are network requests initiated by the APP under test for the target service, therefore, the first test request can also include the following three network requests:
[0054] test.com / res.json?netdebug=1;
[0055] search.com / script.js?netdebug=1;
[0056] test.com / image.jpg?netdebug=1。
[0057] Thereafter, the network proxy module determines that the first test request includes the test identifier "netdebug=1", so as to intercept the first test request, and extract the URL information of the first test request as the second URL information, and in combination with the first URL information, determine that the first test request corresponds to the first business request, and select a group of first test data from the first number of first test data and send it to the business layer of the APP under test to obtain the first response result of the business layer.
[0058] After obtaining a first response result, the second start test instruction carrying the test identifier is used again by the automatic scheduling module to control the business layer to initiate a first test request to obtain a next first response result, until a first quantity of first response results are obtained, and a first test result of the business layer is obtained according to the first quantity of first response results. Based on this, it can be understood that in the embodiments of the present disclosure, the number of initiations of the first test request is equal to the number of groups of the first test data, that is, the first quantity.
[0059] In the above process, since the first test data sent to the business layer in response to the first test request is generated on the electronic device side by the data generator, in the actual test stage, there is no need to communicate with the server, offline testing can be realized, and the limitation of network capability on the test process is improved to improve the testing convenience.
[0060] In some optional embodiments, as described above, the first quantity of groups of first test data includes protocol test data and resource test data, and specifically can include multiple groups of protocol test data and at least one group of resource test data. Based on this, the "abnormal processing of the first protocol data and the first resource data to generate the first quantity of groups of first test data" can include:
[0061] The multiple processed fields are obtained by performing multiple transformation processes on the to-be-processed field, and the to-be-processed field is any initial field in the first protocol data.
[0062] The protocol test data is generated by performing protocol data reorganization using the multiple processed fields corresponding to each initial field.
[0063] The resource test data is generated by performing null processing on the first resource data in combination with the first protocol data.
[0064] The to-be-processed field is any initial field in the first protocol data. That is, for any initial field in the first protocol data, multiple transformation processes need to be performed on it to obtain multiple processed fields, thereafter, the protocol test data is generated by performing protocol data reorganization using the multiple processed fields corresponding to each initial field, at least one resource test data is generated by performing null processing on the first resource data in combination with the first protocol data, and finally, the first quantity of groups of first test data is obtained by integrating the multiple protocol test data and the at least one resource test data.
[0065] By the above steps included in the step of "performing exception processing on the first protocol data and the first resource data to generate the first quantity of groups of first test data", in the embodiment of the present disclosure, on the one hand, since any one initial field in the first protocol data needs to be processed by multiple transformation processes to obtain multiple processed fields, after the protocol data is reorganized by using the multiple processed fields corresponding to each initial field to generate multiple groups of protocol test data, the diversity and comprehensiveness of the protocol test data can be further ensured, so as to further ensure the coverability of the first test data for various abnormal conditions and improve the test coverage.
[0066] In some optional embodiments, the step of "performing multiple transformation processes on the to-be-processed field to obtain multiple processed fields" can include the following steps:
[0067] obtaining a feature analysis result of the to-be-processed field;
[0068] determining multiple transformation processing modes according to the feature analysis result, the transformation processing mode including at least one of a type transformation mode and a value transformation mode;
[0069] performing multiple transformation processes on the to-be-processed field according to the multiple transformation processing modes to obtain multiple processed fields.
[0070] The feature analysis result can include a first data type and a first specific value. After the feature analysis result is obtained, the multiple transformation processing modes can be determined according to the feature analysis result.
[0071] For example, at least one optional type transformation mode can be randomly determined according to the first data type of the to-be-processed field, the type transformation mode having a corresponding second data type and the second data type being different from the first data type. The type transformation mode is used to indicate that the to-be-processed field is transformed from the first data type to a random value in the second data type corresponding to the type transformation mode.
[0072] For another example, at least one optional value transformation mode can be randomly determined according to the first specific value of the to-be-processed field, the value transformation mode having a corresponding second specific value and the second specific value being different from the first specific value. The value transformation mode is used to indicate that the to-be-processed field is transformed from the first specific value to the second specific value corresponding to the value transformation mode.
[0073] In a specific example, the first protocol data includes an initial field B1. When the initial field B1 is taken as a field to be processed, a feature analysis result of the initial field B1 is obtained when the initial field B1 is subjected to feature analysis, including: the first data type is a String type, and the first specific value is a string C1. Then, according to the String type, a random type transformation mode D1 can be determined, and the type transformation mode D1 is used to represent that the initial field B1 is transformed from the String type to a random value under a second data type corresponding to the type transformation mode D1, for example, 200. At the same time, according to the string C1, a random value transformation mode D2 can also be determined, and the value transformation mode D2 is used to represent that the initial field B1 is transformed from the string C1 to a second specific value corresponding to the value transformation mode D2, that is, still the string C1 itself. According to the string C1, a random value transformation mode D3 can also be determined, and the value transformation mode D3 is used to represent that the initial field B1 is transformed from the string C1 to a second specific value corresponding to the value transformation mode D3, that is, an empty value. In this way, a total of three processed fields corresponding to the initial field B1 can be obtained, which are respectively a random value under the Int, the string C1 and the empty value.
[0074] In another specific example, the first protocol data further includes an initial field B2 in addition to the initial field B1. When the initial field B2 is taken as a to-be-processed field, the feature analysis result of the initial field B2 includes that the first data type is an 8-bit unsigned Int type, and the first specific value is a numerical value C2. Then, an optional type transformation manner D4 can be randomly determined according to the 8-bit unsigned Int type, the type transformation manner D4 being used to represent that the initial field B2 is transformed from the 8-bit unsigned Int type to a random value in a second data type corresponding to the type transformation manner D4, for example, a String type. Meanwhile, an optional value transformation manner D5 can also be randomly determined according to the numerical value C2, the value transformation manner D5 being used to represent that the initial field B2 is transformed from the numerical value C2 to a second specific value corresponding to the value transformation manner D5, for example, a normal value, that is, still the numerical value C2 itself. An optional value transformation manner D6 can also be randomly determined according to the numerical value C2, the value transformation manner D6 being used to represent that the initial field B2 is transformed from the numerical value C2 to a second specific value corresponding to the value transformation manner D6, for example, a maximum overflow value. An optional value transformation manner D7 can also be randomly determined according to the numerical value C2, the value transformation manner D7 being used to represent that the initial field B2 is transformed from the numerical value C2 to a second specific value corresponding to the value transformation manner D7, for example, a minimum negative value. In this way, four processed fields corresponding to the initial field B2 can be obtained, which are a random value in a String type, the numerical value C2, a maximum overflow value and a minimum negative value.
[0075] Through the above steps included in the “performing multiple transformation processing on the to-be-processed field to obtain multiple processed fields”, in the embodiment of the disclosure, the to-be-processed field can be processed in multiple transformation processing manners to obtain multiple processed fields, and the transformation processing manner includes at least one of the type transformation manner and the value transformation manner, so that the diversity and comprehensiveness of the protocol test data can be further ensured, so as to further ensure the coverability of the first test data for various abnormal conditions, so as to improve the test coverage. In addition, in the embodiment of the disclosure, since the determination of the multiple processed fields also has a certain randomness, the business expansibility of the test method is further optimized.
[0076] In some optional embodiments, “recombining the protocol data by using the multiple processed fields corresponding to each initial field to generate protocol test data” can include the following steps:
[0077] Using the multiple processed fields corresponding to each initial field to form a candidate field set to obtain multiple candidate field sets;
[0078] selecting one target field from each candidate field set according to the exhaustive combination mode or the parallel combination mode to obtain a plurality of target fields;
[0079] recombining the protocol data by using the plurality of target fields to generate protocol test data.
[0080] In the embodiments of the present disclosure, after obtaining the plurality of candidate field sets, one target field can be selected from each candidate field set according to the exhaustive combination mode to obtain a plurality of target fields, and then the protocol data is recombined by using the plurality of target fields to generate protocol test data. Thereafter, the steps of "selecting one target field from each candidate field set according to the exhaustive combination mode to obtain a plurality of target fields; recombining the protocol data by using the plurality of target fields to generate protocol test data" are repeatedly executed, and finally, the combination universe of the plurality of candidate field sets is obtained as the plurality of protocol test data.
[0081] In the embodiments of the present disclosure, after obtaining the plurality of candidate field sets, one target field can be selected from each candidate field set according to the parallel combination mode to obtain a plurality of target fields, and then the protocol data is recombined by using the plurality of target fields to generate protocol test data. Thereafter, the steps of "selecting one target field from each candidate field set according to the parallel combination mode to obtain a plurality of target fields; recombining the protocol data by using the plurality of target fields to generate protocol test data" are repeatedly executed, and finally, the combination universe of the plurality of candidate field sets is obtained as the plurality of protocol test data.
[0082] Continuing the foregoing example, in the first protocol data, in addition to the initial fields B1 and B2, the candidate field set E1 is composed of the random value under the Int, the string C1 and the null value, which are the three processed fields corresponding to the initial field B1, and the candidate field set E2 is composed of the random value under the String type, the numerical value C2, the maximum overflow value and the minimum negative value, which are the four processed fields corresponding to the initial field B2.
[0083] Then, if the exhaustive combination mode is adopted, the combination universe G1 of the candidate field set E1 and the candidate field set E2 can be obtained, which includes 3*4 protocol test data:
[0084] Random value under Int & random value under String type;
[0085] Random value under Int & numerical value C2;
[0086] Random value under Int & maximum overflow value;
[0087] Random value under Int & minimum negative value;
[0088] String C1 & random value under String type;
[0089] String C1 & numeric value C2;
[0090] String C1 & maximum overflow value;
[0091] String C1 & minimum negative value;
[0092] Null & random value of String type;
[0093] Null & numeric value C2;
[0094] Null & maximum overflow value;
[0095] Null & minimum negative value.
[0096] If according to the parallel combination mode, a combined set G2 of the candidate field set E1 and the candidate field set E2 can be obtained, including 4 protocol test data:
[0097] Random value of Int & random value of String type;
[0098] String C1 & numeric value C2;
[0099] Null & maximum overflow value;
[0100] Random value of Int, numeric value C2 or Null & minimum negative value.
[0101] By the above steps included in the step of “generating protocol test data by recombining protocol data using multiple processed fields corresponding to each initial field”, in the embodiment of the disclosure, after multiple candidate field sets are obtained by using multiple processed fields corresponding to each initial field to form a candidate field set, if according to the exhaustive combination mode, a target field is selected from each candidate field set to obtain multiple target fields, and then protocol test data is generated by recombining protocol data using the multiple target fields, the diversity and comprehensiveness of the protocol test data can be ensured to the greatest extent, so as to further ensure the coverability of the first test data for various abnormal conditions and improve the test coverage. After multiple candidate field sets are obtained by using multiple processed fields corresponding to each initial field to form a candidate field set, if according to the parallel combination mode, a target field is selected from each candidate field set to obtain multiple target fields, and then protocol test data is generated by recombining protocol data using the multiple target fields, the test efficiency can be improved while ensuring that the protocol test data has a certain diversity and comprehensiveness, thereby meeting different test requirements.
[0102] In some optional embodiments, the step of “performing null processing on the first resource data and generating resource test data in combination with the first protocol data” can include the following steps:
[0103] The first resource data is subjected to overall null processing to obtain a first processing result, and resource test data including the first processing result and first protocol data is generated;
[0104] In response to determining that the first resource data includes multiple initial resource files, the to-be-processed resource file is subjected to overall null processing to obtain a second processing result, and resource test data including the second processing result, other resource files and the first protocol data is generated, the to-be-processed resource file being any initial resource file in the first resource data, and the other resource files being other initial resource files in the first resource data except the to-be-processed resource file.
[0105] It can be understood that in the embodiments of the present disclosure, in the case where the first resource data includes only one initial resource file, the first resource data is subjected to overall null processing to obtain a first processing result, and one set of resource test data including the first processing result and the first protocol data is generated, and only in the case where the first resource data includes multiple initial resource files, in response to determining that the first resource data includes multiple initial resource files, the to-be-processed resource file is subjected to overall null processing to obtain a second processing result, and multiple sets of resource test data including the second processing result, other resource files and the first protocol data are generated.
[0106] In a specific example, the first protocol data includes initial field B1 and initial field B2, the initial field B1 is a string C1, and the initial field B2 is an Int type value C2, and the first resource data includes two initial resource files, namely initial resource file H1 and initial resource file H2.
[0107] When the first resource data is subjected to overall null processing, a first processing result is obtained, that is, the initial resource file H1 is empty, and the initial resource file H2 is empty, and a set of resource test data including the first processing result and the first protocol data is generated, specifically as follows:
[0108] String C1 & Int type value C2 & initial resource file H1 is empty & initial resource file H2 is empty.
[0109] Thereafter, in response to determining that the first resource data includes multiple initial resource files, when the initial resource file H1 is taken as the to-be-processed resource file, the initial resource file H1 is subjected to overall null processing to obtain a second processing result, that is, the initial resource file H1 is empty, and a set of resource test data including the second processing result, other resource files (specifically, the initial resource file H2) and the first protocol data is generated, specifically as follows:
[0110] String C1 & Int type value C2 & initial resource file H1 is empty & initial resource file H2 is not empty.
[0111] When the initial resource file H2 is the resource file to be processed, the initial resource file H2 is subjected to the overall null processing to obtain a second processing result that the initial resource file H2 is empty, and a set of resource test data including the second processing result, other resource files (specifically, the initial resource file H1) and the first protocol data is generated again, specifically:
[0112] String C1 & Int type value C2 & initial resource file H1 is not empty & initial resource file H2 is empty.
[0113] Through the above steps included in the step of "subjecting the first resource data to the null processing and generating the resource test data in combination with the first protocol data", in the embodiment of the present disclosure, in the case where the first resource data includes multiple initial resource files, each initial resource file can be subjected to the overall null processing individually while keeping other resource files in the non-empty state, so as to further ensure the diversity and comprehensiveness of the resource test data, to ensure the coverability of the first test data for various abnormal conditions, and to improve the test coverage.
[0114] In some optional embodiments, the test method further includes:
[0115] obtaining a second request result returned by the server in response to a second service request, the second service request being a network request for the target service initiated based on the APP to be tested;
[0116] in response to determining that the second request result has new data relative to the first request result, performing abnormal processing on the new data and keeping the original data unchanged to generate a second number of second test data, the original data being other data in the second request result except the new data;
[0117] in response to the second test request, sending a set of second test data to the business layer to obtain a second response result of the business layer, until a second number of second response results are obtained, the second test request being a network request for the target service initiated based on the APP to be tested;
[0118] obtaining a second test result of the business layer according to the second number of second response results.
[0119] The second request result includes second protocol data and second resource data. For the second service request, its initiation mode and data structure can be referred to the related description of the first service request above, which will not be repeated. Similarly, for the second test request, its initiation mode and data structure can be referred to the related description of the first test request above, which will not be repeated.
[0120] In addition, as described above, the first service request and the second service request are both network requests initiated by the to-be-tested APP for the target service. Therefore, it can be understood that, in the embodiments of the present disclosure, the first initiation time corresponding to the second service request can be later than the second initiation time corresponding to the first service request, and between the second initiation time and the first initiation time, the to-be-tested APP has an upgrade. In a specific example, between the second initiation time and the first initiation time, the communication protocol between the to-be-tested APP and the server has an upgrade.
[0121] Through the above steps included in the test method, in the embodiments of the present disclosure, in the case that the second request result has new data relative to the first request result, only the new data can be processed abnormally to obtain the second number of abnormal processing results, and then the second number of abnormal processing results and the original data are used to generate the second number of second test data groups, without further processing the original data abnormally, thereby improving the test efficiency.
[0122] In addition, in the embodiments of the present disclosure, the new data includes at least one of the following:
[0123] The second protocol data has a new field relative to the first protocol data;
[0124] The second resource data has a new resource file relative to the first resource data.
[0125] It should be noted that, in the embodiments of the present disclosure, for the new field, the way of processing it abnormally to obtain the abnormal processing result can refer to the related description of processing the first protocol data abnormally in the foregoing, that is, the foregoing related description of “processing the to-be-processed field in multiple ways to obtain multiple processed fields, the to-be-processed field being any initial field in the first protocol data; and recombining the protocol data by using the multiple processed fields corresponding to each initial field to generate the protocol test data”, which will not be repeated here. For the new resource file, the way of processing it abnormally to obtain the abnormal processing result can refer to the related description of processing the first resource data abnormally in the foregoing, that is, the foregoing related description of “processing the to-be-processed field in multiple ways to obtain multiple processed fields, the to-be-processed field being any initial field in the first protocol data; and recombining the protocol data by using the multiple processed fields corresponding to each initial field to generate the protocol test data”, which will not be repeated here. In addition, in the case that the new data includes the new field, the second number can be set according to the number of the new field and the feature analysis result, and in the case that the new data includes the new resource file, the second number can be set according to the number of the new resource file, and the embodiments of the present disclosure do not specifically limit this.
[0126] In a specific example, in the first request result, the first protocol data includes initial field B1 and initial field B2, the first resource data includes initial resource file H1 and initial resource file H2, in the second request result, the second protocol data includes initial field B1, initial field B2, initial field B3 and initial field B4, and the second resource data includes initial resource file H1 and initial resource file H2. Obviously, the new data includes the new fields of the second protocol data relative to the first protocol data, that is, initial field B3 and initial field B4. Therefore, only initial field B3 and initial field B4 can be processed abnormally to obtain a second number of abnormal processing results, and then based on the second number of abnormal processing results and the original data (initial field B1, initial field B2, initial resource file H1 and initial resource file H2) to generate a second number of second test data groups.
[0127] Similarly, taking initial field B1 as string C1 and initial field B2 as Int value C2 as an example, assuming that initial field B3 is a Boolean value C3 and is taken as a field to be processed, a total of three processed fields corresponding to initial field B3 can be obtained, that is, a random value in the String type, Boolean value C3 and null value to form candidate field set E3. Assuming that initial field B4 is a string C4 and is taken as a field to be processed, a total of three processed fields corresponding to initial field B4 can be obtained, that is, a random value in Int, string C4 and null value to form candidate field set E4. Then, if the exhaustive combination mode is adopted, the combination universe G3 of candidate field set E3 and candidate field set E4 can be obtained, including 3*3 abnormal processing results, and then 3*3 groups of second test data are generated based on the 3*3 abnormal processing results and the original data:
[0128] String type random value & Int random value;
[0129] String type random value & string C4;
[0130] String type random value & null value;
[0131] String type random value & Int random value;
[0132] String C1 & Int C2 & Initial resource file H1 Non-empty & Initial resource file H2 Non-empty & Boolean C3 & String C4
[0133] String C1 & Int C2 & Initial resource file H1 Non-empty & Initial resource file H2 Non-empty & Boolean C3 & Null value
[0134] String C1 & Int C2 & Initial resource file H1 Non-empty & Initial resource file H2 Non-empty & Null value & Random value under Int
[0135] String C1 & Int C2 & Initial resource file H1 Non-empty & Initial resource file H2 Non-empty & Null value & String C4
[0136] String C1 & Int C2 & Initial resource file H1 Non-empty & Initial resource file H2 Non-empty & Null value & Null value
[0137] As described above, in the embodiments of the present disclosure, the newly added data can include newly added fields and newly added resource files, so that comprehensive data addition can be covered, thereby ensuring that the test efficiency can be improved as much as possible in the case that the second request result has newly added data relative to the first request result.
[0138] In some optional embodiments, the test method further includes:
[0139] In response to determining that the retest condition is met, entering the next round of testing to obtain the third test result of the business layer.
[0140] That is, in the embodiments of the present disclosure, in response to determining that the retest condition is met, the next round of testing can be entered according to the same test process as “obtaining a first request result returned by a server in response to a first business request, the first business request being a network request initiated by the to-be-tested APP to the target business, the first request result including first protocol data and first resource data; performing abnormal processing on the first protocol data and the first resource data to generate a first number of first test data; in response to a first test request, sending a group of first test data to the business layer of the to-be-tested APP to obtain a first response result of the business layer until a first number of first response results are obtained, the first test request being a network request initiated by the to-be-tested APP to the target business; and obtaining a first test result of the business layer according to the first number of first response results”, to obtain a third test result of the business layer.
[0141] Through the above steps included in the test method, in the embodiments of the present disclosure, in response to determining that the retest condition is met, the next round of testing can be entered to obtain the third test result of the business layer, thereby further improving the automation degree of the test method.
[0142] In some optional embodiments, "determining that the retest condition is met" can include at least one of the following:
[0143] In a case where a time difference between the current time and the latest historical test time is greater than a preset time length, it is determined that the retest condition is met.
[0144] In a case where the version of the APP to be tested is updated, it is determined that the retest condition is met.
[0145] In a case where the third request result returned by the server for the third service request is obtained, and third protocol data in the third request result is reduced or changed in field relative to the first protocol data, it is determined that the retest condition is met.
[0146] In a case where the third request result returned by the server for the third service request is obtained, and third resource data in the third request result is reduced in resource file relative to the first resource data, it is determined that the retest condition is met.
[0147] It can be understood that, in the case where "determining that the retest condition is met" includes "in a case where a time difference between the current time and the latest historical test time is greater than a preset time length, it is determined that the retest condition is met", in the process of performing the last round of test, after the first URL information is recorded by the network proxy module, the time when the first network request in the first service request is sent to the server can also be recorded as the latest historical test time, so as to be used for judging whether the time difference between the current time and the latest historical test time is greater than the preset time length. The recording format of the latest historical test time can be, for example, "2022.10.29.08.08.08", and the preset time length can be set according to actual application requirements, which is not specifically limited in the embodiments of the present disclosure.
[0148] Similarly, it can be understood that, in the case where "determining that the retest condition is met" includes "in a case where the version of the APP to be tested is updated, it is determined that the retest condition is met", in the process of performing the last round of test, when the first URL information is recorded by the network proxy module, the version number of the APP to be tested can also be recorded, so as to be used for judging whether the version of the APP to be tested is updated. The recording format of the version number can be, for example, "v8.8", which is not specifically limited in the embodiments of the present disclosure.
[0149] In addition, it should be noted that, in the embodiments of the present disclosure, for the third service request, the initiation mode and data structure thereof can be referred to the foregoing description of the first service request, which will not be repeated here.
[0150] In addition, as described above, the first service request and the third service request are both network requests initiated by the to-be-tested APP and directed to the target service. Therefore, it can be understood that, in the embodiments of the present disclosure, the third initiation time corresponding to the third service request can be later than the second initiation time corresponding to the first service request, and between the second initiation time and the third initiation time, the to-be-tested APP is upgraded. In a specific example, between the second initiation time and the third initiation time, the communication protocol between the to-be-tested APP and the server is upgraded.
[0151] In the embodiments of the present disclosure, there can be various situations of "determining that the retesting condition is met", and therefore, comprehensive retestable situations can be covered to further improve the automation degree of the test method.
[0152] In the following, the integrity process of the test method provided by the embodiments of the present disclosure will be described. Figure 2 The integrity process of the test method provided by the embodiments of the present disclosure will be described.
[0153] Firstly, the first start test instruction carrying the test identifier can be used to control the service layer to initiate the first service request, and record the first URL information, the latest historical test time and the version number of the to-be-tested APP, and then receive the first request result returned by the server, wherein the latest historical test time can be the time when the first network request in the first service request is sent to the server, the first URL information can be the URL information of the first service request, and the first request result can include the first protocol data and the first resource data.
[0154] Thereafter, the first protocol data and the first resource data are subjected to abnormality processing to generate a first number of first test data, wherein the first number of first test data includes a plurality of protocol test data and at least one set of resource test data. Specifically, the following steps can be performed:
[0155] Based on the first protocol data, a plurality of protocol test data can be generated: the feature analysis result of the to-be-processed field can be obtained, and a plurality of transformation processing modes can be determined according to the feature analysis result, and then a plurality of transformation processing modes can be performed on the to-be-processed field to obtain a plurality of processed fields, wherein the to-be-processed field is any initial field in the first protocol data, and the transformation processing mode includes at least one of a type transformation mode and a value transformation mode. Then, a candidate field set is formed by using the plurality of processed fields corresponding to each initial field to obtain a plurality of candidate field sets, and then a target field is selected from each candidate field set according to an exhaustive combination mode or a parallel combination mode to obtain a plurality of target fields, and then the protocol data is reorganized by using the plurality of target fields to generate a set of protocol test data, and finally a plurality of sets of protocol test data can be generated.
[0156] The first resource data is subjected to overall null processing to obtain a first processing result, and a set of resource test data including the first processing result and the first protocol data is generated, and in response to determining that the first resource data includes a plurality of initial resource files, a to-be-processed resource file is subjected to overall null processing to obtain a second processing result, and a set of resource test data including the second processing result, other resource files and the first protocol data is generated, and finally a plurality of sets of resource test data can be generated, wherein the to-be-processed resource file is any initial resource file in the first resource data, and the other resource files are other initial resource files in the first resource data except the to-be-processed resource file.
[0157] After the first quantity of sets of first test data are generated, a second start test instruction carrying a test identifier can be used to control the business layer to initiate a first test request to load the target service. Each time the target service is loaded, the network proxy module determines that the first test request includes the test identifier, so as to intercept the first test request, extract the URL information of the first test request as second URL information, determine that the first test request corresponds to the first service request in combination with the first URL information, select a set of first test data from the first quantity of sets of first test data, and send the set of first test data to the business layer of the APP under test, so as to obtain a first response result of the business layer. After the first quantity of first response results are obtained, a first test result of the business layer is obtained based on the first quantity of first response results. Based on this, it can be understood that in the embodiments of the present disclosure, the number of times of loading the target service is equal to the number of sets of first test data, that is, the first quantity.
[0158] Finally, a first test result of the business layer is obtained based on the first quantity of first response results, so as to represent the stability and robustness of the business layer.
[0159] After the last round of testing is completed, a second request result returned by the server in response to the second service request can be obtained, and in response to determining that the second request result has new data relative to the first request result, the new data is subjected to abnormal processing and the original data remains unchanged to generate a second quantity of sets of second test data. The original data is other data in the second request result except the new data. Then, a set of second test data is sent to the business layer in response to the second test request to obtain a second response result of the business layer. After the second quantity of second response results are obtained, a second test result of the business layer is obtained based on the second quantity of second response results. The new data includes at least one of the following:
[0160] A new field in the second protocol data relative to the first protocol data;
[0161] The second resource data has a newly added resource file relative to the first resource data.
[0162] Finally, in the embodiments of the present disclosure, the next round of testing can be entered to obtain a third test result of the service layer in response to determining that the retest condition is met. The determination that the retest condition is met can include at least one of the following:
[0163] In a case where a time difference between the current time and the latest historical test time is greater than a preset time length, it is determined that the retest condition is met.
[0164] In a case where the version of the APP to be tested is updated, it is determined that the retest condition is met.
[0165] In a case where the third request result returned by the server in response to the third service request is obtained, and third protocol data in the third request result is reduced or changed relative to the first protocol data field, it is determined that the retest condition is met.
[0166] In a case where the third request result returned by the server in response to the third service request is obtained, and third resource data in the third request result has a resource file reduction relative to the first resource data, it is determined that the retest condition is met.
[0167] Referring to Figure 3 An application scenario diagram of a test method provided by the embodiments of the present disclosure is shown.
[0168] As described above, the test method provided by the embodiments of the present disclosure is applied to an electronic device. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital processors, servers, blade servers, mainframes, and other suitable computers, for example, a control device. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices, and other similar computing devices. In addition, it should be noted that in the embodiments of the present disclosure, the electronic device can be a first type of device that does not include a playback device (for example, a display device), for example, a control machine, and the electronic device can also be a second type of device that includes a playback device, and the embodiments of the present disclosure do not limit this.
[0169] In the embodiments of the present disclosure, the electronic device can be used to execute the test method:
[0170] Obtaining a first request result returned by a server in response to a first service request, the first service request being a network request for a target service initiated based on an APP to be tested, the first request result including first protocol data and first resource data;
[0171] Performing abnormal processing on the first protocol data and the first resource data to generate a first number of first test data;
[0172] In response to the first test request, a set of first test data is sent to the service layer of the APP under test to obtain a first response result of the service layer until a first number of first response results are obtained, the first test request being a network request initiated by the APP under test for a target service;
[0173] According to the first number of first response results, a first test result of the service layer is obtained.
[0174] It can be understood that, in the present embodiment, when the electronic device is a first type of device, the corresponding second video segment can be played synchronously in the process of playing the to-be-played voice through the playing device.
[0175] It should be noted that, in the present embodiment, Figure 3 The scene schematic diagram shown is only illustrative and not restrictive, and those skilled in the art can make various obvious changes and / or replacements based on the Figure 3 Examples, and the technical solutions obtained still belong to the disclosure range of the present embodiment.
[0176] In order to better implement the above test method, the present embodiment further provides a test device 400, which can be integrated in an electronic device. Hereinafter, a test device 400 provided by the present embodiment will be described in conjunction with the Figure 4 structure schematic diagram shown.
[0177] The test device 400 comprises:
[0178] The request result acquisition unit 401 is configured to acquire a first request result returned by a server in response to a first service request, the first service request being a network request initiated by the APP under test for a target service, and the first request result comprising first protocol data and first resource data;
[0179] The exception processing unit 402 is configured to perform exception processing on the first protocol data and the first resource data to generate a first number of sets of first test data.
[0180] The response result acquisition unit 403 is configured to, in response to a first test request, send a set of first test data to the service layer of the APP under test to obtain a first response result of the service layer until a first number of first response results are obtained, the first test request being a network request initiated by the APP under test for a target service;
[0181] The test result acquisition unit is configured to obtain a first test result of the service layer according to the first number of first response results.
[0182] In some optional embodiments, the first quantity of first test data includes protocol test data and resource test data.
[0183] The exception processing unit 402 is configured to:
[0184] perform multiple transformation processes on the to-be-processed field to obtain multiple processed fields, the to-be-processed field being any initial field in the first protocol data;
[0185] recombine the protocol data by using the multiple processed fields corresponding to each initial field to generate protocol test data;
[0186] perform null processing on the first resource data and combine the first protocol data to generate resource test data.
[0187] In some optional embodiments, the exception processing unit 402 is configured to:
[0188] obtain a feature analysis result of the to-be-processed field;
[0189] determine multiple transformation processing modes according to the feature analysis result, the transformation processing mode including at least one of a type transformation mode and a value transformation mode;
[0190] perform multiple transformation processes on the to-be-processed field according to the multiple transformation processing modes to obtain multiple processed fields.
[0191] In some optional embodiments, the exception processing unit 402 is configured to:
[0192] use the multiple processed fields corresponding to each initial field to form a candidate field set to obtain multiple candidate field sets;
[0193] select a target field from each candidate field set according to an exhaustive combination mode or a parallel combination mode to obtain multiple target fields;
[0194] recombine the protocol data by using the multiple target fields to generate protocol test data.
[0195] In some optional embodiments, the exception processing unit 402 is configured to:
[0196] perform overall null processing on the first resource data to obtain a first processing result, and generate resource test data including the first processing result and the first protocol data;
[0197] And, in response to determining that the first resource data includes multiple initial resource files, performing a whole nullification process on a to-be-processed resource file to obtain a second processing result, and generating resource test data including the second processing result, other resource files, and the first protocol data, the to-be-processed resource file being any initial resource file in the first resource data, and the other resource files being other initial resource files in the first resource data except the to-be-processed resource file.
[0198] In some optional embodiments, the test device 400 further includes an additional test unit.
[0199] The additional test unit is configured to:
[0200] obtain a second request result returned by the server in response to a second service request, the second service request being a network request initiated by the to-be-tested APP for the target service;
[0201] In response to determining that the second request result includes new data relative to the first request result, performing an exception processing on the new data and keeping the original data unchanged to generate a second number of second test data, the original data being other data in the second request result except the new data;
[0202] In response to the second test request, sending a group of second test data to the service layer to obtain a second response result of the service layer, until a second number of second response results are obtained, the second test request being a network request initiated by the to-be-tested APP for the target service;
[0203] According to the second number of second response results, obtaining a second test result of the service layer.
[0204] In some optional embodiments, the second request result includes second protocol data and second resource data.
[0205] The new data includes at least one of:
[0206] The second protocol data includes a new field relative to the first protocol data;
[0207] The second resource data includes a new resource file relative to the first resource data.
[0208] In some optional embodiments, the test device 400 further includes a retest unit.
[0209] The retest unit is configured to:
[0210] In response to determining that a retest condition is met, entering a next round of testing to obtain a third test result of the service layer.
[0211] In some optional embodiments, the retest unit is configured to:
[0212] In a case where a time difference between the current time and the latest historical test time is greater than a preset time length, it is determined that the retest condition is met.
[0213] In a case where the version of the APP to be tested is updated, it is determined that the retest condition is met.
[0214] In a case where the third request result returned by the server in response to the third service request is obtained, and third protocol data in the third request result is reduced or changed in field relative to the first protocol data, it is determined that the retest condition is met.
[0215] In a case where the third request result returned by the server in response to the third service request is obtained, and third resource data in the third request result is reduced in resource file relative to the first resource data, it is determined that the retest condition is met.
[0216] In implementation, the above various modules can be implemented as independent entities, or can be combined as the same or several entities, and the specific implementation of the above various modules can be referred to the test method embodiments above, which will not be described here.
[0217] The test device 400 provided by the embodiments of the present disclosure can obtain the first request result returned by the server in response to the first service request, the first service request being a network request for a target service initiated based on the APP to be tested, and the first request result including first protocol data and first resource data; perform abnormal processing on the first protocol data and the first resource data to generate a first number of groups of first test data; in response to a first test request, send a group of first test data to a service layer of the APP to be tested to obtain a first response result of the service layer until a first number of first response results are obtained, the first test request being a network request for a target service initiated based on the APP to be tested; and obtain a first test result of the service layer according to the first number of first response results. On the one hand, in the embodiments of the present disclosure, the first protocol data and the first resource data can be automatically processed to generate a first number of groups of first test data, so compared with the prior art, a large amount of human cost can be saved, and the test cost of the target application program can be reduced. On the other hand, in the embodiments of the present disclosure, the first protocol data and the first resource data are both processed to generate a first number of groups of first test data, and as described above, a first number of different first test data can be generated, thereby ensuring the diversity and comprehensiveness of the first test data, so compared with the prior art, the test coverage can be improved.
[0218] In the technical solution of the present disclosure, the acquisition, storage and application of user personal information comply with relevant laws and regulations and do not violate public order and good customs.
[0219] According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a test system, a storage medium, and a computer program product.
[0220] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure is shown.
[0221] As described previously, an electronic device is intended to represent a wide variety of digital computers such as, for example, laptops, desktops, workstations, personal digital processors, servers, blade servers, mainframes, and other appropriate computers. An electronic device can also represent a wide variety of mobile devices such as, for example, personal digital processors, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present disclosure described and / or claimed in this document.
[0222] As Figure 5 shown, the electronic device 500 includes a computing unit 501 that can perform various appropriate actions and processes in accordance with a computer program stored in a Read-Only Memory (ROM) 502 or a computer program loaded into a Random Access Memory (RAM) 503 from a storage unit 508. Various programs and data required for the operation of the electronic device 500 can also be stored in the RAM 503. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An Input / Output (I / O) interface 505 is also connected to the bus 504.
[0223] Various components in the electronic device 500 are connected to the I / O interface 505, including an input unit 506, such as a keyboard, a mouse, and the like; an output unit 507, such as various types of displays, speakers, and the like; a storage unit 508, such as a magnetic disk, an optical disk, and the like; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, and the like. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0224] The computing unit 501 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various special-purpose Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Process (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 501 performs various methods and processes described above, e.g., the testing method. For example, in some optional embodiments, the testing method can be implemented as a computer software program, respectively, which is tangibly embodied in a non-transitory computer-readable storage medium, e.g., the storage unit 508. In some optional embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded onto the RAM 503 and executed by the computing unit 501, one or more steps of the testing method described above can be performed. Alternatively, in other embodiments, the computing unit 501 can be configured to perform the testing method by any other appropriate means, e.g., by means of firmware.
[0225] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuitry, integrated circuitry, a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a System On Chip (SOC), a Complex Programmable Logic Device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0226] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package, partially on a machine and partially on a remote machine or entirely on a remote machine or server.
[0227] In the context of the present disclosure, a non-transitory computer-readable storage medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The non-transitory computer-readable storage medium can be a machine-readable signal medium or a machine-readable storage medium. The non-transitory computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a non-transitory computer-readable storage medium can include, but are not limited to, an electrical connection based on one or more wires, a portable computer disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM) or flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0228] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a Cathode Ray Tube (CRT) monitor or a Liquid Crystal Display (LCD)) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0229] The systems and techniques described herein can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0230] The computer system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0231] The embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the foregoing test method.
[0232] The embodiments of the present disclosure further provide a computer program product, comprising a computer program which, when executed by a processor, implements the foregoing test method.
[0233] The electronic device, the storage medium and the computer program product provided by the embodiments of the present disclosure can obtain a first request result returned by a server in response to a first service request, the first service request being a network request for a target service initiated based on a to-be-tested APP, the first request result including first protocol data and first resource data; perform abnormal processing on the first protocol data and the first resource data to generate a first quantity of groups of first test data; in response to a first test request, send a group of first test data to a service layer of the to-be-tested APP to obtain a first response result of the service layer until a first quantity of first response results are obtained, the first test request being a network request for the target service initiated based on the to-be-tested APP; and obtain a first test result of the service layer according to the first quantity of first response results. On the one hand, in the embodiments of the present disclosure, the first protocol data and the first resource data can be automatically processed abnormally to generate the first quantity of groups of first test data, so compared with the prior art, a large amount of human cost can be saved, and the test cost of the target application program can be reduced. On the other hand, in the embodiments of the present disclosure, the first protocol data and the first resource data are both processed abnormally to generate the first quantity of groups of first test data, and as described above, the first quantity of groups of different first test data can be generated, thereby ensuring the diversity and comprehensiveness of the first test data, so compared with the prior art, the test coverage can be improved.
[0234] It should be understood that the steps shown in the above various forms of flowcharts can be reordered, added or deleted. For example, the steps described in the present disclosure can be executed in parallel, in sequence or in different orders, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, which is not limited herein. In addition, in the present disclosure, relationship terms such as "first", "second", "third" and the like are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. In the present disclosure, "a plurality of" can be understood as at least two.
[0235] The foregoing detailed description does not constitute a limitation of the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A testing method, comprising: Obtain the first request result returned by the server in response to the first business request, wherein the first business request is a network request for the target business initiated by the application under test, and the first request result includes first protocol data and first resource data; Anomaly handling is performed on the first protocol data and the first resource data to generate a first quantity of first test data; In response to the first test request, a set of the first test data is sent to the business layer of the application under test to obtain the first response result of the business layer until a first number of first response results are obtained. The first test request is a network request for the target business initiated by the application under test. Based on the first number of first response results, the first test result of the business layer is obtained; Wherein, the first test data of the first quantity group includes protocol test data and resource test data; the step of performing anomaly processing on the first protocol data and the first resource data to generate the first test data of the first quantity group includes: The field to be processed is subjected to various transformation processes to obtain multiple processed fields, wherein the field to be processed is any initial field in the first protocol data; Protocol data is reassembled using multiple processed fields corresponding to each initial field to generate protocol test data; The first resource data is set to empty, and combined with the first protocol data, resource test data is generated.
2. The method according to claim 1, wherein, The process involves performing various transformations on the field to be processed to obtain multiple processed fields, including: Obtain the feature parsing results of the field to be processed; Based on the feature parsing results, multiple transformation processing methods are determined, including at least one of type transformation methods and value transformation methods; The fields to be processed are subjected to various transformation processes according to the aforementioned multiple transformation processing methods to obtain the multiple processed fields.
3. The method according to claim 1, wherein, The step of reassembling protocol data using multiple processed fields corresponding to each initial field to generate protocol test data includes: By utilizing the multiple processed fields corresponding to each initial field, a candidate field set is formed to obtain multiple candidate field sets; According to the exhaustive combination method or the parallel combination method, one target field is selected from each of the candidate field sets to obtain multiple target fields; The protocol data is reassembled using the multiple target fields to generate protocol test data.
4. The method according to claim 1, wherein, The step of setting the first resource data to null and generating resource test data in conjunction with the first protocol data includes: The first resource data is completely empty to obtain a first processing result, and resource test data including the first processing result and the first protocol data is generated. In response to determining that the first resource data includes multiple initial resource files, the resource file to be processed is completely empty to obtain a second processing result, and resource test data including the second processing result, other resource files and the first protocol data is generated. The resource file to be processed is any initial resource file in the first resource data, and the other resource files are other initial resource files in the first resource data other than the resource file to be processed.
5. The method according to claim 1, further comprising: Obtain the second request result returned by the server in response to the second service request, wherein the second service request is a network request for the target service initiated by the application under test; In response to determining that the second request result contains new data relative to the first request result, the new data is anomaly-handled while the original data remains unchanged, to generate a second number of sets of second test data, wherein the original data is other data in the second request result excluding the new data; In response to the second test request, a set of the second test data is sent to the service layer to obtain the second response result of the service layer, until a second number of second response results are obtained. The second test request is a network request for the target service initiated by the application under test. Based on the second number of second response results, the second test result of the business layer is obtained.
6. The method according to claim 5, wherein, The result of the second request includes second protocol data and second resource data; The newly added data includes at least one of the following: The second protocol data contains additional fields compared to the first protocol data; The second resource data refers to newly added resource files relative to the first resource data.
7. The method according to claim 1, further comprising: In response to the determination that the retest conditions are met, proceed to the next round of testing to obtain the third test result of the business layer.
8. The method according to claim 7, wherein, The determination that the retest condition is met includes at least one of the following: If the time difference between the current time and the most recent historical test time is greater than a preset duration, it is determined that the retest condition is met; If the version of the application under test is updated, it is determined that the retesting conditions are met; If the server returns a third request result for a third service request, and the third protocol data in the third request result is reduced or changed compared to the first protocol data field, then the retest condition is determined to be met. If the server returns a third request result for a third service request, and the third resource data in the third request result shows a reduction in resource files compared to the first resource data, then the retest condition is determined to be met.
9. A testing apparatus, comprising: The request result acquisition unit is used to acquire the first request result returned by the server in response to the first business request. The first business request is a network request for a target business initiated by the application under test. The first request result includes first protocol data and first resource data. An exception handling unit is used to perform exception handling on the first protocol data and the first resource data, and generate a first number of sets of first test data. The response result acquisition unit is used to respond to the first test request by sending a set of the first test data to the business layer of the application under test in order to obtain the first response result of the business layer until a first number of first response results are obtained. The first test request is a network request for the target business initiated by the application under test. The test result acquisition unit is used to obtain the first test result of the business layer based on the first number of first response results; Wherein, the first quantity group of first test data includes protocol test data and resource test data; the exception handling unit is used for: The field to be processed is subjected to various transformation processes to obtain multiple processed fields, wherein the field to be processed is any initial field in the first protocol data; Protocol data is reassembled using multiple processed fields corresponding to each initial field to generate protocol test data; The first resource data is set to empty, and combined with the first protocol data, resource test data is generated.
10. The apparatus according to claim 9, wherein, The exception handling unit is used for: Obtain the feature parsing results of the field to be processed; Based on the feature parsing results, multiple transformation processing methods are determined, including at least one of type transformation methods and value transformation methods; The fields to be processed are subjected to various transformation processes according to the aforementioned multiple transformation processing methods to obtain the multiple processed fields.
11. The apparatus according to claim 9, wherein, The exception handling unit is used for: By utilizing the multiple processed fields corresponding to each initial field, a candidate field set is formed to obtain multiple candidate field sets; According to the exhaustive combination method or the parallel combination method, one target field is selected from each of the candidate field sets to obtain multiple target fields; The protocol data is reassembled using the multiple target fields to generate protocol test data.
12. The apparatus according to claim 9, wherein, The exception handling unit is used for: The first resource data is completely empty to obtain a first processing result, and resource test data including the first processing result and the first protocol data is generated. In response to determining that the first resource data includes multiple initial resource files, the resource file to be processed is completely empty to obtain a second processing result, and resource test data including the second processing result, other resource files and the first protocol data is generated. The resource file to be processed is any initial resource file in the first resource data, and the other resource files are other initial resource files in the first resource data other than the resource file to be processed.
13. The apparatus according to claim 9 further includes a newly added testing unit; The newly added test unit is used for: Obtain the second request result returned by the server in response to the second service request, wherein the second service request is a network request for the target service initiated by the application under test; In response to determining that the second request result contains new data relative to the first request result, the new data is anomaly-handled while the original data remains unchanged, to generate a second number of sets of second test data, wherein the original data is other data in the second request result excluding the new data; In response to the second test request, a set of the second test data is sent to the service layer to obtain the second response result of the service layer, until a second number of second response results are obtained. The second test request is a network request for the target service initiated by the application under test. Based on the second number of second response results, the second test result of the business layer is obtained.
14. The apparatus according to claim 13, wherein, The result of the second request includes second protocol data and second resource data; The newly added data includes at least one of the following: The second protocol data contains additional fields compared to the first protocol data; The second resource data refers to newly added resource files relative to the first resource data.
15. The apparatus according to claim 9, further comprising a retesting unit; The retest unit is used for: In response to the determination that the retest conditions are met, proceed to the next round of testing to obtain the third test result of the business layer.
16. The apparatus according to claim 15, wherein, The retest unit is used for: If the time difference between the current time and the most recent historical test time is greater than a preset duration, it is determined that the retest condition is met; If the version of the application under test is updated, it is determined that the retesting conditions are met; If the server returns a third request result for a third service request, and the third protocol data in the third request result is reduced or changed compared to the first protocol data field, then the retest condition is determined to be met. If the server returns a third request result for a third service request, and the third resource data in the third request result shows a reduction in resource files compared to the first resource data, then the retest condition is determined to be met.
17. An electronic device comprising: At least one processor; A memory that is communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 8.
18. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 8.
19. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method for generating testing data and device thereof
CN105868095A
Test data creation method, test data creation program, and test data creation device
JP2013196390A