Method and device for generating abnormal test data
By obtaining server response packets and replacing contents according to pre-configured exception test rules, the problem of time-consuming construction of exception test data in the existing technology is solved, and efficient exception test data generation and interface exception testing are realized. .
Patent Information
- Application Number
- CN202411456214.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-02-11
AI Technical Summary
The existing technology cannot quickly generate abnormal test data, which leads to manual construction by testers, which consumes a lot of time and energy and is inefficient.
By obtaining the response message sent by the server, replace the content of the target field with the content of the exception test field according to the JSON path in the pre-configured exception test rule, generate the exception test data, and send it to the client.
It realizes the rapid generation of exception test data, improves the generation efficiency of exception test data, and thus improves the efficiency of interface exception testing.
Smart Images

Figure CN119415427A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating abnormal test data. Background Art
[0002] With the development of technology, the number and types of applications (Application, APP) that can be installed on mobile terminals are increasing. For example, travel applications, shopping applications, and life applications, etc. The above applications need to undergo multiple tests before they are put into use, usually including functional testing, interface testing, performance testing, compatibility testing, and exception testing. Among them, exception testing mainly focuses on the performance of applications under various abnormal conditions to ensure that the application can still maintain stability and correctness under unstable conditions. Different exception test data is required in different scenarios.
[0003] In the prior art, it is impossible to directly generate abnormal test data, and testers need to construct it manually. However, due to the large number of abnormal test scenarios, a lot of time and energy of testers are consumed, and the efficiency is relatively low.
[0004] In summary, how to quickly generate abnormal test data is a problem that needs to be solved at present. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and apparatus for generating abnormal test data, which can improve the efficiency of generating abnormal test data.
[0006] In a first aspect, an embodiment of the present invention provides a method for generating abnormal test data, the method comprising:
[0007] Obtain a response message sent by the server, wherein the response message carries the first interface address;
[0008] In response to the second interface address in the pre-configured exception test rule being the same as the first interface address, obtaining a JSON path in the pre-configured exception test rule;
[0009] Acquire the content of the target field in the response message according to the JSON path;
[0010] The content of the target field is replaced with the content of the abnormal test field in the pre-configured abnormal test rule to generate abnormal test data.
[0011] Optionally, the method further includes:
[0012] The abnormal test data is sent to the client.
[0013] Optionally, the method further includes:
[0014] The anomaly test rules are preconfigured.
[0015] Optionally, the method further includes:
[0016] Enable the anomaly test rule.
[0017] Optionally, the specific process of pre-configuring the abnormal test rule includes:
[0018] receiving a second interface address selection instruction, and determining the second interface address;
[0019] Searching for an abnormal test field according to the JSON path, receiving the abnormal test field selection instruction, and determining the abnormal test field;
[0020] receiving an abnormal test scenario selection instruction and determining at least one abnormal test scenario;
[0021] At least one abnormal test rule is generated, wherein each abnormal test rule corresponds to an abnormal test scenario.
[0022] Optionally, the method further includes:
[0023] Receive instructions for creating exception test rules.
[0024] Optionally, the method further includes:
[0025] Display the JSON path and all abnormal test scenarios.
[0026] Optionally, the abnormal test scenarios include data abnormalities, status code abnormalities and interface abnormalities.
[0027] In a second aspect, an embodiment of the present invention provides a device for generating abnormal test data, the device comprising:
[0028] An acquiring unit, configured to acquire a response message sent by the server, wherein the response message carries the first interface address;
[0029] A matching unit, in response to the second interface address in the pre-configured anomaly test rule being the same as the first interface address, for obtaining a JSON path in the pre-configured anomaly test rule;
[0030] The acquisition unit is further used to acquire the content of the target field in the response message according to the JSON path;
[0031] The processing unit is used to replace the content of the target field with the content of the abnormal test field in the pre-configured abnormal test rule to generate abnormal test data.
[0032] Optionally, the device further comprises:
[0033] A sending unit is used to send the abnormal test data to the client.
[0034] Optionally, the device further comprises:
[0035] A configuration unit is used to pre-configure the anomaly test rule.
[0036] Optionally, the device further comprises:
[0037] The enabling unit is used to enable the abnormal test rule.
[0038] Optionally, the configuration unit is specifically used to:
[0039] receiving a second interface address selection instruction, and determining the second interface address;
[0040] Searching for an abnormal test field according to the JSON path, receiving the abnormal test field selection instruction, and determining the abnormal test field;
[0041] receiving an abnormal test scenario selection instruction and determining at least one abnormal test scenario;
[0042] At least one abnormal test rule is generated, wherein each abnormal test rule corresponds to an abnormal test scenario.
[0043] Optionally, the device further comprises:
[0044] The receiving unit is used to receive an instruction for creating an abnormal test rule.
[0045] Optionally, the device further comprises:
[0046] The display unit is used to display the JSON path and all abnormal test scenarios.
[0047] Optionally, the abnormal test scenarios include data abnormalities, status code abnormalities and interface abnormalities.
[0048] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement a method as described in the first aspect or any possible one of the first aspect.
[0049] In a fourth aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement a method as described in the first aspect or any possible one of the first aspect.
[0050] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements a method as described in the first aspect or any possible method of the first aspect.
[0051] In the embodiment of the present invention, a response message sent by a server is obtained, wherein the response message carries a first interface address; in response to the second interface address in a pre-configured exception test rule being the same as the first interface address, a JSON path in the pre-configured exception test rule is obtained; the content of a target field in the response message is obtained according to the JSON path; the content of the target field is replaced with the content of an exception test field in the pre-configured exception test rule to generate exception test data; and the exception test data is sent to a client. Through the above method, exception test data can be quickly generated, thereby achieving efficient interface exception testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0053] Figure 1 is a flow chart of a method for generating abnormal test data according to an embodiment of the present invention;
[0054] Figure 2 is a schematic diagram of a display interface of an agent tool according to an embodiment of the present invention;
[0055] Figure 3 is a flow chart of another method for generating abnormal test data according to an embodiment of the present invention;
[0056] Figure 4 is a schematic diagram of a display interface of another proxy tool according to an embodiment of the present invention;
[0057] Figure 5 is a schematic diagram of a display interface of another proxy tool according to an embodiment of the present invention;
[0058] Figure 6 is a flow chart of another method for generating abnormal test data according to an embodiment of the present invention;
[0059] Figure 7 is a flow chart of a method for pre-configuring anomaly test rules according to an embodiment of the present invention;
[0060] Figure 8 is a schematic diagram of a display interface of another proxy tool according to an embodiment of the present invention;
[0061] Fig. 9 is a schematic diagram of a display interface of another proxy tool according to an embodiment of the present invention;
[0062] Fig.10 is a schematic diagram of a display interface of an agent tool according to an embodiment of the present invention;
[0063] Fig.11 is a schematic diagram of a display interface of another proxy tool according to an embodiment of the present invention;
[0064] Fig.12 is a schematic diagram of a display interface of another proxy tool according to an embodiment of the present invention;
[0065] Fig.13 is a schematic diagram of a display interface of another proxy tool according to an embodiment of the present invention;
[0066] Fig.14 is a schematic diagram of a display interface of an agent tool according to an embodiment of the present invention;
[0067] Fig.15 This is a flow chart of interaction between terminals according to an embodiment of the present invention;
[0068] Fig.16 is a schematic diagram of a device for generating abnormal test data according to an embodiment of the present invention;
[0069] Fig.17 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0070] The present invention is described below based on the embodiments, but the present invention is not limited to these embodiments. In the detailed description of the present invention below, some specific details are described in detail. It is possible for a person skilled in the art to fully understand the present invention without the description of these details. In order to avoid confusing the essence of the present invention, known methods, processes, procedures, components and circuits are not described in detail.
[0071] In addition, persons of ordinary skill in the art will appreciate that the drawings provided herein are for illustration purposes and are not necessarily drawn to scale.
[0072] Unless the context clearly requires otherwise, the words "include", "including" and similar words throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, the meaning is "including but not limited to".
[0073] In the description of the present invention, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and cannot be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, the meaning of "plurality" is two or more.
[0074] Usually in the existing technology, exception testing includes exception testing at different levels. For example, interface exception testing mainly focuses on verifying whether the application can properly handle these exceptions and avoid crashes when the server returns abnormal data, network anomalies, users make wrong operations or encounter unexpected situations. By simulating various possible exception scenarios, interface exception testing evaluates the robustness of the application and ensures that the application can still run reliably in an undesirable environment.
[0075] Common exception types include server-side exceptions and network exceptions. The server-side exceptions include data exceptions, status code exceptions and interface exceptions. Among them, the data exceptions include test data type errors, field values out of range, data missing, etc. Specifically, they are divided into the following three situations. Case 1: For the [] array type, common exception test scenarios include: empty array, NULL, missing structure, a group of empty data, a group of empty data and a group of non-empty data, multiple groups of empty data, normal data and multiple groups of empty data and the empty data are not adjacent, the array contains a large amount of data, etc.; Case 2: For the {} dictionary type, common exception test scenarios include: empty dictionary, NULL, field missing; Case 3: For the character type, common exception test scenarios include: empty string, NULL, field missing, color value exception, type exception, hyperlink address exception, etc.; The status code exception includes the application receiving a 4xx or 5xx status code; The interface exception includes the incorrect format of the data returned by the server, for example, the lack of necessary fields or the return of an unexpected JSON structure.
[0076] When encountering the above-mentioned data exceptions, status code exceptions and interface exceptions, the application needs to handle the errors correctly to ensure that the user experience is not seriously affected, the application does not crash, and the core functions are kept running normally. The exception handling of the above-mentioned applications should have a good user experience and provide clear and friendly prompt information. For example, specific measures include displaying friendly error prompts, retry mechanisms and fallback strategies; and ensure that in abnormal situations, the application data is not lost or duplicated, and the consistency of the data is guaranteed; after the exception is resolved, the application should be able to quickly return to normal, including automatic retry or reloading of data.
[0077] For the above-mentioned various abnormal test scenarios, testers need to manually construct abnormal test data. For example, each time an abnormal test is performed, the tester needs to manually create a set of interface abnormal test data in advance, and then direct the tested interface request to the interface abnormal test data through the proxy tool. When a new abnormal test scenario needs to be constructed, the user must manually modify the abnormal test data again to achieve the purpose of interface abnormal test. However, due to the large number of abnormal test scenarios, a lot of time and energy of the tester is consumed, and the efficiency is also relatively low. Therefore, how to quickly generate abnormal test data to achieve efficient interface abnormal test is a problem that needs to be solved at present.
[0078] In an embodiment of the present invention, in order to solve the above problems, a method for generating abnormal test data is proposed. The flow chart of the method for generating abnormal test data is as follows: Figure 1 As shown, specifically including:
[0079] Step S101: Obtain a response message sent by a server, wherein the response message carries a first interface address.
[0080] Specifically, a proxy tool is used to obtain a response message sent by the server. The format of the response message conforms to the JSON structure. The response message carries a first interface address, which is the interface address that needs to be tested for exception. Since the response message is feedback information given by the server after receiving an interface request that needs to be tested triggered by the client's application, the interface address carried in the interface request that needs to be tested is the first interface address in the response message.
[0081] Step S102: In response to the second interface address in the pre-configured exception test rule being the same as the first interface address, obtaining a JSON path in the pre-configured exception test rule.
[0082] Specifically, after receiving the response message, the proxy tool needs to match it with the second interface address in the exception test rule. If the first interface address and the second interface address are the same, the JSON path in the pre-configured exception test rule is obtained; wherein the exception test rule includes the second interface address, the JSON path of the exception test field, and the content of the exception test field; the exception test rule can also be called the exception scenario name, which can be displayed in the display interface of the proxy tool, for example Figure 2As shown, the name of the abnormal scenario is: the abnormal test of the $.data.cards[0].nickname field "" of the interface me, the second interface address is: http: / / common.taxi.com.cn / commom / v5 / usercenter / me, and the JSON path of the abnormal test is: $.data.cards[0].nickname, wherein the JSON path of the abnormal test can also be called a matching target; the content of the abnormal test field is: "", wherein the content of the abnormal test field can also be "010101010000", a hyperlink, etc., which is adjusted according to the scenario of the abnormal test. The content of the abnormal test field can also be called a replacement content, which is used to replace the content of the target field in the response message. This is only an exemplary description and is determined according to actual conditions.
[0083] Step S103: Acquire the content of the target field in the response message according to the JSON path.
[0084] Specifically, since the JSON path in the exception test rule is the same as the JSON path for locating the target field in the response guarantee, the content of the target field in the response message can be obtained according to the JSON path; assuming that the content of the target field obtained according to the JSON path is "0136".
[0085] Step S104: Replace the content of the target field with the content of the abnormal test field in the pre-configured abnormal test rule to generate abnormal test data.
[0086] Specifically, assuming that the content of the exception test field in the exception test rule is the hyperlink "www.123456.com", that is, a null value, then the null value "" replaces the content of the target field with "0136" to generate exception test data, that is, replace "0136" in the response message with the hyperlink "www.123456.com", and the updated response message is the exception test data.
[0087] In the embodiment of the present invention, abnormal test data is dynamically generated by the above-mentioned pre-configured abnormal test rules without the need for user construction, which greatly improves the efficiency of generating abnormal test data and further improves the efficiency of abnormal testing.
[0088] In a possible implementation, after step S104, other steps are further included, specifically: Figure 3 As shown, specifically including:
[0089] Step S105: Send the abnormal test data to the client.
[0090] Specifically, the updated response message is sent to the client and displayed in the client application. Assume that the interface diagram of the interface request issued by the application is as follows: Figure 4 As shown, wherein, in the Figure 4 The value displayed in the setting position in is "0136". After receiving the updated response message, the interface of the application is updated. The updated interface diagram is as follows Figure 5 As described above, the position originally displayed "0136" in the display interface is updated to a hyperlink "www.123456.com", which is only for exemplary explanation.
[0091] In a possible implementation, a variety of abnormal test rules are pre-set according to different interface addresses in the interface request, and a variety of abnormal test data are dynamically generated to meet different test requirements.
[0092] In a possible implementation, before step S101, other steps are also included, specifically: Figure 6 As shown, specifically including:
[0093] Step S106: pre-configure the abnormality test rules.
[0094] In the embodiment of the present invention, the specific process of pre-configuring the abnormal test rule is as follows: Figure 7 As shown, the following steps are included:
[0095] Step S701: Receive a second interface address selection instruction and determine the second interface address.
[0096] Specifically, the second interface address shown is the interface address to be tested. Different interface addresses in the proxy tool have their corresponding historical response messages. Specifically, the interface diagram in the proxy tool is as follows: Figure 8 As shown in the Figure 8 The path "http: / / wttr.in / Dunedin" shown on the left is the second interface address. Figure 8 The right side shows the historical response message corresponding to the second interface address. Figure 8 The right side can also display request messages, network connections, time consumption statistics, and Mock, etc. This is only an example and will be determined based on actual conditions.
[0097] Step S702: Receive an instruction to create an exception test rule.
[0098] Specifically, the user triggers the creation instruction. For example, the user can click the Figure 8The "Common Test View" in triggers the creation of an exception test instruction, and the agent tool receives the creation of an exception test rule instruction.
[0099] Step S703: display the JSON path and all abnormal test scenarios.
[0100] In a possible implementation, the historical response message is displayed in the proxy terminal in a JSON structure, wherein the JSON structure includes multiple JSON paths. Specifically, the JSON structure and the abnormal test scenario in the proxy tool are as follows: Fig. 9 As shown in the Fig. 9 The left side is the JSON structure, and the right side is the abnormal test scenario, which can also be called the abnormal scenario.
[0101] Step S704: searching for an abnormal test field according to the JSON path, receiving the abnormal test field selection instruction, and determining the abnormal test field.
[0102] In a possible implementation, after the user searches for the field that needs to be tested for abnormality according to the JSON path, the user triggers an instruction to select the field that needs to be tested for abnormality, and the proxy tool receives the instruction to select the field that needs to be tested for abnormality, for example, Fig.10 As shown, the user selects "firstName: John" as the anomaly test field.
[0103] Step S705: Receive an abnormal test scenario selection instruction and determine at least one abnormal test scenario.
[0104] In a possible implementation, in the Fig.10 Different abnormal test scenarios can be set on the right side of the , and the user triggers the abnormal test scenario selection instruction. After the agent tool receives the abnormal test scenario selection instruction, it can select at least one abnormal test scenario. For example, different abnormal test scenarios are set for the abnormal test field "firstName: John", wherein the abnormal test scenarios include data abnormality, status code abnormality, and interface abnormality, etc. Fig.11 As shown, Fig.11 The abnormal test scenario selection column includes "", null, missing field, invalid hyperlink, hyperlink 404, str
[99] and color value abnormality, etc. The abnormal test scenarios set here for the abnormal test field "firstName: John" include: "", null, missing field, and str
[99] .
[0105] Step S706: Generate at least one abnormal test rule, wherein each abnormal test rule corresponds to an abnormal test scenario.
[0106] Specifically, the user clicks on the Fig.11 In "Create", generate at least one exception test rule; for example, generate 4 exception test rules, such as Fig.12 As shown, in Fig.12 "My Test" in the dialog box displays four exception test rules, namely: the $.firstname field "" exception test of the interface Dunedin; the $.firstname field null exception test of the interface Dunedin; the $.firstname field missing exception test of the interface Dunedin; the $.firstname field str
[99] exception test of the interface Dunedin; the four exception test rules are all in the closed state.
[0107] Step S107, start the abnormal test rule.
[0108] In one possible implementation, the user clicks the Fig.12 In the “on”, the agent tool turns on the exception test rule, as follows Fig.13 shown.
[0109] In a possible implementation, after the abnormal test rule is turned on, the user triggers the interface request to be tested and continues to execute steps S101 to S104, replacing the content of the target field with the content of the abnormal test field in the pre-configured abnormal test rule to generate abnormal test data; for example, "John" in the response message is updated to "" with a null value, and the specific abnormal test data is as follows: Fig.14 The illustrations shown here are for illustrative purposes only.
[0110] In the embodiment of the present invention, the process of configuring the abnormal test rules and generating the abnormal test data requires the participation of the client, the proxy tool and the server. The specific processing flow is as follows: Fig.15 As shown, including the following:
[0111] Step S1501: The proxy tool receives a tested interface address selection instruction triggered by a user and selects a tested interface address.
[0112] Step S1502: The proxy tool receives an instruction to create an exception test rule and starts to create an exception test rule.
[0113] Step S1503: The proxy tool displays the JSON path and all abnormal test scenarios.
[0114] Step S1504: The agent tool receives the abnormal test field selection instruction and determines the abnormal test field.
[0115] Step S1505: The agent tool receives an abnormal test scenario selection instruction and determines at least one abnormal test scenario;
[0116] Step S1506: The agent tool receives the creation instruction and generates at least one exception test rule.
[0117] Step S1507: The client receives an interface request triggered by the user.
[0118] Step S1508: The client sends the interface request to the server.
[0119] Step S1509: The server generates a response message according to the interface request.
[0120] Step S1510: The server sends the response message to the proxy tool.
[0121] Step S1511, after the proxy tool receives the response message, it determines whether the interface address in the pre-configured exception test rule is the same as the interface address in the interface request. If so, it obtains the JSON path in the pre-configured exception test rule and continues to execute step S1512. If not, it directly returns the response message to the client.
[0122] Step S1512: The proxy tool obtains the content of the target field in the response message according to the JSON path.
[0123] In a possible implementation, if the target field cannot be obtained, a response message is returned to the client.
[0124] Step S1513: The proxy tool replaces the content of the target field with the content of the abnormal test field in the pre-configured abnormal test rule to generate abnormal test data.
[0125] Step S1514: The proxy tool sends the abnormal test data to the client.
[0126] Step S1515: The client receives the abnormal test data.
[0127] In the embodiment of the present invention, when the user receives the abnormal test data at the client, the user observes the performance of the client in processing the abnormal test data and evaluates the robustness and exception handling capability of the application program.
[0128] Fig.16 FIG. 1 is a schematic diagram of a device for generating abnormal test data according to an embodiment of the present invention. Fig.16 As shown, the device of this embodiment includes an acquisition unit 1601 , a matching unit 1602 , and a processing unit 1603 .
[0129] Among them, the acquisition unit 1601 is used to obtain a response message sent by the server, wherein the response message carries a first interface address; the matching unit 1602, in response to the second interface address in the pre-configured exception test rule being the same as the first interface address, is used to obtain the JSON path in the pre-configured exception test rule; the acquisition unit 1601 is also used to obtain the content of the target field in the response message according to the JSON path; the processing unit 1603 is used to replace the content of the target field with the content of the exception test field in the pre-configured exception test rule to generate exception test data.
[0130] Furthermore, the device also includes:
[0131] A sending unit is used to send the abnormal test data to the client.
[0132] Furthermore, the device also includes:
[0133] A configuration unit is used to pre-configure the anomaly test rule.
[0134] Furthermore, the device also includes:
[0135] The enabling unit is used to enable the abnormal test rule.
[0136] Furthermore, the configuration unit is specifically used for:
[0137] receiving a second interface address selection instruction, and determining the second interface address;
[0138] Searching for an abnormal test field according to the JSON path, receiving the abnormal test field selection instruction, and determining the abnormal test field;
[0139] receiving an abnormal test scenario selection instruction and determining at least one abnormal test scenario;
[0140] At least one abnormal test rule is generated, wherein each abnormal test rule corresponds to an abnormal test scenario.
[0141] Furthermore, the device also includes:
[0142] The receiving unit is used to receive an instruction for creating an abnormal test rule.
[0143] Furthermore, the device also includes:
[0144] The display unit is used to display the JSON path and all abnormal test scenarios.
[0145] Furthermore, the abnormal test scenarios include data abnormalities, status code abnormalities and interface abnormalities.
[0146] Fig.17 Schematic diagram of an electronic device according to an embodiment of the present invention. Fig.17 As shown, Fig.17 The electronic device shown is a device for generating abnormal test data, which includes a general computer hardware structure, which at least includes a processor 1701 and a memory 1702. The processor 1701 and the memory 1702 are connected via a bus 1703. The memory 1702 is suitable for storing instructions or programs executable by the processor 1701. The processor 1701 can be an independent microprocessor or a collection of one or more microprocessors. Thus, the processor 1701 executes the instructions stored in the memory 1702, thereby executing the method flow of the embodiment of the present invention as described above to realize the processing of data and the control of other devices. The bus 1703 connects the above-mentioned multiple components together, and at the same time connects the above-mentioned components to the display controller 1704 and the display device and the input / output (I / O) device 1705. The input / output (I / O) device 1705 can be a mouse, a keyboard, a modem, a network interface, a touch input device, a somatosensory input device, a printer, and other devices known in the art. Typically, the input / output device 1705 is connected to the system via an input / output (I / O) controller 1706.
[0147] Among them, the instructions stored in the memory 1702 are executed by at least one processor 1701 to implement: obtaining a response message sent by the server, wherein the response message carries a first interface address; in response to the second interface address in the pre-configured exception test rule being the same as the first interface address, obtaining a JSON path in the pre-configured exception test rule; obtaining the content of the target field in the response message according to the JSON path; replacing the content of the target field with the content of the exception test field in the pre-configured exception test rule to generate exception test data.
[0148] Specifically, the electronic device includes: one or more processors 1701 and a memory 1702, Fig.17 Take a processor 1701 as an example. The processor 1701 and the memory 1702 may be connected via a bus or other means. Fig.17 In the example, the bus connection is used. The memory 1702 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The processor 1701 executes various functional applications and data processing of the device by running the non-volatile software programs, instructions and modules stored in the memory 1702, that is, the above-mentioned method of generating abnormal test data is realized.
[0149] The memory 1702 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store a list of options, etc. In addition, the memory 1702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 1702 may optionally include a memory remotely arranged relative to the processor 1701, and these remote memories may be connected to an external device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0150] One or more modules are stored in the memory 1702, and when executed by one or more processors 1701, the method for generating abnormal test data in any of the above method embodiments is executed.
[0151] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.
[0152] An embodiment of the present invention relates to a non-volatile storage medium for storing a computer-readable program, wherein the computer-readable program is used for a computer to execute part or all of the above method embodiments.
[0153] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0154] Those skilled in the art will appreciate that the above embodiments are specific embodiments for implementing the present invention, and that in actual applications, various changes may be made in form and detail without departing from the spirit and scope of the present invention.
[0155] The solutions described in this specification and in the examples, if they involve the processing of personal information, will be processed on the premise of having a legal basis (such as obtaining the consent of the subject of personal information, or being necessary for the performance of a contract, etc.), and will only be processed within the scope of regulations or agreements. If a user refuses to process personal information other than the necessary information for basic functions, it will not affect the user's use of basic functions.
Claims
1. A method for generating abnormal test data, characterized in that: The method comprises: Obtain a response message sent by the server, wherein the response message carries the first interface address; In response to the second interface address in the pre-configured exception test rule being the same as the first interface address, obtaining a JSON path in the pre-configured exception test rule; Acquire the content of the target field in the response message according to the JSON path; The content of the target field is replaced with the content of the abnormal test field in the pre-configured abnormal test rule to generate abnormal test data.
2. The method according to claim 1, characterized in that The method further comprises: The abnormal test data is sent to the client.
3. The method according to claim 1, characterized in that The method further comprises: The anomaly test rules are preconfigured.
4. The method according to claim 2, characterized in that The method further comprises: Enable the anomaly test rule.
5. The method according to claim 1, characterized in that The specific process of pre-configuring the abnormal test rules includes: receiving a second interface address selection instruction, and determining the second interface address; Searching for an abnormal test field according to the JSON path, receiving the abnormal test field selection instruction, and determining the abnormal test field; receiving an abnormal test scenario selection instruction and determining at least one abnormal test scenario; At least one abnormal test rule is generated, wherein each abnormal test rule corresponds to an abnormal test scenario.
6. The method according to claim 5, characterized in that The method further comprises: Receive instructions for creating exception test rules.
7. The method according to claim 6, characterized in that The method further comprises: Display the JSON path and all abnormal test scenarios.
8. The method according to claim 5, characterized in that The abnormal test scenarios include data abnormalities, status code abnormalities and interface abnormalities.
9. A device for generating abnormal test data, characterized in that: The device includes: An acquiring unit, configured to acquire a response message sent by the server, wherein the response message carries the first interface address; A matching unit, in response to the second interface address in the pre-configured anomaly test rule being the same as the first interface address, for obtaining a JSON path in the pre-configured anomaly test rule; The acquisition unit is further used to acquire the content of the target field in the response message according to the JSON path; The processing unit is used to replace the content of the target field with the content of the abnormal test field in the pre-configured abnormal test rule to generate abnormal test data.
10. A computer-readable storage medium storing computer program instructions, characterized in that: The computer program instructions implement the method according to any one of claims 1 to 8 when executed by a processor.
11. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.