Test method, device, electronic device, and storage medium
Patent Information
- Application Number
- CN202211607166.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2026-10-13
- Estimated Expiration
- 2042-12-14
AI Technical Summary
因此,不仅测试成本较高,还存在测试覆盖度较低的问题
[0022]应当理解,本部分所描述的内容并非旨在标识本公开的实施例的关键或重要特征,也不用于限制本公开的范围。本公开的其它特征将通过以下的说明书而变得容易理解。
Smart Images

Figure CN115964279B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to the field of application testing, and can be applied to fields such as smart hardware, artificial intelligence, and the Internet of Things. Background Technology
[0002] With the widespread adoption of the internet and smart devices, applications are offering an increasing number of services, leading to higher development costs. These costs are influenced by factors such as application size, personnel collaboration, application quality, testability, and the impact of module changes. Therefore, applications typically undergo testing before deployment to ensure overall stability and prevent frequent anomalies that could further increase development costs.
[0003] However, the above tests are mainly performed manually. Therefore, not only are the testing costs high, but the test coverage is also low. Summary of the Invention
[0004] This disclosure provides a test method, apparatus, electronic device, and storage medium.
[0005] According to one aspect of this disclosure, a testing method is provided, comprising:
[0006] Obtain the request result returned by the server in response to the business request. The business request is a network request initiated by the application under test for the target business. The request result includes basic data segments and structured data segments.
[0007] In response to the first test request, the basic data segment will be anomaly handled, and a set of first test data will be generated and 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.
[0008] In response to the second test request, the structured data segment will be anomaly handled, and a set of second test data will be generated and sent to the business layer to obtain the second response result of the business layer, until a second number of second response results are obtained. The second test request is a network request for the target business initiated by the application under test.
[0009] Based on the multiple request and response results, the test results of the business layer are obtained. The multiple request and response results include a first number of first response results and a second number of second response results.
[0010] According to a second aspect of this disclosure, a testing apparatus is provided, comprising:
[0011] The request result acquisition unit is used to acquire the request result returned by the server in response to the business request. The business request is a network request initiated by the application under test for the target business. The request result includes basic data segment and structured data segment.
[0012] The first test unit is used to respond to the first test request by performing exception handling on the basic data segment and sending a set of first test data generated 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.
[0013] The second test unit is used to respond to the second test request by performing exception handling on the structured data segment and sending a set of second test data generated to the business layer to obtain the second response result of the business layer until a second number of second response results are obtained. The second test request is a network request for the target business initiated by the application under test.
[0014] The test result acquisition unit is used to obtain the test results of the business layer based on multiple request response results, including a first number of first response results and a second number of second response results.
[0015] According to a third aspect of this disclosure, an electronic device is provided, comprising:
[0016] At least one processor;
[0017] Memory that is communicatively connected to at least one processor;
[0018] The memory stores instructions that can be executed by at least one processor, such that the instructions are executed by 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 this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause a computer to perform the method provided in the first aspect.
[0020] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method provided in the first aspect.
[0021] Using this disclosure can reduce the testing cost of applications while increasing test coverage.
[0022] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0023] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0024] Figure 1 A flowchart illustrating a testing method provided in an embodiment of this disclosure;
[0025] Figure 2 A schematic diagram illustrating the completeness of a testing method provided in this embodiment of the disclosure;
[0026] Figure 3 This is a schematic diagram illustrating an application scenario of a testing method provided in an embodiment of this disclosure;
[0027] Figure 4 A schematic structural block diagram of a testing device provided in an embodiment of this disclosure;
[0028] Figure 5 This is a schematic structural block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0029] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0030] As described in the background section, with the widespread adoption of the internet and smart devices, applications (APPs) are providing increasingly more services, leading to higher development costs. These costs are influenced by factors such as program size, personnel collaboration, program quality, testability, and the impact of module changes. Therefore, before an APP is launched, it is typically tested to ensure its overall stability and prevent frequent anomalies that would further increase development costs. Specifically, before an APP is launched, it is usually necessary to perform abnormal configurations on the communication protocol data between the APP and the server to obtain test data. This test data is then used to test the APP's business layer to identify and address issues at the data processing level, thereby ensuring the stability and robustness of the business layer and ultimately the overall stability of the APP.
[0031] However, the above tests are mainly performed manually. On the one hand, this consumes a lot of manpower; on the other hand, it cannot ensure that the test data covers various abnormal situations. Therefore, not only is the testing cost high, but it also suffers from low test coverage.
[0032] Based on the above background, this disclosure provides a testing method that can be applied to electronic devices. The following will be combined with... Figure 1 The flowchart shown illustrates a testing method provided by an embodiment of this disclosure. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order.
[0033] Step S101: Obtain the request result returned by the server in response to the business request. The business request is a network request initiated by the APP under test for the target business. The request result includes basic data segment and structure data segment.
[0034] Step S102: In response to the first test request, the basic data segment will be anomaly processed, and a set of first test data will be sent to the business layer of the APP 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 APP under test.
[0035] Step S103: In response to the second test request, the structured data segment will be anomaly processed, and a set of second test data will be sent to the business layer to obtain the second response result of the business layer until a second number of second response results are obtained. The second test request is a network request for the target business initiated by the APP under test.
[0036] Step S104: Based on the multiple request response results, obtain the test results of the business layer. The multiple request response results include a first number of first response results and a second number of second response results.
[0037] The app under test can be any app categorized as shopping, search, communication, news, or information, while the target service can be any service provided by the app under test. In a specific example, the app under test is a search app; correspondingly, the target service can be web search, information search, video search, image search, map query, product procurement, or any of the aforementioned sub-services, and can involve multiple different business scenarios. That is, the testing method provided in this embodiment is not targeted at a specific business scenario, a specific service, or a specific app, and has good business scalability.
[0038] A business request may include one or at least two network requests and may be pre-configured to represent the need to utilize the server's response to the business request to test the business layer of the app under test. The configuration can be configured when the test process starts or when the computer instructions corresponding to the test method are compiled; this disclosure does not impose specific limitations on this. Furthermore, when a business request includes at least two network requests, these at least two network requests may be sent synchronously and nested or sent sequentially; this disclosure also does not impose specific limitations on this.
[0039] In this embodiment of the disclosure, the request result may include communication protocol data between the target APP and the server, specifically including basic data segments and structured data segments. The basic data segment may consist of a third number of initial basic data segments, and the structured data segment may have at least one, and each structured data segment may consist of a fourth number of initial structured data segments with a hierarchical structure. Basic data refers to any data belonging to the four types: Int, Number, Boolean, and String. Structured data refers to any data belonging to the two types: Array and Object. Furthermore, the third number can be determined based on the data structure of the basic data segment, and the fourth number can be determined based on the data structure of the structured data segment. Generally, the third number can be an integer greater than or equal to 2, and the fourth number can be an integer greater than or equal to 1. This embodiment of the disclosure does not impose specific limitations on this.
[0040] After obtaining the basic data segment and the structured data segment, the business layer of the app under test can be controlled to initiate the first test request. This first test request is then intercepted by the network layer, and in response, an exception is handled on the basic data segment, generating a set of first test data which is sent to the business layer to obtain its first response. Subsequently, the business layer of the app under test is controlled to initiate the second test request, which is again intercepted by the network layer. In response, the basic data segment is also handled, generating the next set of first test data which is sent to the business layer to obtain its next first response, and so on, until a first set of first response results are obtained. Here, "controlling the business layer of the app under test to initiate the first test request" can be done through a pre-recorded trigger action, while "handling an exception on the basic data segment" can involve replacing at least one initial basic data in the basic data segment with first abnormal data, ensuring that the first test data generated in the two instances are different. Furthermore, the first response result can be response data from the business layer, response screenshots, etc., and the first quantity can be set according to the data structure of the basic data segment and in combination with actual application requirements. This disclosure embodiment does not impose specific limitations on this.
[0041] After obtaining a first number of first response results, the business layer of the app under test can be controlled to initiate a first second test request. This second test request is then intercepted by the network layer, and in response, anomaly processing is performed on the structured data segment, generating a set of second test data which is sent to the business layer to obtain the second response result from the business layer. Subsequently, the business layer of the app under test is controlled to initiate a second second test request, which is then intercepted by the network layer. In response, anomaly processing is performed on the structured data segment, generating another set of second test data which is sent to the business layer to obtain the next second response result from the business layer, and so on, until a second number of second response results are obtained. Here, "controlling the business layer of the app under test to initiate a second test request" can be achieved through a pre-recorded trigger action, while "anomaly processing the structured data segment" can involve replacing at least one initial structured data segment with second abnormal data, ensuring that the second test data generated in the two instances are different. Furthermore, the second response result can be response data from the business layer, response screenshots, etc., and the second quantity can be set according to the data structure of the structured data segment and in combination with actual application requirements. This disclosure embodiment does not impose specific limitations on this.
[0042] After obtaining a first number of first response results and a second number of second response results, the test results of the business layer can be obtained based on the multiple request response results including the first number of first response results and the second number of second response results.
[0043] By employing the embodiments of this disclosure, on the one hand, the first test data generated by anomaly handling of the basic data segment and the second test data generated by anomaly handling of the structured data segment can be automatically acquired. Therefore, compared with the prior art, it does not consume a large amount of manpower, thus reducing the testing cost of the target application. On the other hand, since the embodiments of this disclosure perform anomaly handling of both the basic data segment and the structured data segment to generate corresponding test data, the diversity and comprehensiveness of the test data are ensured, thereby ensuring the coverage of the test data for various anomaly situations. Therefore, compared with the prior art, the test coverage can be improved.
[0044] As mentioned above, in this embodiment of the disclosure, the basic data segment may include a third number of initial basic data. Based on this, in some optional implementations, "performing exception handling on the basic data segment and sending a set of first test data to the business layer of the APP under test" may include the following steps:
[0045] Traverse the basic data segment;
[0046] For each initial basic data point encountered during traversal, a first abnormal data point corresponding to the initial basic data point is obtained, and a third number of first abnormal data points are obtained.
[0047] Using the third number of first abnormal data points, generate a set of first test data;
[0048] Send the first test data to the business layer.
[0049] In this embodiment of the disclosure, the basic data segment can be traversed in a forward-backward traversal order. Each time an initial basic data is traversed, an anomaly transformation can be performed on the initial basic data in real time to obtain a first anomaly data corresponding to the initial basic data. Alternatively, a first anomaly data corresponding to the initial basic data can be directly obtained from a pre-made anomaly candidate set. This embodiment of the disclosure does not impose any specific limitations on this.
[0050] In a specific example, the basic data segment includes three initial basic data points:
[0051] The initial basic data A1 is of type String and its specific value is "200";
[0052] The initial basic data A2 is of type String and its specific value is "OK";
[0053] The initial basic data A3 is of type String and its specific value is "Tom".
[0054] Therefore, when traversing the data in a forward-to-back order, firstly, upon reaching the initial basic data A1, a first abnormal data point corresponding to A1 can be obtained, for example, an empty string. Subsequently, upon reaching the initial basic data A2, a first abnormal data point corresponding to A2 can also be obtained, again for example, an empty string. Finally, upon reaching the initial basic data A3, a first abnormal data point corresponding to A3 can also be obtained, for example, yet another empty string. In this way, three first abnormal data points can be obtained, and these three first abnormal data points can be used to generate a set of first test data.
[0055] By including the above steps of "processing the basic data segment for anomalies and sending a set of first test data to the business layer of the APP under test", each set of first test data in this embodiment of the disclosure may include the first abnormal data corresponding to all the initial basic data in the basic data segment. It can be understood that all the initial basic data included in the basic data segment are processed in parallel to improve the testing efficiency.
[0056] As mentioned above, in this embodiment of the disclosure, each time an initial basic data is traversed, a first abnormal data corresponding to that initial basic data can be directly obtained from a pre-made set of corresponding abnormal candidates. Based on this, in some optional implementations, "obtaining a first abnormal data corresponding to the initial basic data" may include the following steps:
[0057] From multiple anomaly candidate sets, determine the first target candidate set corresponding to the initial basic data;
[0058] Select one first abnormal data from the first target candidate set.
[0059] In this embodiment of the disclosure, the data type of the initial basic data can be determined, and then, based on the data type, a first target candidate set corresponding to the initial basic data can be determined from multiple anomaly candidate sets. Subsequently, a first anomaly data point is selected from the first target candidate set according to a first selection method. The first selection method can be sequential selection from front to back. For example, when generating the first set of first test data, the first first anomaly data point can be selected from the first target candidate set; when generating the second set of first test data, the second first anomaly data point can be selected from the first target candidate set; when generating the third set of first test data, the third first anomaly data point can be selected from the first target candidate set, and so on.
[0060] By using the above steps, including "obtaining a first abnormal data corresponding to the initial basic data", in this embodiment of the disclosure, a first target candidate set corresponding to the initial basic data can be determined from multiple abnormal candidate sets, and then a first abnormal data can be directly selected from the first target candidate set. Since multiple abnormal candidate sets can be pre-made, the testing efficiency can be further improved.
[0061] As previously described, in this embodiment of the disclosure, the structured data segment may include a fourth number of initial structured data with a structure hierarchy. Based on this, in some optional implementations, "processing the structured data segment for anomalies and sending a set of second test data generated to the business layer" may include the following steps:
[0062] Following the outward-to-inward progressive anomaly handling sequence, the target structural data is determined from the fourth number of initial structural data.
[0063] Anomaly processing is performed on the target structure data to obtain second anomalous data;
[0064] Generate a set of second test data including second abnormal data and first original data, wherein the first original data is the data in the request result other than the target structure data;
[0065] Send the second test data to the business layer.
[0066] In this embodiment of the disclosure, the target structural data can be determined from the fourth number of initial structural data according to the progressively advancing anomaly handling sequence from the outside to the inside. For each determined target structural data, anomaly transformation processing can be performed on the initial target structural data in real time to obtain a second anomaly data corresponding to that target structural data. Alternatively, a second anomaly data corresponding to the target structural data can be directly obtained from a pre-made, corresponding anomaly candidate set. This embodiment of the disclosure does not impose specific limitations on this approach.
[0067] In a specific example, the structured data segment includes two initial structured data segments with a structure hierarchy, namely:
[0068] The outer initial structure data B1 is of object type, and it includes two initial basic data and initial structure data B2.
[0069] The inner initial structure data B2 is an object type, which contains two initial basic data.
[0070] Therefore, following the progressive anomaly handling sequence from the outside in, when determining the outer initial structural data B1 as the target structural data from these two initial structural data sets, anomaly handling can be performed on initial structural data B1 to obtain a second anomalous data corresponding to initial structural data B1, for example, an empty structure, and a set of second test data including this second anomalous data and the first original data is generated. Subsequently, when determining the inner initial structural data B2 as the target structural data from these two initial structural data sets, anomaly handling can be performed on initial structural data B2 to obtain a second anomalous data corresponding to initial structural data B2, for example, still an empty structure, and a set of second test data including this second anomalous data and the first original data is generated.
[0071] Through the steps of "processing the structural data segment with anomalies and sending a set of second test data to the business layer," in this embodiment of the disclosure, on the one hand, for a certain structural data segment, the target structural data is determined from the fourth number of initial structural data segments included in the structural data segment according to the anomaly processing order from the outside to the inside. The target structural data is then processed with anomalies to obtain second abnormal data, and a set of second test data including the second abnormal data and the first original data is generated. Therefore, when sending this set of second test data to the business layer to obtain the second response result from the business layer, it can be ensured that the second response result is not affected by the outer data of the target structural data, thereby ensuring that the second response result is highly correlated with the set of second test data, thus improving the reliability of the test results. On the other hand, since the second abnormal data is obtained after processing the target structural data with anomalies, a set of second test data including the second abnormal data and the first original data is generated. The first original data is other data in the request result besides the target structural data; that is, no anomaly processing is performed on the first original data. Therefore, processing efficiency can be improved, thereby improving testing efficiency.
[0072] As mentioned above, in this embodiment of the disclosure, after determining the target structural data from the fourth number of initial structural data according to the progressively advancing anomaly handling order from the outside to the inside, a second anomaly data corresponding to the target structural data can be directly obtained from the pre-made and corresponding anomaly candidate set. Based on this, in some optional implementations, "performing anomaly handling on the target structural data to obtain the second anomaly data" may include the following steps:
[0073] From multiple anomaly candidate sets, determine the second target candidate set corresponding to the initial structure data;
[0074] Select a second abnormal data from the second target candidate set.
[0075] In this embodiment of the disclosure, the data type of the initial structure data can be determined, and then a second target candidate set corresponding to the initial structure data can be determined from multiple anomaly candidate sets based on the data type. Subsequently, a second anomaly data is selected from the second target candidate set according to a second selection method. The second selection method can be sequential selection from front to back. For example, when generating the first set of second test data corresponding to the initial structure data, the first second anomaly data can be selected from the second target candidate set; when generating the second set of second test data corresponding to the initial structure data, the second second anomaly data can be selected from the second target candidate set; when generating the third set of second test data corresponding to the initial structure data, the third second anomaly data can be selected from the second target candidate set, and so on.
[0076] By performing anomaly processing on the target structure data to obtain second anomalous data, the embodiments of this disclosure can determine a second target candidate set corresponding to the initial structure data from multiple anomaly candidate sets, and then directly select a second anomalous data from the second target candidate set. Since multiple anomaly candidate sets can be pre-made, testing efficiency can be further improved.
[0077] As mentioned above, in the embodiments of this disclosure, the multiple anomaly candidate sets may be pre-prepared; that is, in some optional implementations, the testing method may further include the following steps:
[0078] Obtain the feature parsing results of the data to be processed, where the data to be processed is any initial data in the request results;
[0079] Based on the feature analysis results, multiple anomaly handling methods are determined, including at least one of type transformation method and value transformation method;
[0080] By applying various exception handling methods, the data to be processed is transformed to obtain multiple processed data.
[0081] By using the multiple processed data corresponding to each initial data, an anomaly candidate set is formed to obtain multiple anomaly candidate sets.
[0082] The feature parsing result can include a first data type and a first specific value. After obtaining the feature parsing result of the data to be processed, various transformation processing methods can be determined based on the feature parsing result.
[0083] For example, at least one optional type transformation method can be randomly determined based on the first data type of the data to be processed. This type transformation method has a corresponding second data type, and the second data type is different from the first data type. The type transformation method indicates that the data to be processed will be transformed from the first data type to a random value under the second data type corresponding to that type transformation method.
[0084] For example, at least one optional value transformation method can be randomly determined based on a first specific value of the data to be processed. This value transformation method has a corresponding second specific value, and the second specific value is different from the first specific value. The value transformation method is used to indicate that the data to be processed is transformed from the first specific value to the second specific value corresponding to the value transformation method.
[0085] Furthermore, it should be noted that in this embodiment of the disclosure, the data to be processed is any initial data in the request result. That is, for any initial data (initial basic data and initial structural data) in the request result, it is necessary to determine multiple anomaly handling methods based on its feature parsing results, so as to perform multiple transformation processes on it, obtain multiple processed data, and form an anomaly candidate set.
[0086] In a specific example, if the primary data type of the data to be processed is Int and the primary value is the numerical value C1, to further improve test coverage, and considering the case where it takes the normal value (numerical value C1), the corresponding exception handling methods can at least include the following type transformation methods and value transformation methods:
[0087] case none = 0;
[0088] case toMin;
[0089] case to Max;
[0090] case toString;
[0091] case to Random;
[0092] case to Null;
[0093] case toEmptyString;
[0094] case toFloat;
[0095] case toArray;
[0096] case to Dictionary;
[0097] case toDelete.
[0098] Therefore, for each of the above exception handling methods, a corresponding processed data can be obtained. Multiple processed data can be obtained, and these multiple processed data can be used to form an exception candidate set, denoted as D1, which serves as the first target candidate set corresponding to the initial basic data when the first data type of the initial basic data is Int.
[0099] In a specific example, if the first data type of the data to be processed is a double-precision floating-point number under the Number type, and the first specific value is a floating-point number C2, in order to further improve the test coverage, and considering the case where it takes a normal value (floating-point number C2), the corresponding exception handling methods can at least include the following type transformation methods and value transformation methods:
[0100] case none = 0;
[0101] case toMin;
[0102] case to Max;
[0103] case toString;
[0104] case to Random;
[0105] case to Null;
[0106] case toEmptyString;
[0107] case toInt;
[0108] case toArray;
[0109] case to Dictionary;
[0110] case toDelete;
[0111] Therefore, for each of the above exception handling methods, a corresponding processed data can be obtained. Multiple processed data can be obtained, and these multiple processed data can be used to form an exception candidate set, denoted as D2, which serves as the first target candidate set corresponding to the initial basic data when the first data type of the initial basic data is Number.
[0112] In a specific example, if the primary data type of the data to be processed is String and the primary value is string C3, to further improve test coverage, the case of it taking the normal value (string C3) should also be considered. The corresponding exception handling methods can at least include the following type transformation methods and value transformation methods:
[0113] case none = 0
[0114] case toInt;
[0115] case to Random;
[0116] case to Null;
[0117] case to Empty;
[0118] case toArray;
[0119] case to Dictionary;
[0120] case toDelete;
[0121] Case finished.
[0122] Therefore, for each of the above exception handling methods, a corresponding processed data can be obtained. Multiple processed data can be obtained, and these multiple processed data can be used to form an exception candidate set, denoted as D3, which serves as the first target candidate set corresponding to the initial basic data when the first data type of the initial basic data is String.
[0123] In a specific example, if the primary data type of the data to be processed is Boolean and the primary specific value is Boolean C4, to further improve test coverage, and considering the case where it takes a normal value (Boolean C4), the corresponding exception handling methods can at least include the following type transformation methods and value transformation methods:
[0124] case none = 0;
[0125] case toInt;
[0126] case toString;
[0127] case to Null;
[0128] case to Revert;
[0129] case toRandomString;
[0130] case toArray;
[0131] case to Dictionary;
[0132] case toDelete.
[0133] Therefore, for each of the above exception handling methods, a corresponding processed data can be obtained. Multiple processed data can be obtained, and these multiple processed data can be used to form an exception candidate set, denoted as D4, which serves as the first target candidate set corresponding to the initial basic data when the first data type of the initial basic data is Bool.
[0134] In a specific example, if the primary data type of the data to be processed is Array and the primary value is array C5, to further improve test coverage, and considering the case where it takes a normal value (array C5), the corresponding exception handling methods can at least include the following type transformation methods and value transformation methods:
[0135] case none = 0;
[0136] case toInt;
[0137] case toString;
[0138] case to Empty;
[0139] case to Dictionary;
[0140] case to Null;
[0141] case toEmptyString;
[0142] case toDelete.
[0143] Therefore, for each of the above exception handling methods, a corresponding processed data can be obtained. Multiple processed data can be obtained, and these multiple processed data can be used to form an exception candidate set, denoted as D5, which serves as the second target candidate set corresponding to the initial structure data when the first data type of the initial structure data is Array type.
[0144] In a specific example, if the first data type of the data to be processed is a dictionary under the object type, and the first specific value is structured data C6, in order to further improve test coverage, and considering the case where it takes a normal value (structured data C6), the corresponding exception handling methods can at least include the following type transformation methods and value transformation methods:
[0145] case none = 0;
[0146] case toInt;
[0147] case toString;
[0148] case to Empty;
[0149] case toArray;
[0150] case to Null;
[0151] case toEmptyString;
[0152] case toDelete.
[0153] Therefore, for each of the above exception handling methods, a corresponding processed data can be obtained. Multiple processed data can be obtained, and these multiple processed data can be used to form an exception candidate set, denoted as D6, which serves as the second target candidate set corresponding to the initial structure data when the first data type of the initial structure data is object type.
[0154] Combining the above examples, we can form anomaly candidate sets D1, D2, D3, D4, D5, and D6, thus obtaining a total of 6 anomaly candidate sets.
[0155] Through the above steps included in the testing method, in this embodiment of the disclosure, the data to be processed can be subjected to anomaly transformation processing according to various anomaly handling methods to obtain multiple processed data. The anomaly handling methods include at least one of type transformation and value transformation methods. Therefore, the diversity and comprehensiveness of the subsequently selected first and second anomaly data can be ensured, further ensuring the coverage of the first and second test data for various anomaly situations, thereby improving test coverage. Furthermore, in this embodiment of the disclosure, since the determination of multiple processed data can also have a certain degree of randomness, the business scalability of the testing method is further optimized.
[0156] In this embodiment of the disclosure, the request result may further include a status code, and multiple request response results may further include a fifth number of third response results. Based on this, in some optional implementations, the testing method may further include the following steps:
[0157] In response to the third test request, the status code will be handled as an exception, and a set of third test data will be sent to the business layer to obtain the third response result from the business layer, until the fifth number of third response results are obtained. The third test request is a network request initiated by the APP under test for the target business.
[0158] Among them, the status code is also known as the Response.
[0159] In this embodiment, after obtaining a first number of first response results and a second number of second response results, the business layer of the app under test can be controlled to initiate a first third test request. This third test request is then intercepted by the network layer, and in response to the third test request, an anomaly handling is performed on the status code, generating a set of third test data which is sent to the business layer to obtain the third response result from the business layer. Subsequently, the business layer of the app under test is controlled to initiate a second second test request, and this third test request is intercepted by the network layer. In response to the third test request, an anomaly handling is performed on the status code, generating the next set of third test data which is sent to the business layer to obtain the next third response result from the business layer, and so on, until a fifth number of third response results are obtained. Here, "controlling the business layer of the app under test to initiate a third test request" can be done through a pre-recorded trigger action, and "anomaly handling the status code" can be done by replacing the status code with third anomaly data, ensuring that the third test data generated before and after are different. Furthermore, the third response result can be the business layer's response data, response screenshots, etc., and the fifth number can be set according to actual application requirements; this embodiment does not impose specific limitations on this.
[0160] After obtaining the fifth number of third response results, the test results of the business layer can be obtained based on the multiple request response results, including the first number of first response results, the second number of second response results, and the fifth number of third response results.
[0161] Through the above steps included in the testing method, in this embodiment of the disclosure, in addition to a first number of first response results and a second number of second response results, the multiple request response results also include a fifth number of third response results, and the third response results are related to status codes. Therefore, the test data's coverage of various abnormal situations can be further improved, thereby further enhancing test coverage.
[0162] In some alternative implementations, "processing the status code for exceptions and sending the generated set of third test data to the business layer" may include the following steps:
[0163] Perform exception handling on the status code to obtain the third exception data;
[0164] Generate a set of third test data, which includes third abnormal data and second original data. The second original data is the data in the request result other than the status code.
[0165] Send the third test data to the business layer.
[0166] This involves anomaly handling of status codes, transforming them into third-order abnormal data that differs from the normal value. For example, if the normal value of the status code is 200, it can be transformed into abnormal data such as 101, 201, 301, 404, and 502.
[0167] By including the steps of "processing the status code for exceptions and sending the generated set of third test data to the business layer," this embodiment of the disclosure, on the one hand, improves processing efficiency and thus testing efficiency because the status code is subject to simple exception processing with simple logic. On the other hand, after processing the status code for exceptions and obtaining the third exception data, a set of third test data is generated, which includes the third exception data and the second original data. The second original data consists of the data in the request result other than the status code; that is, no exception processing is performed on the second original data. Therefore, processing efficiency is also improved, thereby further improving testing efficiency.
[0168] As mentioned above, in this embodiment of the disclosure, the target business may involve multiple different business scenarios.
[0169] Based on this, in some optional implementations, the testing method may further include the following steps:
[0170] Record multiple trigger actions, each of which corresponds one-to-one with a different business scenario in the target business.
[0171] The first test request, the second test request, and the third test request are initiated through multiple triggering actions.
[0172] In this embodiment of the disclosure, for any business scenario in the target business, the corresponding triggering action can be executed according to the triggering method on the APP under test, and the triggering action can be recorded in response to the execution of the triggering action.
[0173] Subsequently, by playing the trigger action, the first test request, second test request, and third test request can be initiated sequentially to enter the testing process for a specific business scenario. Specifically, this involves: obtaining the server's response to the business request (a network request initiated by the app under test for the target business, the request result including basic data segments and structured data segments); responding to the first test request, performing exception handling on the basic data segments, generating a set of first test data and sending it to the business layer of the app under test to obtain the first response result from the business layer, until a first number of first response results are obtained; responding to the second test request, performing exception handling on the basic data segments, generating a set of first test data and sending it to the business layer of the app under test to obtain the first response result from the business layer, until a first number of first response results are obtained; the first test request is a network request initiated by the app under test for the target business; responding to the second test request, performing exception handling on the basic data segments, generating a set of first test data and sending it to the business layer of the app under test to obtain the first response result from the business layer, until a first number of first response results are obtained. The test process involves: handling exceptions in the first stage, generating a set of second test data and sending it to the business layer to obtain the second response result from the business layer, until a second number of second response results are obtained. The second test request is a network request initiated by the APP under test for the target business. In response to the third test request, exceptions are handled on the status code, generating a set of third test data and sending it to the business layer to obtain the third response result from the business layer, until a fifth number of third response results are obtained. The third test request is a network request initiated by the APP under test for the target business. The test result of the business layer is obtained based on the multiple request response results, including a first number of first response results, a second number of second response results, and a fifth number of third response results.
[0174] Furthermore, based on the above description, it can be understood that in the embodiments of this disclosure, for a certain business scenario in the target business, the number of times the corresponding trigger action is played can be determined according to the total number of the first test data, the second test data and the third test data to be generated, which will not be elaborated here.
[0175] Through the steps outlined above in this embodiment of the testing method, on the one hand, multiple triggering actions corresponding one-to-one with multiple business scenarios in the target business can be recorded, so as to initiate a first test request, a second test request, and a third test request through the multiple triggering actions, thereby further improving the automation level of the testing method. On the other hand, since the multiple triggering actions correspond one-to-one with multiple business scenarios in the target business, the testing method can be applied to multiple different business scenarios of the same target business, thereby further optimizing the business scalability of the testing method.
[0176] The following will combine Figure 2 The integrity process of a testing method provided in the embodiments of this disclosure will be described.
[0177] First, a business request is configured in advance to represent the request result returned by the server in response to the business request, and to test the business layer of the APP under test. The business request is a network request initiated by the APP under test for a target business. The configuration method can be configured when the test process starts or when the computer instructions corresponding to the test method are compiled; this disclosure does not impose specific limitations on this.
[0178] Next, record the trigger actions for the target business. If the target business involves multiple different business scenarios, multiple trigger actions need to be recorded, each corresponding to one of the business scenarios. The following explanation focuses on the testing process for a specific business scenario. By playing the target action from multiple trigger actions, the first, second, and third test requests can be initiated sequentially to enter the testing process for that business scenario.
[0179] Suppose that the server responds to the business request by returning the following result:
[0180]
[0181]
[0182] The basic data segment is as follows:
[0183]
[0184]
[0185] The basic data segment includes eight initial basic data items: status, message, name1, score1, name2, score2, total, and finish.
[0186] The structured data segment is:
[0187]
[0188] The structured data segment includes two initial structured data segments with a structure hierarchy: the outer segment classes1 and the inner segment classes2.
[0189] The status code is 200.
[0190] For the basic data segment:
[0191] First, the target action among multiple trigger actions is played to initiate a first test request. This first test request is then intercepted by the network layer. In response, the basic data segment is traversed. For each initial basic data segment encountered, a corresponding first anomalous data point is retrieved, resulting in eight first anomalous data points. These eight first anomalous data points are then used to generate a set of first test data E. For example, the first test data E could be:
[0192]
[0193]
[0194] Send the first test data E to the business layer to obtain the first response result F from the business layer in response to the first test data E.
[0195] After that, the target action continues to be played to initiate the first test request. In accordance with other exception handling methods, the basic data segment is processed again to generate the next set of first test data E1 in order to obtain the next first response result F. This process continues until the first number of first response results F are obtained.
[0196] For structured data segments:
[0197] First, the target action is played to initiate a second test request. This second test request is then intercepted at the network layer and responded to. Following a progressively deeper exception handling sequence, initial structure data `classes1` is determined as the target structure data from two initial structure data sets. Exception handling is performed on `classes1` to obtain second exception data. A set of second test data `G1` is then generated, including the second exception data and the first original data. The first original data consists of all data in the request result except for the initial structure data `classes1`. For example, the second test data `G1` could be:
[0198]
[0199]
[0200] Send the second test data G1 to the business layer to obtain the second response result H1 from the business layer in response to the second test data G1.
[0201] After that, the target action continues to be played to initiate a second test request, so as to process the initial structure data classes1 again according to other exception handling methods, to obtain the next set of second test data G1, and to obtain the next second response result H1, and so on, until the exception handling of the initial structure data classes1 is completed according to multiple exception handling methods, so as to obtain multiple second test data G1.
[0202] Next, the target action continues to be played, initiating a second test request. This second test request is then intercepted at the network layer, and a response is given. Following a progressively layered exception handling order from the outside in, the initial structure data `classes2` is determined as the target structure data from the two initial structure data sets. Exception handling is performed on the initial structure data `classes2` to obtain second exception data. A set of second test data `G2` is generated, which includes the second exception data and the first original data. The first original data consists of all data in the request result except for the initial structure data `classes2`. For example, the second test data `G2` could be:
[0203]
[0204] Send the second test data G2 to the business layer to obtain the second response result H2 from the business layer in response to the second test data G2.
[0205] After that, the target action continues to be played to initiate a second test request, so as to process the initial structure data classes2 again according to other exception handling methods, to obtain the next set of second test data G2, and to obtain the next second response result H2, and so on, until the exception handling of the initial structure data classes2 is completed according to multiple exception handling methods, so as to obtain multiple second test data G2.
[0206] Based on the above description, it can be understood that in this example, the second number of second response results includes multiple second test data G1 and multiple second test data G2.
[0207] Regarding status codes:
[0208] First, the target action is played, initiating a third test request. This request is then intercepted at the network layer. In response, the status code is handled to obtain third abnormal data. Finally, a set of third test data I is generated, including the third abnormal data and the second set of original data. The second set of original data consists of all data in the request result except for the status code. For example, the third test data I could be:
[0209]
[0210]
[0211] Send the third test data I to the business layer to obtain the third response result J from the business layer in response to the third test data I.
[0212] After that, the target action can continue to be played to initiate a third test request, generating the next set of third test data I, which includes other third abnormal data and the second original data, to obtain the next third response result J, until the fifth number of third response results J are obtained.
[0213] Finally, based on the multiple request response results, including a first number of first response results F, a second number of second response results (multiple second test data G1 and multiple second test data G2), and a fifth number of third response results J, the test results of the business layer are obtained.
[0214] Please see Figure 3 This is a schematic diagram illustrating an application scenario of a testing method provided in an embodiment of this disclosure.
[0215] As previously described, the testing methods provided in this disclosure are applied to electronic devices. Here, "electronic device" is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital processors, servers, blade servers, mainframe computers, and other suitable computers, such as central control devices. Electronic devices can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. Furthermore, it should be noted that in this disclosure, the electronic device can be a first-class device excluding playback devices (e.g., display devices), such as a central control unit; the electronic device can also be a second-class device including playback devices, and this disclosure does not impose any limitations on this.
[0216] In this embodiment of the disclosure, the electronic device can be used to perform the test method:
[0217] Obtain the request result returned by the server in response to the business request. The business request is a network request initiated by the APP under test for the target business. The request result includes basic data segment and structured data segment.
[0218] In response to the first test request, the basic data segment will be anomaly handled, and a set of first test data will be generated and sent to the business layer of the APP 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 APP under test.
[0219] In response to the second test request, the structured data segment will be anomaly handled, and a set of second test data will be generated and sent to the business layer to obtain the second response result of the business layer, until a second number of second response results are obtained. The second test request is a network request for the target business initiated by the APP under test.
[0220] Based on the multiple request and response results, the test results of the business layer are obtained. The multiple request and response results include a first number of first response results and a second number of second response results.
[0221] It is understood that, in this embodiment of the disclosure, when the electronic device is a first type of device, the corresponding second video segment can be played synchronously while the audio to be played is being played through the playback device.
[0222] It should be noted that, in the embodiments disclosed herein, Figure 3 The schematic diagrams shown are for illustrative purposes only and are not restrictive. Those skilled in the art can use them as a basis for their own interpretation. Figure 3 The examples may be modified in various obvious ways and / or substitutions, and the resulting technical solutions still fall within the scope of the disclosure of the embodiments of this disclosure.
[0223] To better implement the above testing methods, this disclosure also provides a testing device 400, which can be integrated into an electronic device. The following will be combined with... Figure 4 The schematic diagram shown illustrates a test apparatus 400 provided in a disclosed embodiment.
[0224] The testing device 400 includes:
[0225] The request result acquisition unit 401 is used to acquire the request result returned by the server in response to the business request. The business request is a network request initiated by the APP under test for the target business. The request result includes basic data segment and structure data segment.
[0226] The first test unit 402 is used to respond to the first test request by performing exception handling on the basic data segment and sending a set of first test data generated to the business layer of the APP 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 APP under test.
[0227] The second test unit 403 is used to respond to the second test request by performing exception handling on the structured data segment and sending a set of second test data generated to the business layer to obtain the second response result of the business layer until a second number of second response results are obtained. The second test request is a network request for the target business initiated by the APP under test.
[0228] The test result acquisition unit is used to obtain the test results of the business layer based on multiple request response results, including a first number of first response results and a second number of second response results.
[0229] In some alternative implementations, the basic data segment includes a third number of initial basic data;
[0230] The first test unit 402 is used for:
[0231] Traverse the basic data segment;
[0232] For each initial basic data point encountered during traversal, a first abnormal data point corresponding to the initial basic data point is obtained, and a third number of first abnormal data points are obtained.
[0233] Using the third number of first abnormal data points, generate a set of first test data;
[0234] Send the first test data to the business layer.
[0235] In some alternative implementations, the first test unit 402 is used for:
[0236] From multiple anomaly candidate sets, determine the first target candidate set corresponding to the initial basic data;
[0237] According to the first selection method, select a first abnormal data from the first target candidate set.
[0238] In some alternative implementations, the structured data segment includes a fourth number of initial structured data segments with a structured hierarchy;
[0239] The second test unit 403 is used for:
[0240] Following the outward-to-inward progressive anomaly handling sequence, the target structural data is determined from the fourth number of initial structural data.
[0241] Anomaly processing is performed on the target structure data to obtain second anomalous data;
[0242] Generate a set of second test data including second abnormal data and first original data, wherein the first original data is the data in the request result other than the target structure data;
[0243] Send the second test data to the business layer.
[0244] In some alternative implementations, the second test unit 403 is used for:
[0245] From multiple anomaly candidate sets, determine the second target candidate set corresponding to the initial structure data;
[0246] According to the second selection method, a second abnormal data is selected from the second target candidate set.
[0247] In some alternative implementations, the test apparatus 400 further includes a candidate set creation unit for:
[0248] Obtain the feature parsing results of the data to be processed, where the data to be processed is any initial data in the request results;
[0249] Based on the feature analysis results, multiple anomaly handling methods are determined, including at least one of type transformation method and value transformation method;
[0250] By applying various exception handling methods, the data to be processed is transformed to obtain multiple processed data.
[0251] By using the multiple processed data corresponding to each initial data, an anomaly candidate set is formed to obtain multiple anomaly candidate sets.
[0252] In some optional implementations, the request result may also include a status code, and multiple request response results may also include a fifth number of third response results;
[0253] The device also includes a third test unit for:
[0254] In response to the third test request, the status code will be handled as an exception, and a set of third test data will be sent to the business layer to obtain the third response result from the business layer, until the fifth number of third response results are obtained. The third test request is a network request initiated by the APP under test for the target business.
[0255] In some alternative implementations, the third test unit is used for:
[0256] Perform exception handling on the status code to obtain the third exception data;
[0257] Generate a set of third test data, which includes third abnormal data and second original data. The second original data is the data in the request result other than the status code.
[0258] Send the third test data to the business layer.
[0259] In some alternative embodiments, the test apparatus 400 further includes an action recording unit for:
[0260] Record multiple trigger actions, each of which corresponds one-to-one with a different business scenario in the target business.
[0261] Each application test request can be initiated through multiple triggering actions, including the first test request, the second test request, and the third test request.
[0262] In practice, the above modules can be implemented as independent entities or combined in any way to be implemented as the same or several entities. For the specific implementation of the above modules, please refer to the previous test method implementation examples, which will not be repeated here.
[0263] The testing apparatus 400 provided in this embodiment can automatically acquire first test data generated by anomaly processing of basic data segments, and second test data generated by anomaly processing of structured data segments. Therefore, compared with the prior art, it does not consume a large amount of manpower, thus reducing the testing cost of the target application. Furthermore, since this embodiment performs anomaly processing on both basic data segments and structured data segments to generate corresponding test data, it ensures the diversity and comprehensiveness of the test data, guaranteeing its coverage of various anomaly situations. Therefore, compared with the prior art, it can improve test coverage.
[0264] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0265] According to embodiments of this disclosure, this disclosure also provides an electronic device, a testing system, a storage medium, and a computer program product.
[0266] 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.
[0267] As previously described, in embodiments of this disclosure, the electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital processors, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0268] like Figure 5As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. The RAM 503 may also store various programs and data required for the operation of the electronic device 500. The computing unit 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0269] Multiple components in electronic device 500 are connected to I / O interface 505, including: input unit 506, such as keyboard, mouse, etc.; output unit 507, such as various types of displays, speakers, etc.; storage unit 508, such as disk, optical disk, etc.; and communication unit 509, such as network card, modem, wireless transceiver, etc. Communication unit 509 allows electronic device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0270] The computing unit 501 can be a variety of general-purpose 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, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the various methods and processes described above, such as test methods. For example, in some alternative embodiments, the test methods may be implemented as computer software programs tangibly contained in a non-transitory computer-readable storage medium, such as storage unit 508. In some alternative embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by the computing unit 501, one or more steps of the test methods described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform test methods by any other suitable means (e.g., by means of firmware).
[0271] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transferring data and instructions to the storage system, the at least one input device, and the at least one output device.
[0272] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0273] In the context of this disclosure, a non-transitory computer-readable storage medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A non-transitory computer-readable storage medium can be a machine-readable signal medium or a machine-readable storage medium. A non-transitory computer-readable storage medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of non-transitory computer-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, RAM, ROM, erasable programmable read-only memory (EPROM) or flash memory, optical fibers, compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0274] To provide interaction with a user, the systems and techniques described herein 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 pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; 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 sound input, voice input, or tactile input).
[0275] The systems and technologies described herein can be implemented in computing systems that include back-end components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected via digital data communication (e.g., a communication network) of any form or medium. Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0276] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0277] This disclosure also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to perform the aforementioned test method.
[0278] This disclosure also provides a computer program product, including a computer program that implements the aforementioned test method when executed by a processor.
[0279] The electronic device, storage medium, and computer program product provided in this disclosure can automatically acquire first test data generated by anomaly processing of basic data segments, and second test data generated by anomaly processing of structured data segments. Therefore, compared with the prior art, it does not consume a lot of manpower and can reduce the testing cost of the target application. On the other hand, since this disclosure performs anomaly processing on both basic data segments and structured data segments to generate corresponding test data, it ensures the diversity and comprehensiveness of the test data and the coverage of various anomaly situations. Therefore, compared with the prior art, it can improve test coverage.
[0280] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure is achieved, and this is not limited herein. Furthermore, in this disclosure, relational terms such as "first," "second," and "third" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. In this disclosure, "multiple" refers to at least two.
[0281] The foregoing specific embodiments do not constitute a limitation on the scope of protection of this 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 substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A testing method, comprising: Obtain the request result returned by the server in response to the business request. The business request is a network request initiated by the application under test for the target business. The request result includes a basic data segment and a structured data segment. In response to the first test request, the basic data segment is subjected to anomaly processing, and a set of first test data is generated and 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; wherein, the first test request is a network request for the target service initiated by the application under test; the anomaly processing of the basic data segment includes: replacing at least one initial basic data in the basic data segment with the first abnormal data; In response to the second test request, the structured data segment is anomaly-processed, and a set of second test data is generated and 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; wherein, the second test request is a network request for the target service initiated by the application under test; the anomaly-processing of the structured data segment includes: replacing at least one initial structured data in the structured data segment with second anomaly data; Based on multiple request-response results, the test results of the business layer are obtained, wherein the multiple request-response results include a first number of first response results and a second number of second response results; The request result also includes a status code, and the multiple request response results also include a fifth number of third response results; The method further includes: In response to the third test request, the status code will be processed for exceptions, and a set of third test data will be generated and sent to the business layer to obtain the third response result of the business layer, until the fifth number of third response results are obtained. The third test request is a network request for the target business initiated by the application under test.
2. The method according to claim 1, wherein, The basic data segment includes a third number of initial basic data; The step of performing anomaly handling on the basic data segment and sending a set of first test data to the business layer of the application under test includes: The basic data segment is traversed. For each initial basic data point traversed, a first abnormal data point corresponding to the initial basic data point is obtained, so as to obtain a third number of first abnormal data points; Using the third number of first abnormal data, a set of first test data is generated; The first test data is sent to the business layer.
3. The method according to claim 2, wherein, The step of obtaining a first abnormal data corresponding to the initial basic data includes: From multiple anomaly candidate sets, a first target candidate set corresponding to the initial basic data is determined; Select a first abnormal data from the first target candidate set.
4. The method according to claim 1, wherein, The structured data segment includes a fourth number of initial structured data segments with a structured hierarchy; The step of performing anomaly processing on the structured data segment and sending a set of second test data to the business layer includes: The target structure data is determined from the fourth number of initial structure data according to the progressively progressive anomaly handling order from the outside to the inside. Anomaly processing is performed on the target structure data to obtain second anomalous data; Generate a set of second test data including the second abnormal data and the first original data, wherein the first original data is other data in the request result except for the target structure data; The second test data is sent to the business layer.
5. The method according to claim 4, wherein, The step of performing anomaly processing on the target structure data to obtain second anomaly data includes: From multiple anomaly candidate sets, a second target candidate set corresponding to the initial structure data is determined; Select a second abnormal data from the second target candidate set.
6. The method according to claim 3 or 5, further comprising: Obtain the feature parsing results of the data to be processed, wherein the data to be processed is any initial data in the request result; Based on the feature parsing results, multiple anomaly handling methods are determined, including at least one of type transformation method and value transformation method; The data to be processed is subjected to anomaly transformation processing according to the various anomaly handling methods described above, resulting in multiple processed data. By utilizing the multiple processed data corresponding to each initial data, an anomaly candidate set is formed to obtain multiple anomaly candidate sets.
7. The method according to claim 1, wherein, The step involves performing exception handling on the status code and generating a set of third test data, which is then sent to the business layer. This includes: The status code is processed to obtain third abnormal data; Generate a set of third test data including the third abnormal data and the second original data, wherein the second original data is the data in the request result other than the status code; The third test data is sent to the business layer.
8. The method according to claim 1, further comprising: Record multiple trigger actions, each of which corresponds one-to-one with a different business scenario in the target business; The first test request, the second test request, and the third test request are initiated through the multiple triggering actions, respectively.
9. A testing apparatus, comprising: The request result acquisition unit is used to acquire the request result returned by the server in response to the business request. The business request is a network request initiated by the application under test for the target business. The request result includes a basic data segment and a structured data segment. The first testing unit is configured to respond to a first test request by performing anomaly processing on the basic data segment and sending a set of first test data generated to the business layer of the application under test to obtain a first response result from the business layer, until a first number of first response results are obtained; wherein, the first test request is a network request initiated by the application under test for the target business; the anomaly processing on the basic data segment includes: replacing at least one initial basic data in the basic data segment with first abnormal data; The second testing unit is configured to respond to a second test request by performing anomaly processing on the structured data segment and sending a set of second test data generated to the service layer to obtain a second response result from the service layer, until a second number of second response results are obtained; wherein, the second test request is a network request for the target service initiated by the application under test; the anomaly processing on the structured data segment includes: replacing at least one initial structured data in the structured data segment with second anomaly data; The test result acquisition unit is used to obtain the test results of the business layer based on multiple request response results, wherein the multiple request response results include a first number of first response results and a second number of second response results; The request result also includes a status code, and the multiple request response results also include a fifth number of third response results; The device further includes a third testing unit for: In response to the third test request, the status code will be processed for exceptions, and a set of third test data will be generated and sent to the business layer to obtain the third response result of the business layer, until the fifth number of third response results are obtained. The third test request is a network request for the target business initiated by the application under test.
10. The apparatus according to claim 9, wherein, The basic data segment includes a third number of initial basic data; The first test unit is used for: The basic data segment is traversed. For each initial basic data point traversed, a first abnormal data point corresponding to the initial basic data point is obtained, so as to obtain a third number of first abnormal data points; Using the third number of first abnormal data, a set of first test data is generated; The first test data is sent to the business layer.
11. The apparatus according to claim 10, wherein, The first test unit is used for: From multiple anomaly candidate sets, a first target candidate set corresponding to the initial basic data is determined; Select a first abnormal data from the first target candidate set.
12. The apparatus according to claim 9, wherein, The structured data segment includes a fourth number of initial structured data segments with a structured hierarchy; The second test unit is used for: The target structure data is determined from the fourth number of initial structure data according to the progressively progressive anomaly handling order from the outside to the inside. Anomaly processing is performed on the target structure data to obtain second anomalous data; Generate a set of second test data including the second abnormal data and the first original data, wherein the first original data is other data in the request result except for the target structure data; The second test data is sent to the business layer.
13. The apparatus according to claim 12, wherein, The second test unit is used for: From multiple anomaly candidate sets, a second target candidate set corresponding to the initial structure data is determined; Select a second abnormal data from the second target candidate set.
14. The apparatus of claim 11 or 13, further comprising a candidate set production unit, for: Obtain the feature parsing results of the data to be processed, wherein the data to be processed is any initial data in the request result; Based on the feature parsing results, multiple anomaly handling methods are determined, including at least one of type transformation method and value transformation method; The data to be processed is subjected to anomaly transformation processing according to the various anomaly handling methods described above, resulting in multiple processed data. By utilizing the multiple processed data corresponding to each initial data, an anomaly candidate set is formed to obtain multiple anomaly candidate sets.
15. The apparatus according to claim 9, wherein, The third test unit is used for: The status code is processed to obtain third abnormal data; Generate a set of third test data including the third abnormal data and the second original data, wherein the second original data is the data in the request result other than the status code; The third test data is sent to the business layer.
16. The apparatus of claim 9, further comprising an action recording unit, configured to: Record multiple trigger actions, each of which corresponds one-to-one with a different business scenario in the target business; The first test request, the second test request, and the third test request are initiated through the multiple triggering actions, respectively.
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
Automatic generation method and system for test case
CN108595341A
Mobile terminal data testing method and device
CN115314926A