Interface testing method and device, electronic equipment and storage medium

By generating and verifying test data of interface parameters, the problems of interface camel and compliance verification in the prior art are solved, and the stability and efficiency of the system are guaranteed.

CN120144461APending Publication Date: 2025-06-13SHANDONG CVIC SOFTWARE ENG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510283205.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

In software testing, it is difficult for the prior art to effectively verify the hump and compliance of the interface, resulting in difficult to ensure system stability and efficiency.

Method used

By generating test data for the interface parameters to be tested and target interface parameters, using absolute paths and parameter values ​​for camel value and compliance verification, ensuring that the interface parameters comply with the rules of the design document.

Benefits of technology

It realizes effective verification of interface camel value and compliance, ensures the stability and efficiency of the system, and improves the maintainability and scalability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144461A_ABST
    Figure CN120144461A_ABST
Patent Text Reader

Abstract

The invention provides an interface testing method and device, electronic equipment and a storage medium, and the method comprises the steps: generating test data of each to-be-tested interface parameter according to a to-be-tested feature case, and generating test data of each target interface parameter according to an interface design document; performing a first test according to the absolute path in the test data of the to-be-tested interface parameter and the absolute path in the test data of the target interface parameter; and / or, according to an absolute path and a parameter value in the test data of the to-be-tested interface parameter, and an absolute path and a parameter rule in the test data of the target interface parameter, carrying out a second test to obtain an interface test result of the to-be-tested feature case; the first test is used for verifying whether the to-be-tested interface parameters conform to the hump value verification rule or not, and the second test is used for verifying whether the to-be-tested interface parameters conform to the compliance verification rule or not, so that verification of the hump value and compliance of the interface can be realized to ensure the stability and high efficiency of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of interface testing, and particularly relates to an interface testing method, device, electronic device and storage medium. Background Art

[0002] Interface hump naming refers to the use of lower camel case or upper camel case naming methods when naming variables, functions, classes, etc. in programming. The lower camel case naming method means that the first word starts with a lowercase letter and the first letter of subsequent words is capitalized, such as firstName, lastName; the upper camel case naming method is that the first letter of each word is capitalized, such as FirstName, LastName, CamelCase. In interface development, the camel case naming method is widely used because it can improve the readability and consistency of the code. For example, in Json data interaction, the camel case naming method makes the field names more intuitive, easier to understand and use.

[0003] In software engineering, the application of interfaces is extensive and crucial. Interfaces play the role of a bridge and link between different systems and components, ensuring the effective transmission of data and the collaborative work of functions. Among them, in object-oriented programming, interfaces define the behavior specifications of objects, enabling different classes to implement the same interface and thus have similar functions; moreover, it can also achieve software modularity and pluggability, facilitating system maintenance and upgrade; in addition, through interfaces, software hierarchical design can be realized, reducing the coupling degree between different layers of the system and improving the maintainability and scalability of the system.

[0004] Due to the importance of interfaces, during software testing, the function implementation of interfaces, the verification of interface hump naming, and the compliance verification of interfaces should be fully considered to ensure the stability and efficiency of the system. Summary of the Invention

[0005] In view of this, the present application provides an interface testing method, device, electronic device and storage medium, which can realize the verification of interface hump naming and compliance to ensure the stability and efficiency of the system.

[0006] To achieve the above object, the embodiments of the present invention provide the following technical solutions:

[0007] The first aspect of the present application discloses an interface testing method, including:

[0008] Generate test data for each parameter of the interface to be tested according to the use case of the feature to be tested, and generate test data for each parameter of the target interface according to the interface design document; the parameters of the interface to be tested include the input parameters of the interface to be tested and the response content parameters of the interface to be tested, and the parameters of the target interface include the input parameters of the target interface and the response content parameters of the target interface;

[0009] Conduct a first test based on the absolute paths in the test data of the parameters of the interface to be tested and the absolute paths in the test data of the parameters of the target interface; and / or, conduct a second test based on the absolute paths and parameter values in the test data of the parameters of the interface to be tested and the absolute paths and parameter rules in the test data of the parameters of the target interface to obtain the interface test result of the use case of the feature to be tested; the first test is used to verify whether the parameters of the interface to be tested conform to the camel case verification rule, and the second test is used to verify whether the parameters of the interface to be tested conform to the compliance verification rule.

[0010] Optionally, in the above interface test method, the test data of the parameters of the interface to be tested includes: absolute path and parameter value, and generating the test data of each parameter of the interface to be tested according to the use case of the feature to be tested includes:

[0011] Determine the feature use case information of the use case of the feature to be tested, and the feature use case information at least includes: the interface number to be tested, the function module of the interface to be tested, the use case feature, and the input content;

[0012] Read and write the feature use case information by using a preset test case interface class, and establish a mapping relationship between each attribute in the preset test case interface class and the feature use case information;

[0013] Generate the absolute path and parameter value of each parameter of the interface to be tested according to the mapping relationship.

[0014] Optionally, in the above interface test method, generating the absolute path and parameter value of each parameter of the interface to be tested according to the mapping relationship includes:

