Interface test case generation method and device, equipment, storage medium and product
By setting target parameters and generation rules, normal and exception parameter values are generated, the problem of low efficiency in generating interface test cases is solved, comprehensive and effective test coverage is achieved, and the stability and user experience of the interface are improved.
Patent Information
- Application Number
- CN202411126064.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-13
AI Technical Summary
In the prior art, interface test cases are generated with low efficiency and an efficient and fast method is needed to generate test cases to ensure the functionality, performance and reliability of the interface.
By presetting multiple target parameters, generating rules based on the type definition of each target parameter, generating normal parameter values and exception parameter values, and generating multiple test cases, including positive cases and countercases based on the standard test cases that have been successfully executed, to Overwrite possible input scenarios.
It realizes efficient and rapid generation of test cases, ensures the comprehensiveness and effectiveness of tests, can detect potential defects and boundary problems, and improves the robustness of the interface and user experience.
Smart Images

Figure CN119127676A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of software testing, and in particular, to a method, apparatus, device, storage medium and product for generating interface test cases. Background Art
[0002] Interface test cases refer to specific examples of testing interfaces between modules or services in a software system. Interface testing mainly verifies the functionality, performance, security, and reliability of interfaces, ensuring that data exchange and interaction between different modules or services can proceed normally. In the prior art, test cases are generally written one by one using multiple business parameters under the same business scenario, resulting in low efficiency in generating interface test cases.
[0003] Therefore, there is an urgent need for a method for generating interface test cases for efficiently and quickly generating test cases. Summary of the invention
[0004] The purpose of the embodiments of this specification is to provide a method, apparatus, device, storage medium and product for generating interface test cases, so as to generate test cases efficiently and quickly.
[0005] To achieve the above objectives, on the one hand, an embodiment of this specification provides a method for generating an interface test case, including:
[0006] Pre-set multiple target parameters;
[0007] According to the type of each target parameter, a generation rule of each target parameter is obtained;
[0008] Generate multiple parameter values of each target parameter according to the generation rule of each target parameter, wherein the multiple parameter values of each target parameter include normal parameter values and abnormal parameter values;
[0009] Based on the successfully executed standard test cases, multiple test cases are generated according to the multiple parameter values of each target parameter.
[0010] Preferably, obtaining a generation rule for each target parameter according to the type of each target parameter further includes:
[0011] If a target parameter is a character type, the generation rule is: according to the specified type of the character and the specified interval of the character, generate multiple parameter values of the target parameter, where the specified type of the character is a single type or a combined type;
[0012] If a target parameter is of numeric type, the generation rule is: generate multiple parameter values of a target parameter according to the specified range of the numeric value and the specified precision of the numeric value;
[0013] If a target parameter is of date type, the generation rule is: generate multiple parameter values of a target parameter according to the specified format of the date and the specified interval of the date;
[0014] If a target parameter is of Boolean type, the generation rule is: according to the specified attributes of the parameter value, multiple parameter values of a target parameter are generated, where a target parameter is a required parameter or a non-required parameter;
[0015] If the type of a target parameter is a target parameter derived from a data pool, the generation rule is: generate multiple parameter values of the target parameter according to the business characteristics of the parameter value.
[0016] Preferably, generating a plurality of parameter values of each target parameter according to the generation rule of each target parameter further comprises:
[0017] When a target parameter is of character type:
[0018] Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to the specified type of the character and the specified interval of the character, wherein the type of the normal parameter value is the specified type of the character and the length is within the specified interval of the character, and the type of the abnormal parameter value is not the specified type of the character or the length is not within the specified interval of the character;
[0019] When a target parameter is a numeric type:
[0020] Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified range of values and a specified precision of values, wherein the normal parameter value has a size that conforms to the specified range of values and a precision that conforms to the specified precision of values, and the abnormal parameter value has a size that does not conform to the specified range of values or a precision that does not conform to the specified precision of values;
[0021] When a target parameter is of date type:
[0022] Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified format of a date and a specified interval of a date, wherein a format of the normal parameter value conforms to the specified format of the date and a length conforms to the specified interval of the date, and a format of the abnormal parameter value does not conform to the specified format of the date or a length does not conform to the specified interval of the date;
[0023] When a target parameter is of Boolean type:
[0024] Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified attribute of the parameter;
[0025] When the type of a target parameter is a target parameter from a data pool:
[0026] According to the business characteristics of the parameters, at least one normal parameter value and at least one abnormal parameter value of a target parameter are generated, wherein the normal parameter value is a parameter value in the data pool that meets the business characteristics, and the abnormal parameter value is not a parameter value in the data pool, or is a parameter value in the data pool that does not meet the business characteristics.
[0027] Preferably, generating at least one normal parameter value and at least one abnormal parameter value of a target parameter according to the specified attribute of the parameter further comprises:
[0028] If a target parameter is a required parameter, the normal parameter value generated for the target parameter is a true value or a false value, and the abnormal parameter value is other values;
[0029] If a target parameter is a non-mandatory parameter, the normal parameter value generated for the target parameter is a true value, a false value, or a null value, and the abnormal parameter value is other values.
[0030] Preferably, the multiple test cases include positive cases and negative cases.
[0031] Preferably, the generating of multiple test cases based on the successfully executed standard test cases and according to the multiple parameter values of each target parameter further comprises:
[0032] Based on the format of the successfully executed standard test case, obtaining at least one normal parameter value of each target parameter, and generating at least one positive case;
[0033] Based on the format of the successfully executed standard test case, at least one abnormal parameter value of at least one target parameter among all target parameters is obtained, and at least one counter case is generated.
[0034] Preferably, it also includes:
[0035] If a certain target parameter is of character type, numeric type or date type, the corresponding generation rule also includes: the certain target parameter is a required parameter or a non-required parameter.
[0036] Preferably, it also includes:
[0037] When a target parameter is of character type:
[0038] If a target parameter is a required parameter, the type of a normal parameter value of the target parameter is a specified type of character, and the length is within a specified range of characters, and the type of an abnormal parameter value is not a specified type of character, or the length is not within a specified range of characters;
[0039] If a target parameter is a non-mandatory parameter, the type of a normal parameter value of the target parameter is a specified type of character, and the length is within a specified range of characters, or the normal parameter value is a null value, and the type of the abnormal parameter value is not a specified type of character, or the length is not within a specified range of characters;
[0040] When a target parameter is a numeric type:
[0041] If a target parameter is a required parameter, the size of the normal parameter value of the target parameter meets the specified range of values, and the precision meets the specified precision of the values, and the size of the abnormal parameter value does not meet the specified range of values, or the precision does not meet the specified precision of the values;
[0042] If a target parameter is a non-mandatory parameter, the size of the normal parameter value of the target parameter meets the specified range of the value, and the precision meets the specified precision of the value, or the normal parameter value is a null value, and the size of the abnormal parameter value does not meet the specified range of the value, or the precision does not meet the specified precision of the value;
[0043] When a target parameter is of date type:
[0044] If a target parameter is a required parameter, the format of a normal parameter value of the target parameter complies with the specified format of the date, and the length complies with the specified interval of the date, and the format of an abnormal parameter value does not comply with the specified format of the date, or the length does not comply with the specified interval of the date;
[0045] If a target parameter is a non-mandatory parameter, the format of the normal parameter value of the target parameter conforms to the specified format of the date, and the length conforms to the specified range of the date, or the normal parameter value is a null value, and the format of the abnormal parameter value does not conform to the specified format of the date, or the length does not conform to the specified range of the date.
[0046] On the other hand, an embodiment of the present specification provides a device for generating an interface test case, the device comprising:
[0047] A setting module, used to pre-set multiple target parameters;
[0048] A rule determination module, used to obtain a generation rule for each target parameter according to the type of each target parameter;
[0049] A parameter value generating module, configured to generate a plurality of parameter values of each target parameter according to a generating rule of each target parameter, wherein the plurality of parameter values of each target parameter include a normal parameter value and an abnormal parameter value;
[0050] The case generation module is used to generate multiple test cases based on the successfully executed standard test cases and according to the multiple parameter values of each target parameter.
[0051] On the other hand, an embodiment of the present specification further provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the instructions of any one of the above methods are executed.
[0052] On the other hand, an embodiment of the present specification further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor of a computer device, the computer program executes instructions of any one of the above-described methods.
[0053] On the other hand, the embodiments of this specification further provide a computer program product, which, when executed by a processor of a computer device, executes instructions of any one of the above methods.
[0054] It can be seen from the technical solution provided by the above embodiment of this specification that the generation method of the interface test case of the embodiment of this specification can generate test cases efficiently and quickly to ensure the comprehensiveness and effectiveness of the test. First, multiple target parameters are pre-set, which are input or request parameters that need to be verified in the interface test, such as user name, password, email, etc. Then, according to the type of each target parameter, the corresponding generation rules are defined, including length restrictions, character types, etc. According to these generation rules, multiple parameter values are generated for each target parameter, including normal parameter values that comply with the rules and abnormal parameter values that violate the rules. Normal parameter values are used to verify the functionality of the interface under normal input conditions, while abnormal parameter values are used to test the robustness and error handling capabilities of the interface. Finally, based on the successfully executed standard test cases, multiple test cases are created using these generated parameter values. In this way, possible input scenarios can be fully covered to ensure the stability and reliability of the interface under different conditions. The method of the embodiment of this specification can not only discover potential defects and boundary problems, but also improve the robustness and user experience of the interface.
[0055] In order to make the above and other purposes, features and advantages of the present specification more obvious and easy to understand, the following specifically cites preferred embodiments and describes them in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0057] Figure 1A schematic diagram of a flow chart of a method for generating an interface test case provided in an embodiment of this specification is shown;
[0058] Figure 2 A schematic diagram of a process for generating multiple test cases according to multiple parameter values of each target parameter based on a successfully executed standard test case provided by an embodiment of this specification is shown;
[0059] Figure 3 A schematic diagram of a flow chart of obtaining a generation rule for each target parameter according to the type of each target parameter provided in an embodiment of this specification is shown;
[0060] Figure 4 A schematic diagram of the module structure of a device for generating an interface test case provided in an embodiment of this specification is shown;
[0061] Figure 5 A schematic diagram of the structure of a computer device provided in an embodiment of this specification is shown.
[0062] Description of the accompanying symbols:
[0063] 100. Setting module;
[0064] 200. rule determination module;
[0065] 300. parameter value generation module;
[0066] 400. Case generation module;
[0067] 502. Computer equipment;
[0068] 504, processor;
[0069] 506. Memory;
[0070] 508, driving mechanism;
[0071] 510, input / output module;
[0072] 512. Input devices;
[0073] 514. Output device;
[0074] 516. Presentation equipment;
[0075] 518. Graphical user interface;
[0076] 520, network interface;
[0077] 522, communication link;
[0078] 524. Communication bus. DETAILED DESCRIPTION
[0079] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the embodiments of this specification.
[0080] Interface test cases refer to specific examples of testing interfaces between modules or services in a software system. Interface testing mainly verifies the functionality, performance, security, and reliability of interfaces, ensuring that data exchange and interaction between different modules or services can proceed normally. In the prior art, test cases are generally written one by one using multiple business parameters under the same business scenario, resulting in low efficiency in generating interface test cases.
[0081] In order to solve the above problems, an embodiment of this specification provides a method for generating an interface test case. Figure 1 It is a flowchart of a method for generating an interface test case provided in an embodiment of this specification. This specification provides method operation steps as described in the embodiment or flowchart, but more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the order of many steps and does not represent the only execution order. When the system or device product is executed in practice, it can be executed in the order of the method shown in the embodiment or the accompanying drawings or in parallel.
[0082] It should be noted that the terms "first", "second", etc. in the description and claims of the embodiments of this specification and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this specification described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0083] Reference Figure 1 , the embodiment of this specification provides a method for generating an interface test case, including:
[0084] S101: Pre-set multiple target parameters;
[0085] S102: Obtaining a generation rule for each target parameter according to the type of each target parameter;
[0086] S103: generating a plurality of parameter values of each target parameter according to a generation rule of each target parameter, wherein the plurality of parameter values of each target parameter include a normal parameter value and an abnormal parameter value;
[0087] S104: Based on the successfully executed standard test cases, multiple test cases are generated according to the multiple parameter values of each target parameter.
[0088] Among them, the multiple parameter values of each target parameter include normal parameter values and abnormal parameter values. Generally speaking, the multiple test cases include positive cases and negative cases. All parameter values in the positive cases are normal parameter values, and there is at least one parameter value in the negative cases that is an abnormal parameter value. In order to make the generated multiple test cases include both positive cases and negative cases, there is at least one abnormal parameter value among the multiple parameter values of each target parameter, so that the test cases can cover a wider range and the credibility of the test can be higher.
[0089] In the embodiments of this specification, refer to Figure 2 The generating of multiple test cases based on the successfully executed standard test cases and according to the multiple parameter values of each target parameter further comprises:
[0090] S201: Based on the format of the successfully executed standard test case, obtaining at least one normal parameter value of each target parameter, and generating at least one positive case;
[0091] S202: Based on the format of the successfully executed standard test case, obtain at least one abnormal parameter value of at least one target parameter among all target parameters, and generate at least one counter case.
[0092] For each target parameter, there are multiple corresponding parameter values. The multiple parameter values of the target parameter are generated according to the generation rules of the target parameter. When generating a test case, a successfully executed standard test case is used as a benchmark, and a format example can be provided. Each time, a parameter value is obtained from the multiple parameter values of each target parameter, and the parameter values obtained from the multiple target parameters are combined according to the standard test case to generate a test case. The above steps are repeated multiple times to generate multiple test cases.
[0093] In the embodiment of this specification, the number of positive cases is set to the number of normal parameter values corresponding to the target parameter with the most normal parameter values among all target parameters, and the number of negative cases is set to the sum of the number of abnormal parameter values of all target parameters.
[0094] For example, there are three target parameters, the first target parameter corresponds to a normal parameter value A1 and an abnormal parameter value A2, the second target parameter corresponds to a normal parameter value B1 and an abnormal parameter value B2, and the third target parameter corresponds to two normal parameter values C1, C2 and an abnormal parameter value C3. When generating a positive case, the normal parameter value A1, the normal parameter value B1 and the normal parameter value C1 are combined into the first positive case, the normal parameter value A1, the normal parameter value B1 and the normal parameter value C2 are combined into the second positive case, and when generating a negative case, the abnormal parameter value A2, the normal parameter value B1 and the normal parameter value C1 are combined into the first negative case, the normal parameter value A1, the abnormal parameter value B2 and the normal parameter value C1 are combined into the second negative case, and the normal parameter value A1, the normal parameter value B1 and the abnormal parameter value C3 are combined into the third negative case. For each test case generated, an ID number corresponding to the test case is generated to uniquely identify the test case, and the above test case is stored in the database for subsequent use.
[0095] In the counter-cases generated by the embodiments of this specification, there is generally only one parameter value which is an abnormal parameter value, and the other parameter values are all normal parameter values. In this way, targeted testing can be performed to obtain targeted test results. Of course, the generated counter-cases may also include multiple abnormal parameter values, such as abnormal parameter value A2, abnormal parameter value B2 and abnormal parameter value C3 combined into a certain counter-case. However, after such a setting, when the test results do not meet expectations, it is not easy to locate the problem.
[0096] In the embodiments of this specification, refer to Figure 3 , the generation rule of each target parameter obtained according to the type of each target parameter further includes:
[0097] S301: If a target parameter is a character type, the generation rule is: according to the specified type of the character and the specified interval of the character, generate multiple parameter values of the target parameter, wherein the specified type of the character is a single type or a combined type;
[0098] S302: If a target parameter is of a numerical type, the generation rule is: generating multiple parameter values of the target parameter according to a specified range of the numerical value and a specified precision of the numerical value;
[0099] S303: If a target parameter is of date type, the generation rule is: generate multiple parameter values of a target parameter according to a specified format of the date and a specified interval of the date;
[0100] S304: If a target parameter is of Boolean type, the generation rule is: according to the specified attribute of the parameter value, multiple parameter values of the target parameter are generated, wherein the target parameter is a required parameter or a non-required parameter;
[0101] S305: If the type of a target parameter is a target parameter from a data pool, the generation rule is: generate multiple parameter values of the target parameter according to the business characteristics of the parameter value.
[0102] When the target parameter is of character type, the generated parameter value is a character. The specified type of the character can include letter type, number type, Chinese character type, special character type, etc. The specified interval of the character is the length interval of the character. For example, the specified interval corresponding to the letter type is 5-10, which means that the parameter value consists of 5-10 letters. The specified type of the character is a single type or a combination type. A single type means that the parameter value consists of only a single type, and a combination type means that the parameter value is composed of multiple characters, such as a combination of letter type and number type.
[0103] When the target parameter is of numeric type, the generated parameter value is a numeric value. The specified range of the numeric value is the size range of the numeric value, for example, 0-255, which means that the parameter value is any value within 0-255. The specified precision of the numeric value is the number of digits after the decimal point, for example, 3, which means that it is accurate to 3 decimal places.
[0104] When the target parameter is of date type, the generated parameter value is a date. The specified format of the date is, for example, the format of XXXX-XX-XX, or the format of XXXX.XX.XX, etc. The specified range of the date is, for example, a date within the range from 2024-08-01 to 2024-08-31.
[0105] When the target parameter is of Boolean type, the target parameter is a required parameter or a non-required parameter. If it is a required parameter, the specified attributes of the parameter value include true value and false value. If it is a non-required parameter, the specified attributes of the parameter value include true value, false value and null value.
[0106] When the target parameter is a target parameter derived from a data pool, there are multiple data in the data pool. The target parameter extracts data that meets the business characteristics from the data pool as parameter values. The business characteristics of the parameter values include parameter values for specified systems, specified states, etc. For example, if the specified system is the first system, only the data of the first system in the data pool is obtained as the parameter value.
[0107] Specifically, generating multiple parameter values of each target parameter according to the generation rule of each target parameter further includes:
[0108] When a target parameter is of character type:
[0109] Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to the specified type of the character and the specified interval of the character, wherein the type of the normal parameter value is the specified type of the character and the length is within the specified interval of the character, and the type of the abnormal parameter value is not the specified type of the character or the length is not within the specified interval of the character;
[0110] When a target parameter is a numeric type:
[0111] Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified range of values and a specified precision of values, wherein the normal parameter value has a size that conforms to the specified range of values and a precision that conforms to the specified precision of values, and the abnormal parameter value has a size that does not conform to the specified range of values or a precision that does not conform to the specified precision of values;
[0112] When a target parameter is of date type:
[0113] Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified format of a date and a specified interval of a date, wherein a format of the normal parameter value conforms to the specified format of the date and a length conforms to the specified interval of the date, and a format of the abnormal parameter value does not conform to the specified format of the date or a length does not conform to the specified interval of the date;
[0114] When a target parameter is of Boolean type:
[0115] Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified attribute of the parameter;
[0116] When the type of a target parameter is a target parameter from a data pool:
[0117] According to the business characteristics of the parameters, at least one normal parameter value and at least one abnormal parameter value of a target parameter are generated, wherein the normal parameter value is a parameter value in the data pool that meets the business characteristics, and the abnormal parameter value is not a parameter value in the data pool, or is a parameter value in the data pool that does not meet the business characteristics.
[0118] When the target parameter generation rule is followed, a corresponding normal parameter value can be generated. When the target parameter generation rule is not followed, a corresponding abnormal parameter value can be generated.
[0119] Wherein, generating at least one normal parameter value and at least one abnormal parameter value of a target parameter according to the specified attribute of the parameter further includes:
[0120] If a target parameter is a required parameter, the normal parameter value generated for the target parameter is a true value or a false value, and the abnormal parameter value is other values;
[0121] If a target parameter is a non-mandatory parameter, the normal parameter value generated for the target parameter is a true value, a false value, or a null value, and the abnormal parameter value is other values.
[0122] The embodiments of this specification also include:
[0123] If a certain target parameter is of character type, numeric type or date type, the corresponding generation rule also includes: the certain target parameter is a required parameter or a non-required parameter.
[0124] Specific:
[0125] When a target parameter is of character type:
[0126] If a target parameter is a required parameter, the type of a normal parameter value of the target parameter is a specified type of character, and the length is within a specified range of characters, and the type of an abnormal parameter value is not a specified type of character, or the length is not within a specified range of characters;
[0127] If a target parameter is a non-mandatory parameter, the type of a normal parameter value of the target parameter is a specified type of character, and the length is within a specified range of characters, or the normal parameter value is a null value, and the type of the abnormal parameter value is not a specified type of character, or the length is not within a specified range of characters;
[0128] When a target parameter is a numeric type:
[0129] If a target parameter is a required parameter, the size of the normal parameter value of the target parameter meets the specified range of values, and the precision meets the specified precision of the values, and the size of the abnormal parameter value does not meet the specified range of values, or the precision does not meet the specified precision of the values;
[0130] If a target parameter is a non-mandatory parameter, the size of the normal parameter value of the target parameter meets the specified range of the value, and the precision meets the specified precision of the value, or the normal parameter value is a null value, and the size of the abnormal parameter value does not meet the specified range of the value, or the precision does not meet the specified precision of the value;
[0131] When a target parameter is of date type:
[0132] If a target parameter is a required parameter, the format of a normal parameter value of the target parameter complies with the specified format of the date, and the length complies with the specified interval of the date, and the format of an abnormal parameter value does not comply with the specified format of the date, or the length does not comply with the specified interval of the date;
[0133] If a target parameter is a non-mandatory parameter, the format of the normal parameter value of the target parameter conforms to the specified format of the date, and the length conforms to the specified range of the date, or the normal parameter value is a null value, and the format of the abnormal parameter value does not conform to the specified format of the date, or the length does not conform to the specified range of the date.
[0134] The generated normal parameters and abnormal parameters are shown in Table 1 below, where the teller code is a character type, the transaction password is a numeric type, and the transaction date is a date type.
[0135] Table 1
[0136]
[0137] According to multiple parameter values of each target parameter in Table 1, multiple test cases are generated as shown in Table 2 below.
[0138] Table 2
[0139] serial number Target parameter 1 Target parameter 2 Target parameter 3 Remark 1 310259 111111 20210210 Positive Case 1 2 310259 111111 20210211 Positive Case 2 3 a12345 111111 20210210 Counter-Case 1 4 310259 123456 20210210 Counter-Case 2 5 310259 111111 02-10-2021 Counter-Case 3
[0140] Through the generation method of the interface test case of the embodiment of this specification, the test case can be generated efficiently and quickly to ensure the comprehensiveness and effectiveness of the test. First, multiple target parameters are pre-set, which are input or request parameters that need to be verified in the interface test, such as user name, password, email, etc. Then, according to the type of each target parameter, the corresponding generation rules are defined, including length restrictions, character types, etc. According to these generation rules, multiple parameter values are generated for each target parameter, including normal parameter values that comply with the rules and abnormal parameter values that violate the rules. Normal parameter values are used to verify the functionality of the interface under normal input conditions, while abnormal parameter values are used to test the robustness and error handling capabilities of the interface. Finally, based on the successfully executed standard test cases, multiple test cases are created using these generated parameter values. In this way, possible input scenarios can be fully covered to ensure the stability and reliability of the interface under different conditions. The method of the embodiment of this specification can not only discover potential defects and boundary problems, but also improve the robustness and user experience of the interface.
[0141] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0142] This application provides users with corresponding big data analysis (such as personal biometrics, identity data, consumption data, asset data, electronic terminal operation data, etc.) operation entrances for users to choose to agree or reject automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered.
[0143] Based on the above-mentioned method for generating an interface test case, the embodiment of this specification also provides a device for generating an interface test case. The device may include a system (including a distributed system), software (application), module, component, server, client, etc. using the method described in the embodiment of this specification and a device combined with necessary implementation hardware. Based on the same innovative concept, the device in one or more embodiments provided in the embodiment of this specification is as described in the following embodiments. Since the implementation scheme and method for solving the problem of the device are similar, the implementation of the specific device in the embodiment of this specification can refer to the implementation of the aforementioned method, and the repetitions will not be repeated. As used below, the term "unit" or "module" can implement a combination of software and / or hardware for predetermined functions. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0144] Specifically, Figure 4 This is a schematic diagram of the module structure of an embodiment of a device for generating an interface test case provided in an embodiment of this specification, referring to Figure 4 As shown, an interface test case generation device provided in an embodiment of the present specification includes: a setting module 100, a rule determination module 200, a parameter value generation module 300, and a case generation module 400.
[0145] A setting module 100, used to pre-set a plurality of target parameters;
[0146] A rule determination module 200, for obtaining a generation rule for each target parameter according to the type of each target parameter;
[0147] A parameter value generating module 300, configured to generate a plurality of parameter values of each target parameter according to a generating rule of each target parameter, wherein the plurality of parameter values of each target parameter include a normal parameter value and an abnormal parameter value;
[0148] The case generation module 400 is used to generate multiple test cases based on the successfully executed standard test cases and according to the multiple parameter values of each target parameter.
[0149] Reference Figure 5As shown, based on the above-mentioned method for generating an interface test case, a computer device 502 is also provided in an embodiment of this specification, wherein the above-mentioned method is run on the computer device 502. The computer device 502 may include one or more processors 504, such as one or more central processing units (CPUs) or graphics processing units (GPUs), and each processing unit may implement one or more hardware threads. The computer device 502 may also include any memory 506, which is used to store any kind of information such as code, settings, data, etc. In a specific implementation, a computer program on the memory 506 and executable on the processor 504, when the computer program is executed by the processor 504, can execute instructions according to the above-mentioned method. Non-limitingly, for example, the memory 506 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 502. In one embodiment, when the processor 504 executes the associated instructions stored in any memory or combination of memories, the computer device 502 can perform any operation of the associated instructions. The computer device 502 also includes one or more drive mechanisms 508 for interacting with any memory, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.
[0150] The computer device 502 may also include an input / output module 510 (I / O) for receiving various inputs (via input devices 512) and for providing various outputs (via output devices 514). A specific output mechanism may include a presentation device 516 and an associated graphical user interface 518 (GUI). In other embodiments, the input / output module 510 (I / O), input device 512, and output device 514 may not be included, and the computer device 502 may be used as a computer device in a network. The computer device 502 may also include one or more network interfaces 520 for exchanging data with other devices via one or more communication links 522. One or more communication buses 524 couple the components described above together.
[0151] The communication link 522 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 522 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.
[0152] Corresponds to Figure 1-Figure 3The method in the embodiment of the present specification also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are executed.
[0153] The embodiment of the present specification also provides a computer-readable instruction, wherein when the processor executes the instruction, the program therein causes the processor to execute the following Figures 1 to 3 The method shown.
[0154] The present specification also provides a computer program product. When the computer program product is executed by a processor of a computer device, the computer program product performs the following steps: Figures 1 to 3 The method shown.
[0155] The computer program product described in this specification is a software product that mainly implements the method described in this specification through a computer program.
[0156] It should be understood that in the various embodiments of this specification, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this specification.
[0157] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the embodiments of this specification generally indicates that the associated objects before and after are in an "or" relationship.
[0158] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of this specification can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments of this specification.
[0159] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0160] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0161] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of this specification.
[0162] In addition, each functional unit in each embodiment of this specification may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0163] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of this specification is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of this specification. 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 code.
[0164] Specific embodiments are used in this specification to illustrate the principles and implementation methods of the embodiments of this specification. The description of the above embodiments is only used to help understand the methods and core ideas of the embodiments of this specification. At the same time, for those skilled in the art, according to the ideas of the embodiments of this specification, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the embodiments of this specification.
Claims
1. A method for generating interface test cases, It is characterized in that include: Pre-set multiple target parameters; According to the type of each target parameter, a generation rule of each target parameter is obtained; Generate multiple parameter values of each target parameter according to the generation rule of each target parameter, wherein the multiple parameter values of each target parameter include normal parameter values and abnormal parameter values; Based on the successfully executed standard test cases, multiple test cases are generated according to the multiple parameter values of each target parameter.
2. The method according to claim 1, It is characterized in that The step of obtaining a generation rule for each target parameter according to the type of each target parameter further includes: If a target parameter is a character type, the generation rule is: according to the specified type of the character and the specified interval of the character, generate multiple parameter values of the target parameter, where the specified type of the character is a single type or a combined type; If a target parameter is of numeric type, the generation rule is: generate multiple parameter values of a target parameter according to the specified range of the numeric value and the specified precision of the numeric value; If a target parameter is of date type, the generation rule is: generate multiple parameter values of a target parameter according to the specified format of the date and the specified interval of the date; If a target parameter is of Boolean type, the generation rule is: according to the specified attributes of the parameter value, multiple parameter values of a target parameter are generated, where a target parameter is a required parameter or a non-required parameter; If the type of a target parameter is a target parameter derived from a data pool, the generation rule is: generate multiple parameter values of the target parameter according to the business characteristics of the parameter value.
3. The method according to claim 2, It is characterized in that Generating a plurality of parameter values of each target parameter according to the generation rule of each target parameter further comprises: When a target parameter is of character type: Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to the specified type of the character and the specified interval of the character, wherein the type of the normal parameter value is the specified type of the character and the length is within the specified interval of the character, and the type of the abnormal parameter value is not the specified type of the character or the length is not within the specified interval of the character; When a target parameter is a numeric type: Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified range of values and a specified precision of values, wherein the normal parameter value has a size that conforms to the specified range of values and a precision that conforms to the specified precision of values, and the abnormal parameter value has a size that does not conform to the specified range of values or a precision that does not conform to the specified precision of values; When a target parameter is of date type: Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified format of a date and a specified interval of a date, wherein a format of the normal parameter value conforms to the specified format of the date and a length conforms to the specified interval of the date, and a format of the abnormal parameter value does not conform to the specified format of the date or a length does not conform to the specified interval of the date; When a target parameter is of Boolean type: Generate at least one normal parameter value and at least one abnormal parameter value of a target parameter according to a specified attribute of the parameter; When the type of a target parameter is a target parameter from a data pool: According to the business characteristics of the parameters, at least one normal parameter value and at least one abnormal parameter value of a target parameter are generated, wherein the normal parameter value is a parameter value in the data pool that meets the business characteristics, and the abnormal parameter value is not a parameter value in the data pool, or is a parameter value in the data pool that does not meet the business characteristics.
4. The method according to claim 3, It is characterized in that The step of generating at least one normal parameter value and at least one abnormal parameter value of a target parameter according to the specified attribute of the parameter further comprises: If a target parameter is a required parameter, the normal parameter value generated for the target parameter is a true value or a false value, and the abnormal parameter value is other values; If a target parameter is a non-mandatory parameter, the normal parameter value generated for the target parameter is a true value, a false value, or a null value, and the abnormal parameter value is other values.
5. The method according to claim 3, It is characterized in that include: The plurality of test cases include positive cases and negative cases.
6. The method according to claim 5, It is characterized in that The generating of multiple test cases based on the successfully executed standard test cases and according to the multiple parameter values of each target parameter further comprises: Based on the format of the successfully executed standard test case, obtaining at least one normal parameter value of each target parameter, and generating at least one positive case; Based on the format of the successfully executed standard test case, at least one abnormal parameter value of at least one target parameter among all target parameters is obtained, and at least one counter case is generated.
7. The method according to claim 3, It is characterized in that Also includes: If a certain target parameter is of character type, numeric type or date type, the corresponding generation rule also includes: the certain target parameter is a required parameter or a non-required parameter.
8. The method according to claim 7, It is characterized in that Also includes: When a target parameter is of character type: If a target parameter is a required parameter, the type of a normal parameter value of the target parameter is a specified type of character, and the length is within a specified range of characters, and the type of an abnormal parameter value is not a specified type of character, or the length is not within a specified range of characters; If a target parameter is a non-mandatory parameter, the type of a normal parameter value of the target parameter is a specified type of character, and the length is within a specified range of characters, or the normal parameter value is a null value, and the type of the abnormal parameter value is not a specified type of character, or the length is not within a specified range of characters; When a target parameter is a numeric type: If a target parameter is a required parameter, the size of the normal parameter value of the target parameter meets the specified range of values, and the precision meets the specified precision of the values, and the size of the abnormal parameter value does not meet the specified range of values, or the precision does not meet the specified precision of the values; If a target parameter is a non-mandatory parameter, the size of the normal parameter value of the target parameter meets the specified range of the value, and the precision meets the specified precision of the value, or the normal parameter value is a null value, and the size of the abnormal parameter value does not meet the specified range of the value, or the precision does not meet the specified precision of the value; When a target parameter is of date type: If a target parameter is a required parameter, the format of a normal parameter value of the target parameter complies with the specified format of the date, and the length complies with the specified interval of the date, and the format of an abnormal parameter value does not comply with the specified format of the date, or the length does not comply with the specified interval of the date; If a target parameter is a non-mandatory parameter, the format of the normal parameter value of the target parameter conforms to the specified format of the date, and the length conforms to the specified range of the date, or the normal parameter value is a null value, and the format of the abnormal parameter value does not conform to the specified format of the date, or the length does not conform to the specified range of the date.
9. A device for generating interface test cases, It is characterized in that The device comprises: A setting module, used to pre-set multiple target parameters; A rule determination module, used to obtain a generation rule for each target parameter according to the type of each target parameter; A parameter value generating module, configured to generate a plurality of parameter values of each target parameter according to a generating rule of each target parameter, wherein the plurality of parameter values of each target parameter include a normal parameter value and an abnormal parameter value; The case generation module is used to generate multiple test cases based on the successfully executed standard test cases and according to the multiple parameter values of each target parameter.
10. A computer device comprising a memory, a processor, and a computer program stored on the memory, It is characterized in that When the computer program is executed by the processor, the computer program executes the instructions of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor of a computer device, the computer program executes the instructions of the method according to any one of claims 1 to 8.
12. A computer program product, It is characterized in that When the computer program product is executed by a processor of a computer device, the computer program product executes instructions of the method according to any one of claims 1 to 8.