[0015] For each parameter of the interface to be tested, traverse layer by layer according to the mapping relationship to obtain the absolute path and parameter value of each parameter of the interface to be tested;

[0016] Among them, the parameter value of the parameter of the interface to be tested is the value of the value finally traversed.

[0017] Optionally, in the above interface test method, the test data of the parameters of the target interface includes: absolute path and parameter rule, and generating the test data of each parameter of the target interface according to the interface design document includes:

[0018] Sort out the interface design document to obtain the input and output specifications of the interface design document, where the input and output specifications at least include interface design number, interface design type, interface design name, interface design parameter name, interface design attribute, interface mandatory requirements, and interface design rules;

[0019] Read the input and output specifications using a preset interface request response content rule class;

[0020] Generate the absolute path and parameter rules for each target interface parameter according to the reading result.

[0021] Optionally, in the above interface testing method, generating the absolute path of each target interface parameter according to the reading result includes:

[0022] Determine the interface design type and interface design parameter name of each target interface parameter according to the reading result;

[0023] Concatenate the interface design type and interface design parameter name of each target interface parameter to obtain the absolute path of the target interface parameter.

[0024] Optionally, in the above interface testing method, the first verification based on the absolute path in the test data of the interface parameter to be tested and the absolute path in the test data of the target interface parameter includes:

[0025] Perform a consistency comparison between the absolute path in the test data of the interface parameter to be tested and the absolute path in the test data of the target interface parameter; where a consistent comparison result indicates that the interface parameter to be tested conforms to the camel case verification rule, and an inconsistent comparison result indicates that the interface parameter to be tested does not conform to the camel case verification rule.

[0026] Optionally, in the above interface testing method, the second verification based on the absolute path and parameter value in the test data of the interface parameter to be tested and the absolute path and rule in the test data of the target interface parameter includes:

[0027] Judge whether the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter;

[0028] If it is judged that the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter, then judge whether the parameter value in the test data of the interface parameter to be tested conforms to the parameter rule in the test data of the target interface parameter;

[0029] Among them, if it is determined that the parameter value in the test data of the to-be-tested interface parameter does not conform to the parameter rule in the test data of the target interface parameter, it indicates that the to-be-tested interface parameter does not conform to the compliance verification rule; if it is determined that the parameter value in the test data of the to-be-tested interface parameter conforms to the parameter rule in the test data of the target interface parameter, it indicates that the to-be-tested interface parameter conforms to the compliance verification rule.

[0030] The second aspect of the present application discloses an interface testing device, including:

[0031] A generating unit, configured to generate test data for each to-be-tested interface parameter according to the to-be-tested feature use case, and generate test data for each target interface parameter according to the interface design document; the to-be-tested interface parameters include to-be-tested interface input parameters and to-be-tested interface response content parameters, and the target interface parameters include target interface input parameters and target interface response content parameters;

[0032] A testing unit, configured to perform a first test according to the absolute paths in the test data of the to-be-tested interface parameter and the absolute paths in the test data of the target interface parameter; and / or, perform a second test according to the absolute paths and parameter values in the test data of the to-be-tested interface parameter and the absolute paths and parameter rules in the test data of the target interface parameter, to obtain the interface test result of the to-be-tested feature use case; the first test is used to verify whether the to-be-tested interface parameter conforms to the camel case verification rule, and the second test is used to verify whether the to-be-tested interface parameter conforms to the compliance verification rule.

[0033] The third aspect of the present application discloses an electronic device, including: a memory and a processor;

[0034] Among them, the memory is used to store a computer program;

[0035] The processor is used to execute the computer program, and specifically used to implement the interface testing method as described in any one of the first aspect.

[0036] The fourth aspect of the present application discloses a computer storage medium, used to store a computer program, and when the computer program is executed, it is specifically used to implement the interface testing method as described in any one of the first aspect.

[0037] The present invention provides an interface testing method, including: generating test data for each parameter of the interface to be tested according to the test cases of the features to be tested, and generating test data for each parameter of the target interface according to the interface design document; the parameters of the interface to be tested include the input parameters of the interface to be tested and the response content parameters of the interface to be tested, and the parameters of the target interface include the input parameters of the target interface and the response content parameters of the target interface; performing a first test according to the absolute paths in the test data of the parameters of the interface to be tested and the absolute paths in the test data of the parameters of the target interface; and / or, performing a second test according to the absolute paths and parameter values in the test data of the parameters of the interface to be tested and the absolute paths and parameter rules in the test data of the parameters of the target interface to obtain the interface test result of the test cases of the features to be tested; the first test is used to verify whether the parameters of the interface to be tested conform to the camel case verification rule, and the second test is used to verify whether the parameters of the interface to be tested conform to the compliance verification rule, which can realize the verification of the camel case and compliance of the interface to ensure the stability and efficiency of the system. Description of the Drawings

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.

[0039] Figure 1 It is a flowchart of an interface testing method provided by this application;

[0040] Figure 2 It is a flowchart of generating test data for parameters of an interface to be tested provided by an embodiment of this application;

[0041] Figure 3 It is a flowchart of generating test data for parameters of a target interface provided by an embodiment of this application;

[0042] Figure 4 It is a schematic structural diagram of an interface testing device provided by an embodiment of this application;

[0043] Figure 5 It is a schematic structural diagram of an electronic device provided by an embodiment of this application. Detailed Embodiments

[0044] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.

[0045] First of all, it should be noted that this application mainly involves rule testing. Among them, camel case verification is used to verify whether the naming method of interface parameters meets the requirements of the interface design document, and compliance verification is used to verify whether the format of interface parameter values meets the requirements of the interface design document. Specifically, meeting the camel case verification rule means that the spelling of interface request parameters / response content parameters conforms to the requirements of the design document, and the number of interface request parameters / response content parameters meets the number requirements of the design document. Meeting the compliance verification means that whether the interface request parameters / response content parameters are required, whether the parameter values are within the range defined in the design document, and the time format of the parameter values all meet the requirements of the interface design document.

[0046] The embodiments of this application provide an interface testing method, device, electronic device, and storage medium, which can implement the verification of camel case and compliance of the interface to ensure the stability and efficiency of the system.

[0047] Please refer to Figure 1 , and the interface testing method mainly includes the following steps:

[0048] S101. Generate test data for each interface parameter to be tested according to the test case of the feature to be tested, and generate test data for each target interface parameter according to the interface design document.

[0049] Among them, the feature test case is the code for the system to execute an event during operation, and the feature test case includes the input and response of the interface. The test case of the feature to be tested is the feature test case that the system or platform needs to perform software interface testing, and the test case of the feature to be tested includes at least one interface parameter to be tested. Exemplarily, the test case of the feature to be tested can be a Json (JavaScript Object Notation) string for successfully calling the interface.

[0050] The target interface parameter is the parameter used to test the interface parameter to be tested in the interface design document, and there is a corresponding target interface parameter in the interface design document for each interface parameter to be tested.

[0051] In practical applications, the interface parameters to be tested mainly include the input parameters of the interface to be tested and the response content parameters of the interface to be tested. The specific type of the interface parameter to be tested can be determined according to the "use case feature" in the feature case information of the test case of the feature to be tested. Exemplarily, if the "use case feature" in the feature case information of the test case of the feature to be tested is a request parameter, the interface parameter to be tested is the input parameter of the interface to be tested; if the "use case feature" in the feature case information of the test case of the feature to be tested is the response content, the interface parameter to be tested is the response content parameter of the interface to be tested.

[0052] Corresponding to the interface parameters to be tested, the target interface parameters include input parameters and response content parameters. The type of the target interface is determined according to the interface design type in the input-output specification of the interface design document. Exemplarily, if the interface design type in the input-output specification of the interface design document is request parameters, the target interface parameters are the target interface input parameters; if the interface design type in the input-output specification of the interface design document is response content, the target interface parameters are the target interface response content parameters.

[0053] In some embodiments, the test data of the interface parameters to be tested may include: absolute path and parameter value; wherein, the absolute path of the interface parameter to be tested is the complete path when the interface parameter to be tested is called during the running of the test case of the feature to be tested; the parameter value of the interface parameter to be tested is the final value of the interface parameter to be tested when it is called during the running of the test case of the feature to be tested. Specifically, the process of generating the test data of each interface parameter to be tested according to the test case of the feature to be tested may be as Figure 2 , mainly including steps S201 to S203:

[0054] S201. Determine the feature case information of the test case of the feature to be tested.

[0055] The feature case information at least includes: the interface number to be tested, the function module of the interface to be tested, the case feature, and the input content.

[0056] In practice, by sorting out the test case of the feature to be tested, the feature case information of the test case of the feature to be tested can be obtained. Among them, the feature case information of the test case of the feature to be tested can be sorted into a table form and stored in a sheet page in the form of an electronic document.

[0057] Exemplarily, the test case of the feature to be tested is Json that conforms to the interface specification, and the feature case information of the test case of the feature to be tested can be expressed as Table 1-1:

[0058] Table 1-1 Feature Case Information Table

[0059]

[0060] It should be noted that the interface number to be tested is the number of the interface to be tested, which is an Arabic numeral, and the interface to be tested is the interface corresponding to the interface parameter to be tested; the function module of the interface to be tested is the name of the interface function module, such as login; the case feature is the "request parameter" and "response content" filled in according to the requirements in the interface design document; the input content is a typical Json string that conforms to the interface specification.

[0061] S202. Use the preset test case interface class to read the feature case information and establish the mapping relationship between each attribute in the preset test case interface class and the feature case information.

[0062] Among them, the preset test case interface class can be the CaseInfo class. The characteristic use case information is read through the CaseInfo class, and the mapping relationship between each attribute in the CaseInfo class and the characteristic use case information is established. Specifically, the specific characteristic use case information can be obtained through the get method and set method of the CaseInfo class.

[0063] S203. Generate the absolute path and parameter value of each interface parameter to be tested according to the mapping relationship.

[0064] For each interface parameter to be tested, the absolute path and parameter value of each interface parameter to be tested can be obtained through layer-by-layer traversal according to the mapping relationship. Among them, the parameter value of the interface parameter to be tested is the finally traversed value value.

[0065] During the process of layer-by-layer traversal according to the mapping relationship, it can be determined in real time whether the traversal layer reaches the preset layer. If the traversal layer reaches the preset layer or traverses to the last layer, it is considered that the layer-by-layer traversal is completed. The absolute path and parameter value of each interface parameter to be tested can be generated according to the traversal result when the traversal reaches the preset layer or the traversal result of the last layer; otherwise, if the traversal layer does not reach the preset layer, it is considered that the layer-by-layer traversal is not completed, and the traversal should continue until the traversal layer reaches the preset layer or traverses to the last layer, so as to generate the absolute path and parameter value of each interface parameter to be tested.

[0066] Specifically, the preset layer can be any positive integer, such as 5, 4, 3, 2, 1, etc., which can be determined according to the application environment and user requirements, and all are within the protection scope of this application.

[0067] In practical applications, the parameters in the input content of the characteristic use case to be tested can be processed into absolute paths, so as to obtain the absolute path of each interface parameter to be tested.

[0068] It can be understood that taking the interface parameter to be tested as a Json parameter as an example, the key value path of the Json parameter can be expressed as "request parameter - the previous layer - parameter name(parameterName) - the current - parameter name(parameterName)".

[0069] For further understanding, the following is an exemplary description:

[0070] Suppose the Json string corresponding to the request parameter is as follows:

[0071] {

[0072] "userId": "00817",

[0073] "password": "123458"

[0074] }

[0075] The Json string corresponding to the response content is:

[0076] {

[0077] "responseCode": "00",

[0078] "info": {"birth": "2000-01-01", "deparmen": "Testing Center", "goodAt": [{"enable": "automation"}, {"enable": "oracle"}]},

[0079] }

[0080] , after processing the request parameters into absolute paths, they are represented as: request parameter - userId, request parameter - password. After processing the response content parameters into absolute paths, they are represented as: response content - responseCode, response content - info, response content - goodAt. This is the processing effect of the first-level parameters; response content - info - age, response content - info - department, response content - goodAt - enable. This is the processing effect of the second-level parameters. Since the "attribute" of goodAt is JsonArray and there are multiple JsonObjects in the JsonArray, only the parameters of the first JsonObject are processed here.

[0081] The following is the implementation process of the main method paraPortContainer (method name) of the test case interface class. paraPortContainer passes in the "input content (inputParams)" and "case feature (title)" values of the feature case and returns the absolute path of the parameter, and places the absolute path of the parameter in the List <string>(The data object storing strings in Java), the specific code is as follows:

[0082] * Parameter 1: bodyString is a Json string,

[0083] * Parameter 2: diffInfo is the request parameter or the response content

[0084] * Complete five-layer Json nesting, jsonAray jsonObject

[0085] * * /

[0086] public static List <string>paraPortContainer(String bodyString, String diffInfo) {

[0087] List <string>returnList = new ArrayList <string>();

[0088] / / Return the key values (paths) and value values of each layer

[0089] Map<String, Object> secondMap = new HashMap<>();

[0090] Map<String, Object> threeMap = new HashMap<>();

[0091] Map<String, Object> fourMap = new HashMap<>();

[0092] Map<String, Object> fiveMap = new HashMap<>();

[0093] Map<String, Object> sixMap = new HashMap<>();

[0094] / **The first layer* /

[0095] JSONObject jsonObject = new JSONObject(bodyString); / / Convert the incoming parameter into a JSONObject object for subsequent processing

[0096] Iterator <string>keys = jsonObject.keys(); / / Get all the key values

[0097] while (keys.hasNext()) { / / Traverse all the keys

[0098] String key = keys.next();

[0099] returnList.add(diffInfo + "-" + key); / / Obtain the path of each key, e.g., request parameter - parameter name

[0100] String value = String.valueOf(jsonObject.get(key)); / / Get the value

[0101] / / Verify whether the value of the input Json meets the requirements of the design document, format: absolute path of key $ value

[0102] portParaList.add(diffInfo + "-" + key + "$" + value);

[0103] if (!value.isEmpty() && value != null) {

[0104] / / Obtain the absolute path and value of the keys in the next layer, i.e., the second layer

[0105] if (value.substring(0, 1).equals("{") || value.substring(0, 1).equals("[")) {

[0106] secondMap.put(diffInfo + "-" + key, value);

[0107] }

[0108] }

[0109] }

[0110] / **Second layer - Return the paths and values of the second layer parameters* /

[0111] if (secondMap.size() > 0) {

[0112] threeMap = returnNextFloor(secondMap, returnList); / / Output the passed-in parameter as an absolute path

[0113] }

[0114] / ** Third layer - Return the path and value of the third layer parameters * /

[0115] if (threeMap.size() > 0) {

[0116] fourMap = returnNextFloor(threeMap, returnList); / / Output the passed-in parameter as an absolute path

[0117] }

[0118] / ** Fourth layer - Return the path and value of the fourth layer parameters * /

[0119] if (fourMap.size() > 0) {

[0120] fiveMap = returnNextFloor(fourMap, returnList); / / Output the passed-in parameter as an absolute path

[0121] }

[0122] / ** Fifth layer - Return the path and value of the fifth layer parameters * /

[0123] if (fiveMap.size() > 0) {

[0124] sixMap = returnNextFloor(fiveMap, returnList); / / Output the passed-in parameter as an absolute path

[0125] }

[0126] return returnList; / / Return the paths of all parameters.

[0127] In some embodiments, the test data of the target interface parameter includes: the absolute path and the parameter rule; wherein, the absolute path of the target interface parameter is the complete path required for the target interface parameter to perform a call in the interface design document, and the parameter rule of the target interface parameter is the rule that the return parameter needs to conform to the format requirement when the target interface parameter performs a call in the interface design document. For example, when the target interface parameter requests to call the date of birth, the data format of the return parameter is YYYY-MM-DD. Specifically, the process of generating the test data for each target interface parameter according to the interface design document in step S101 can be as Figure 3 , which mainly includes steps S301 to S303:

[0128] S301. Determine the input and output specifications of the interface design document.

[0129] Among them, the input and output specifications at least include the interface design number, interface design type, interface design name, interface design parameter name, interface design attribute, interface mandatory requirement, interface design rule, and interface design rule remarks, etc.

[0130] In practice, the interface design document can be sorted out to obtain the input and output specifications of the interface design document. Among them, the input and output specifications of the interface design document can be in the form of a table and stored in a sheet page in the form of an electronic document.

[0131] Exemplarily, the input and output specifications of the interface design document can be represented as Table 1-2:

[0132] Table 1-2 Input and Output Specification Table

[0133] Interface Design Number (caseld) Interface Design Type (types) Interface Design Name (names) Interface Design Parameter Name (parameterName) Interface Design Attribute (attribute) Interface Design Mandatory Requirement (required) Interface Design Rule (rule) 1-1 Request Parameters User Number userId String Yes 1-2 Request Parameters Password passWord String Yes 1-3 Response Content Response Code responseCode String Yes 00|01|02|99 1-4 Response Content Response Information info JsonOject No 1-5 Response Content - info Date of Birth birth String No YYYY-MM-DD 1-6 Response Content - info Department department String No 1-7 Response Content Proficient in goodAt JsonArray No 1-8 Response Content - goodAt Proficient Subjects enable String No

[0134] It should be noted that for the interface design number (caseld): it is the number of the interface to be tested in Table 1-1 followed by - serial number. For example, if the number of this interface in Table 1-1 is 1, then the interface design number (caseld) in Table 1-2 is 1-1, 1-2, 1-3... The interface design type (types): fill in "request parameter", "response content", and fill in the path of the parent node of this parameter. The interface design name (names): the Chinese name of the parameter, filled in according to the interface design document. The interface design parameter name (parameterName): the English name of the parameter, filled in according to the interface design document. The interface design attribute (attribute): the type of the parameter, such as String, JsonObject, JsonArray, filled in according to the interface design document. The interface design mandatory requirement (required): filled in according to the interface design document, yes / no. The interface design rule (rule): filled in according to the interface design document, format: for example, if the responseCode value requirements are 00, 01, 02, 99, then fill in 00|01|02|99 here; for example, if birth requires YYYY-MM-DD, then fill in YYYY-MM-DD here, and do not fill in if there is no requirement.

[0135] S302. Read the input and output specifications using the preset interface request response content rule class.

[0136] Among them, the preset interface request response content rule class can be the CaseRuleInfo class. Through the CaseRuleInfo class, the input and output specifications of the interface design document can be read; of course, it is not limited to this, and it can also be read through other existing interface request response content rule classes. This application does not make specific limitations and is within the protection scope of this application.

[0137] S303. Generate the absolute path and parameter rule of each target interface parameter according to the read result.

[0138] In practical applications, the specific process of generating the absolute path of each target interface parameter according to the read result is as follows: first determine the interface design type and interface design parameter name of each target interface parameter according to the read result; then splice the interface design type and interface design parameter name of each target interface parameter to obtain the absolute path of the target interface parameter. And the interface design rule (rule) read can be directly used as the parameter rule of the target interface parameter according to the read result.

[0139] It should be noted that through the CaseRuleInfo class, the interface design parameter name (parameterName) can be processed into an absolute path, so as to obtain the absolute path of each target interface parameter.

[0140] It can be understood that the interface design type (types) and the interface design parameter name (parameterName) can be obtained through the CaseRuleInfo class, and the interface design type - interface design parameter name is concatenated into a string, which is the absolute path of this parameter.

[0141] It should also be noted that after obtaining the absolute path and parameter rules of each target interface parameter, the absolute paths of all parameters can be put into a List <string>In the data object (the data object storing strings in Java).

[0142] S102. Conduct a first test based on the absolute paths in the test data of the interface parameters to be measured and the absolute paths in the test data of the target interface parameters; and / or, conduct a second test based on the absolute paths and parameter values in the test data of the interface parameters to be measured and the absolute paths and parameter rules in the test data of the target interface parameters, to obtain the interface test result of the test case for the feature to be measured.

[0143] Among them, the first test is used to verify whether the interface parameters to be measured comply with the camel peak verification rule, and the second test is used to verify whether the interface parameters to be measured comply with the compliance verification rule.

[0144] In practical applications, the process of the first test can be: comparing the absolute path in the test data of the interface parameters to be measured with the absolute path in the test data of the target interface parameters; among them, a consistent comparison result indicates that the interface parameters to be measured comply with the camel peak verification rule, and an inconsistent comparison result indicates that the interface parameters to be measured do not comply with the camel peak verification rule. A consistent comparison result means that in the absolute path of the target interface parameter corresponding to the interface parameter to be measured, there is an absolute path that is the same as the absolute path of the interface parameter to be measured, and the number of interface parameters to be measured is the same as the number of test data of the target interface parameter.

[0145] Specifically, the absolute path List processed by the CaseInfo class can be used <string>, the absolute path List of the input and output specification parameters processed by the CaseRuleInfo class <string>Perform data consistency comparison.

[0146] It should be noted that, according to the parameter number of the interface to be tested and the interface design number, the interface parameters to be tested and the target interface parameters to be compared can be determined; for example, referring to Table 1-1 and Table 1-2, if the parameter number of the interface to be tested is 1, the interface design numbers of the target interface parameters for consistency comparison with the interface parameter to be tested corresponding to this parameter number of the interface to be tested are 1-1, 1-2, 1-3, 1-4, 1-5, 1-6, 1-7, 1-8.

[0147] The process of the second test can be: determining whether the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter; if it is determined that the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter, then determining whether the parameter value in the test data of the interface parameter to be tested conforms to the parameter rule in the test data of the target interface parameter; among them, if it is determined that the parameter value in the test data of the interface parameter to be tested conforms to the parameter rule in the test data of the target interface parameter, it indicates that the interface parameter to be tested conforms to the compliance verification rule; if it is determined that the parameter value in the test data of the interface parameter to be tested does not conform to the parameter rule in the test data of the target interface parameter, it indicates that the interface parameter to be tested does not conform to the compliance verification rule.

[0148] In practice, the method of comparing the absolute path in the test data of the interface parameter to be tested with the absolute path in the test data of the target interface parameter can be used to determine whether the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter. The specific process can refer to the above, and will not be elaborated here.

[0149] It should be noted that after performing the first test and / or the second test, the interface test result of the test case for the feature to be tested can be obtained, and at the same time, the interface test result can be output to a table document for relevant personnel to consult.

[0150] It should also be noted that the preset test case interface class and the preset interface request-response content rule class can be integrated in the test tool, and the above interface test can be implemented through the test tool.

[0151] Based on the above, the interface testing method provided in this embodiment includes: generating test data for each parameter of the interface to be tested according to the test cases of the features to be tested, and generating test data for each parameter of the target interface according to the interface design document; the parameters of the interface to be tested include the input parameters of the interface to be tested and the response content parameters of the interface to be tested, and the parameters of the target interface include the input parameters of the target interface and the response content parameters of the target interface; performing a first test according to the absolute paths in the test data of the parameters of the interface to be tested and the absolute paths in the test data of the parameters of the target interface; and / or, performing a second test according to the absolute paths and parameter values in the test data of the parameters of the interface to be tested and the absolute paths and parameter rules in the test data of the parameters of the target interface, to obtain the interface test result of the test cases of the features to be tested; the first test is used to verify whether the parameters of the interface to be tested conform to the camel case verification rule, and the second test is used to verify whether the parameters of the interface to be tested conform to the compliance verification rule, which can realize the verification of the camel case and compliance of the interface to ensure the stability and efficiency of the system.

[0152] Optionally, another embodiment of the present application further provides an interface testing device, please refer to Figure 4 The interface testing device mainly includes:

[0153] A generating unit 101, configured to generate test data for each parameter of the interface to be tested according to the test cases of the features to be tested, and generate test data for each parameter of the target interface according to the interface design document; the parameters of the interface to be tested include the input parameters of the interface to be tested and the response content parameters of the interface to be tested, and the parameters of the target interface include the input parameters of the target interface and the response content parameters of the target interface;

[0154] A testing unit 102, configured to perform a first test according to the absolute paths in the test data of the parameters of the interface to be tested and the absolute paths in the test data of the parameters of the target interface; and / or, perform a second test according to the absolute paths and parameter values in the test data of the parameters of the interface to be tested and the absolute paths and parameter rules in the test data of the parameters of the target interface, to obtain the interface test result of the test cases of the features to be tested; the first test is used to verify whether the parameters of the interface to be tested conform to the camel case verification rule, and the second test is used to verify whether the parameters of the interface to be tested conform to the compliance verification rule.

[0155] In some embodiments, the test data of the parameters of the interface to be tested includes: absolute path and parameter value, and generating test data for each parameter of the interface to be tested according to the test cases of the features to be tested includes:

[0156] Determining the feature case information of the test cases of the features to be tested, where the feature case information at least includes: the number of the interface to be tested, the function module of the interface to be tested, the case feature, and the input content;

[0157] Reading and writing the feature case information by using a preset test case interface class, and establishing a mapping relationship between each attribute in the preset test case interface class and the feature case information;

[0158] Generate the absolute path and parameter value of each interface parameter to be tested according to the mapping relationship.

[0159] In some embodiments, generating the absolute path and parameter value of each interface parameter to be tested according to the mapping relationship includes:

[0160] For each interface parameter to be tested, traverse layer by layer according to the mapping relationship to obtain the absolute path and parameter value of each interface parameter to be tested;

[0161] Among them, the parameter value of the interface parameter to be tested is the value of the value finally traversed by the interface parameter to be tested.

[0162] In some embodiments, the test data of the target interface parameter includes: the absolute path and parameter rules. Generating the test data of each target interface parameter according to the interface design document includes:

[0163] Sort out the interface design document to obtain the input and output specifications of the interface design document. The input and output specifications at least include the interface design number, interface design type, interface design name, interface design parameter name, interface design attribute, interface mandatory requirement, and interface design rule;

[0164] Use the preset interface request and response content rule class to read the input and output specifications;

[0165] Generate the absolute path and parameter rules of each target interface parameter according to the reading result.

[0166] In some embodiments, generating the absolute path of each target interface parameter according to the reading result includes:

[0167] Determine the interface design type and interface design parameter name of each target interface parameter according to the reading result;

[0168] Concatenate the interface design type and interface design parameter name of each target interface parameter to obtain the absolute path of the target interface parameter.

[0169] In some embodiments, the first verification according to the absolute path in the test data of the interface parameter to be tested and the absolute path in the test data of the target interface parameter includes:

[0170] Compare the absolute path in the test data of the interface parameter to be tested with the absolute path in the test data of the target interface parameter for consistency; among them, the consistent comparison result indicates that the interface parameter to be tested conforms to the camel case verification rule, and the inconsistent comparison result indicates that the interface parameter to be tested does not conform to the camel case verification rule.

[0171] In some embodiments, the second verification based on the absolute path and parameter value in the test data of the interface parameter to be tested and the absolute path and rules in the test data of the target interface parameter includes:

[0172] Determine whether the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter;

[0173] If it is determined that the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter, then determine whether the parameter value in the test data of the interface parameter to be tested conforms to the parameter rules in the test data of the target interface parameter;

[0174] Wherein, if it is determined that the parameter value in the test data of the interface parameter to be tested does not conform to the parameter rules in the test data of the target interface parameter, it indicates that the interface parameter to be tested does not conform to the compliance verification rules; if it is determined that the parameter value in the test data of the interface parameter to be tested conforms to the parameter rules in the test data of the target interface parameter, it indicates that the interface parameter to be tested conforms to the compliance verification rules.

[0175] The interface testing device provided in this embodiment, the generating unit 101 is used to generate the test data of each interface parameter to be tested according to the test case of the feature to be tested, and generate the test data of each target interface parameter according to the interface design document; the interface parameters to be tested include the input parameters of the interface to be tested and the response content parameters of the interface to be tested, and the target interface parameters include the input parameters of the target interface and the response content parameters of the target interface; the testing unit 102 is used to perform the first test according to the absolute path in the test data of the interface parameter to be tested and the absolute path in the test data of the target interface parameter; and / or, perform the second test according to the absolute path and parameter value in the test data of the interface parameter to be tested and the absolute path and parameter rules in the test data of the target interface parameter, and obtain the interface test result of the test case of the feature to be tested; the first test is used to verify whether the interface parameter to be tested conforms to the camel case verification rule, and the second test is used to verify whether the interface parameter to be tested conforms to the compliance verification rule, which can realize the verification of the camel case and compliance of the interface to ensure the stability and efficiency of the system.

[0176] It should be noted that the relevant descriptions of the units of the interface testing device can be found in the corresponding method embodiments above, and will not be elaborated here one by one.

[0177] Optionally, another embodiment of the present application further provides a computer storage medium for storing a computer program, which is specifically used to implement the interface testing method provided in any embodiment of the present application when the computer program is executed.

[0178] It should be noted that the relevant descriptions of the interface testing method can be found in the above embodiments, and will not be elaborated here.

[0179] Optionally, another embodiment of the present application further provides an electronic device, such as Figure 5 shown, the electronic device includes a memory 601 and a processor 602.

[0180] Among them, the memory 601 is used to store computer programs;

[0181] The processor 602 is used to execute the computer program, and specifically used to implement the interface test method provided by any embodiment of the present application.

[0182] It should be noted that for the relevant descriptions of the interface test method, the above embodiments can also be referred to, and will not be elaborated here.

[0183] The features described in each embodiment of this specification can be replaced or combined with each other. For the same or similar parts between each embodiment, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, reference can be made to the partial description of the method embodiment. The systems and system embodiments described above are merely illustrative. 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 may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative work. Professionals can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by 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 according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professionals 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 present invention.

[0184] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0185] It should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.< / string> < / string> < / string> < / string> < / string> < / string> < / string> < / string>

Claims

1. An interface testing method, characterized in that: include: Generate test data for each interface parameter to be tested based on the feature use case to be tested, and generate test data for each target interface parameter based on the interface design document; The interface parameters to be tested include input parameters of the interface to be tested and response content parameters of the interface to be tested, and the target interface parameters include input parameters of the target interface and response content parameters of the target interface; Performing a first test according to the absolute path in the test data of the interface parameter to be tested and the absolute path in the test data of the target interface parameter; And / or, performing a second test based on the absolute path and parameter value in the test data of the interface parameter to be tested and the absolute path and parameter rule in the test data of the target interface parameter to obtain the interface test result of the feature case to be tested; The first test is used to verify whether the interface parameters to be tested comply with the hump value verification rules, and the second test is used to verify whether the interface parameters to be tested comply with the compliance verification rules.

2. The interface testing method according to claim 1, characterized in that: The test data of the interface parameter to be tested includes: an absolute path and a parameter value. The test data of each interface parameter to be tested generated according to the feature case to be tested includes: Determine the characteristic use case information of the characteristic use case to be tested, wherein the characteristic use case information at least includes: the number of the interface to be tested, the functional module of the interface to be tested, the use case characteristics and the input content; Using a preset test case interface class to read and write the characteristic test case information, and establishing a mapping relationship between each attribute in the preset test case interface class and the characteristic test case information; According to the mapping relationship, an absolute path and a parameter value of each interface parameter to be tested are generated.

3. The interface testing method according to claim 2, characterized in that: Generating the absolute path and parameter value of each of the interface parameters to be tested according to the mapping relationship includes: For each of the interface parameters to be tested, traverse layer by layer according to the mapping relationship to obtain the absolute path and parameter value of each of the interface parameters to be tested; The parameter value of the interface parameter to be tested is the value finally obtained by traversal.

4. The interface testing method according to claim 1, characterized in that: The test data of the target interface parameters include: absolute path and parameter rules. The test data of each target interface parameter generated according to the interface design document includes: The interface design document is sorted to obtain input and output specifications of the interface design document, wherein the input and output specifications at least include an interface design number, an interface design type, an interface design name, an interface design parameter name, an interface design attribute, an interface mandatory requirement, and an interface design rule; Using a preset interface request response content rule class to read the input and output specifications; According to the reading result, an absolute path and parameter rule of each target interface parameter are generated.

5. The interface testing method according to claim 2, characterized in that: Based on the reading results, the absolute path of each target interface parameter is generated including: Determine the interface design type and interface design parameter name of each target interface parameter according to the reading result; The interface design type and the interface design parameter name of each of the target interface parameters are concatenated to obtain the absolute path of the target interface parameter.

6. The interface testing method according to claim 1, characterized in that: Performing a first verification according to the absolute path in the test data of the interface parameter to be tested and the absolute path in the test data of the target interface parameter includes: The absolute path in the test data of the interface parameter to be tested is compared for consistency with the absolute path in the test data of the target interface parameter; wherein, a consistent comparison result indicates that the interface parameter to be tested complies with the hump value verification rule, and an inconsistent comparison result indicates that the interface parameter to be tested does not comply with the hump value verification rule.

7. The interface testing method according to claim 1, characterized in that: Performing a second verification based on the absolute path and parameter value in the test data of the interface parameter to be tested and the absolute path and rule in the test data of the target interface parameter includes: Determine whether the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter; If it is determined that the absolute path in the test data of the interface parameter to be tested is the same as the absolute path in the test data of the target interface parameter, then determining whether the parameter value in the test data of the interface parameter to be tested conforms to the parameter rule in the test data of the target interface parameter; Among them, if it is judged that the parameter value in the test data of the interface parameter to be tested does not comply with the parameter rule in the test data of the target interface parameter, it indicates that the interface parameter to be tested does not comply with the compliance verification rule; if it is judged that the parameter value in the test data of the interface parameter to be tested complies with the parameter rule in the test data of the target interface parameter, it indicates that the interface parameter to be tested complies with the compliance verification rule.

8. An interface testing device, characterized in that: include: A generating unit, used to generate test data for each interface parameter to be tested according to the feature use case to be tested, and to generate test data for each target interface parameter according to the interface design document; The interface parameters to be tested include input parameters of the interface to be tested and response content parameters of the interface to be tested, and the target interface parameters include input parameters of the target interface and response content parameters of the target interface; A testing unit, configured to perform a first test according to an absolute path in the test data of the interface parameter to be tested and an absolute path in the test data of the target interface parameter; And / or, performing a second test based on the absolute path and parameter value in the test data of the interface parameter to be tested and the absolute path and parameter rule in the test data of the target interface parameter to obtain the interface test result of the feature case to be tested; The first test is used to verify whether the interface parameters to be tested comply with the hump value verification rules, and the second test is used to verify whether the interface parameters to be tested comply with the compliance verification rules.

9. An electronic device, characterized in that: include: Memory and processor; Wherein, the memory is used to store computer programs; The processor is used to execute the computer program, specifically to implement the interface testing method as described in any one of claims 1-7.

10. A computer storage medium, characterized in that: Used to store a computer program, which, when executed, is specifically used to implement the interface testing method as described in any one of claims 1-7.