CN106708676B - Interface test method and device - Google Patents

Interface test method and device Download PDF

Info

Publication number
CN106708676B
CN106708676B CN201611092061.0A CN201611092061A CN106708676B CN 106708676 B CN106708676 B CN 106708676B CN 201611092061 A CN201611092061 A CN 201611092061A CN 106708676 B CN106708676 B CN 106708676B
Authority
CN
China
Prior art keywords
parameter
target interface
test input
test
specified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611092061.0A
Other languages
Chinese (zh)
Other versions
CN106708676A (en
Inventor
李焕雄
常明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Kugou Computer Technology Co Ltd
Original Assignee
Guangzhou Kugou Computer Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Kugou Computer Technology Co Ltd filed Critical Guangzhou Kugou Computer Technology Co Ltd
Priority to CN201611092061.0A priority Critical patent/CN106708676B/en
Publication of CN106708676A publication Critical patent/CN106708676A/en
Application granted granted Critical
Publication of CN106708676B publication Critical patent/CN106708676B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2205Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2273Test methods

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses an interface testing method and device, and belongs to the technical field of computers. The method comprises the following steps: acquiring definition information of a target interface; determining test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface; and transmitting the test input parameters to the target interface, so that the target interface operates based on the test input parameters, and generating a test report. According to the method and the device, the definition information of the target interface is acquired, the test input parameter of the target interface is determined according to the specified parameter type and the specified parameter range of the target interface, and the test input parameter is automatically transmitted to the target interface, so that the target interface operates based on the test input parameter, a test report is generated, the target interface can be tested without manually analyzing the definition information by a tester, the test time is saved, and the test efficiency is improved.

Description

Interface test method and device
Technical Field
The invention relates to the technical field of computers, in particular to an interface testing method and device.
Background
With the development of computer technology, applications in various shapes and colors are developed, and each application includes a plurality of interfaces, so that different functions can be realized through different interfaces. When a developer develops each interface, definition information is compiled for each interface, functions, input parameters and the like of the interface are described, and a tester can test the interface according to the definition information.
In order to test whether the target interface can normally operate, after a tester obtains definition information of the target interface, the tester needs to manually analyze the definition information so as to determine a test input parameter and a theoretical response result which is obtained if the test input parameter is transmitted to the target interface. And then, the test input parameters are transmitted to the target interface, so that the target interface operates based on the test input parameters, and the target interface is tested.
In the process of implementing the invention, the inventor finds that the related art has at least the following problems: the process of manually determining the test input parameters is complicated, and the consumed time is too long, so that the test efficiency is low.
Disclosure of Invention
In order to solve the problems of the related art, embodiments of the present invention provide an interface testing method and apparatus. The technical scheme is as follows:
in one aspect, a method for testing an interface is provided, where the method includes:
acquiring definition information of a target interface, wherein the definition information comprises an appointed parameter type of the target interface and a corresponding appointed parameter range, the appointed parameter type is the type of an input parameter when the target interface operates normally, and the appointed parameter range is the range to which the input parameter belongs when the target interface operates normally;
determining test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface;
and transmitting the test input parameters to the target interface, so that the target interface operates based on the test input parameters, and generating a test report, wherein the test report is used for determining whether the target interface operates normally.
In one possible implementation, the test input parameters include a first test input parameter, and the first test input parameter is a parameter belonging to the specified parameter type and belonging to the specified parameter range, and the method further includes:
determining a theoretical response result which is obtained if the first test input parameter is transmitted to the target interface according to the function description information of the target interface in the definition information;
and when the actual response result corresponding to the first test input parameter in the test report is matched with the theoretical response result, determining that the target interface operates normally.
In another possible implementation manner, the determining the test input parameter of the target interface according to the specified parameter type and the specified parameter range of the target interface includes:
and acquiring a median value belonging to the specified parameter type in the specified parameter range, and determining the median value as a test input parameter.
In another possible implementation manner, the test input parameter includes a second test input parameter, where the second test input parameter is a parameter that does not belong to the specified parameter type, and the method further includes:
and when the actual response result corresponding to the second test input parameter in the test report comprises error prompt information, determining that the target interface operates normally.
In another possible implementation manner, the determining the test input parameter of the target interface according to the specified parameter type and the specified parameter range of the target interface includes:
acquiring a first parameter belonging to the specified parameter type;
converting the type of the first parameter to obtain a second parameter, wherein the second parameter does not belong to the specified parameter type;
determining the second parameter as a test input parameter.
In another possible implementation manner, the test input parameters include a third test input parameter, where the third test input parameter is a parameter that does not belong to the specified parameter range, and the method further includes:
and when the actual response result corresponding to the third test input parameter in the test report comprises error prompt information, determining that the target interface operates normally.
In another possible implementation manner, the specified parameter type includes a mandatory parameter type, the test input parameter includes a fourth test input parameter, and the fourth test input parameter is a null parameter, where the method further includes:
and when the actual response result corresponding to the fourth test input parameter in the test report comprises error prompt information, determining that the target interface operates normally.
In another possible implementation manner, the determining the test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface includes:
taking the designated parameter types and the designated parameter ranges which correspond to each other as a group to obtain a plurality of groups;
determining alternative input parameters of each group according to the specified parameter type and the specified parameter range in each group;
combining the alternative input parameters belonging to different groups to obtain a plurality of alternative parameter combinations;
selecting a test input parameter combination from the multiple candidate parameter combinations, and determining each parameter in the test input parameter combination as a test input parameter.
In another possible implementation manner, the obtaining definition information of the target interface includes:
acquiring a first interface file in a js format, wherein the first interface file comprises the definition information;
converting the first interface file into a JavaScript object notation json format to obtain a second interface file;
converting the second interface file into an extensible markup language (XML) format to obtain a third interface file;
and analyzing the third interface file to obtain the definition information.
In another aspect, an interface testing apparatus is provided, the apparatus including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring definition information of a target interface, the definition information comprises an appointed parameter type of the target interface and a corresponding appointed parameter range, the appointed parameter type refers to the type of an input parameter when the target interface normally operates, and the appointed parameter range refers to the range to which the input parameter belongs when the target interface normally operates;
the determining module is used for determining the test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface;
and the parameter transmitting module is used for transmitting the test input parameters to the target interface, so that the target interface operates based on the test input parameters, and a test report is generated and used for determining whether the target interface operates normally.
In a possible implementation manner, the test input parameters include first test input parameters, where the first test input parameters are parameters belonging to the specified parameter type and belonging to the specified parameter range, and the determining module is further configured to determine, according to the function description information of the target interface in the definition information, a theoretical response result that should be obtained if the first test input parameters are transmitted to the target interface;
the determining module is further configured to determine that the target interface operates normally when the actual response result corresponding to the first test input parameter in the test report matches the theoretical response result.
In another possible implementation manner, the determining module is further configured to obtain a median value in the specified parameter range, and determine the median value as a test input parameter.
In another possible implementation manner, the test input parameter includes a second test input parameter, the second test input parameter is a parameter that does not belong to the specified parameter type, and the determining module is further configured to determine that the target interface operates normally when an actual response result corresponding to the second test input parameter in the test report includes error prompt information.
In another possible implementation manner, the determining module, according to the specified parameter type and the specified parameter range of the target interface, includes:
an acquisition unit, configured to acquire a first parameter belonging to the specified parameter type;
the type conversion unit is used for converting the type of the first parameter to obtain a second parameter, and the second parameter does not belong to the specified parameter type;
a determining unit for determining the second parameter as a test input parameter.
In another possible implementation manner, the test input parameter includes a third test input parameter, where the third test input parameter is a parameter that does not belong to the specified parameter range, and the determining module is further configured to determine that the target interface operates normally when an actual response result corresponding to the third test input parameter in the test report includes error prompt information.
In another possible implementation manner, the specified parameter type includes a parameter type that is required to be selected, the test input parameter includes a fourth test input parameter, and the fourth test input parameter is a null parameter, and the determining module is further configured to determine that the target interface operates normally when an actual response result corresponding to the fourth test input parameter in the test report includes error prompt information.
In another possible implementation manner, the definition information includes a plurality of specified parameter types and a plurality of corresponding specified parameter ranges of the target interface, and the determining module, according to the specified parameter types and the specified parameter ranges of the target interface, includes:
the grouping unit is used for taking the designated parameter types and the designated parameter ranges which correspond to each other as a group to obtain a plurality of groups;
the determining unit is used for determining the alternative input parameters of each group according to the specified parameter type and the specified parameter range in each group;
the combination unit is used for combining the alternative input parameters belonging to different groups to obtain a plurality of alternative parameter combinations;
and the selection unit is used for selecting a test input parameter combination from the multiple candidate parameter combinations and determining each parameter in the test input parameter combination as a test input parameter.
In another possible implementation manner, the obtaining module includes:
an obtaining unit, configured to obtain a first interface file in a js format, where the first interface file includes the definition information;
the format conversion unit is used for converting the first interface file into a JavaScript object notation json format to obtain a second interface file;
the format conversion unit is further configured to convert the second interface file into an xml format of an extensible markup language to obtain a third interface file;
and the analysis unit is used for analyzing the third interface file to obtain the definition information.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
by acquiring the definition information of the target interface, determining the test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface and automatically transmitting the test input parameters to the target interface, the target interface operates based on the test input parameters and generates a test report, so that the target interface can be tested without manually analyzing the definition information by a tester, the test time is saved, and the test efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flow chart of an interface testing method provided by an embodiment of the invention;
FIG. 2 is a flow chart of an interface testing method provided by the embodiment of the invention;
FIG. 3 is a schematic structural diagram of an interface testing apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an interface testing apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Fig. 1 is a flowchart of an interface testing method provided in an embodiment of the present invention, where the embodiment of the present invention is applied to a test terminal, and as shown in fig. 1, the interface testing method includes the following steps:
101. acquiring definition information of a target interface, wherein the definition information comprises an appointed parameter type of the target interface and a corresponding appointed parameter range, the appointed parameter type is the type of an input parameter when the target interface operates normally, and the appointed parameter range is the range to which the input parameter belongs when the target interface operates normally.
102. And determining the test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface.
103. And transmitting the test input parameters to the target interface, so that the target interface operates based on the test input parameters, and generating a test report, wherein the test report is used for determining whether the target interface operates normally.
According to the method provided by the embodiment of the invention, the definition information of the target interface is obtained, the test input parameter of the target interface is determined according to the specified parameter type and the specified parameter range of the target interface, and the test input parameter is automatically transmitted to the target interface, so that the target interface runs based on the test input parameter, a test report is generated, the target interface can be tested without manually analyzing the definition information by a tester, the test time is saved, and the test efficiency is improved.
In one possible implementation, the test input parameter includes a first test input parameter, and the first test input parameter is a parameter belonging to the specified parameter type and belonging to the specified parameter range, and the method further includes:
determining a theoretical response result which is obtained if the first test input parameter is transmitted to the target interface according to the functional description information of the target interface in the definition information;
and when the actual response result corresponding to the first test input parameter in the test report is matched with the theoretical response result, determining that the target interface operates normally.
In another possible implementation manner, the determining the test input parameter of the target interface according to the specified parameter type and the specified parameter range of the target interface includes:
and acquiring a median value belonging to the specified parameter type in the specified parameter range, and determining the median value as a test input parameter.
In another possible implementation manner, the test input parameter includes a second test input parameter, and the second test input parameter is a parameter that does not belong to the specified parameter type, and the method further includes:
and when the actual response result corresponding to the second test input parameter in the test report comprises error prompt information, determining that the target interface operates normally.
In another possible implementation manner, the determining the test input parameter of the target interface according to the specified parameter type and the specified parameter range of the target interface includes:
acquiring a first parameter belonging to the specified parameter type;
converting the type of the first parameter to obtain a second parameter, wherein the second parameter does not belong to the specified parameter type;
the second parameter is determined as a test input parameter.
In another possible implementation manner, the test input parameter includes a third test input parameter, and the third test input parameter is a parameter that does not belong to the specified parameter range, and the method further includes:
and when the actual response result corresponding to the third test input parameter in the test report comprises error prompt information, determining that the target interface operates normally.
In another possible implementation manner, the specified parameter type includes a mandatory parameter type, the test input parameter includes a fourth test input parameter, and the fourth test input parameter is a null parameter, and the method further includes:
and when the actual response result corresponding to the fourth test input parameter in the test report includes the error prompt information, determining that the target interface operates normally.
In another possible implementation manner, the defining information includes a plurality of specified parameter types and a plurality of corresponding specified parameter ranges of the target interface, and the determining the test input parameter of the target interface according to the specified parameter types and the specified parameter ranges of the target interface includes:
taking the designated parameter types and the designated parameter ranges which correspond to each other as a group to obtain a plurality of groups;
determining alternative input parameters of each group according to the specified parameter type and the specified parameter range in each group;
combining the alternative input parameters belonging to different groups to obtain a plurality of alternative parameter combinations;
selecting a test input parameter combination from the multiple candidate parameter combinations, and determining each parameter in the test input parameter combination as a test input parameter.
In another possible implementation manner, the obtaining the definition information of the target interface includes:
acquiring a first interface file in a js format, wherein the first interface file comprises the definition information;
converting the first interface file into a JavaScript object notation json format to obtain a second interface file;
converting the second interface file into an extensible markup language (XML) format to obtain a third interface file;
and analyzing the third interface file to obtain the definition information.
All the above optional technical solutions may be combined arbitrarily to form the optional embodiments of the present disclosure, and are not described herein again.
Fig. 2 is a flowchart illustrating an interface testing method according to an exemplary embodiment, where an execution subject of the embodiment of the present invention is a testing terminal, and as shown in fig. 2, the interface testing method includes the following steps:
201. the test terminal acquires definition information of the target interface.
In the related art, when a target interface needs to be tested, after definition information of the target interface is acquired, a tester needs to manually analyze the definition information, know function description information and input parameter information about the target interface, and determine test input parameters after thinking and judging through a brain. This process of manually determining test input parameters takes a long time and is inefficient.
In the embodiment of the invention, the test terminal can acquire the definition information of the target interface, determine the test input parameter directly according to the specified parameter type and the specified parameter range of the target interface, and does not need a tester to analyze the definition information, thereby saving the test time and improving the test efficiency.
The test terminal may be a mobile phone, a computer, or the like, and the target interface may be a display interface, a play interface, or an interface providing other functions, which is not limited in the embodiments of the present invention.
The definition information includes the specified parameter type of the target interface and the corresponding specified parameter range, the specified parameter type is the type of the input parameter when the target interface operates normally, and the specified parameter range is the range to which the input parameter belongs when the target interface operates normally.
The specified parameter type may be a numerical value type, a character string type, an array type, a custom type, or the like, or may be other types, which is not limited herein in the embodiments of the present invention. The specified parameter range corresponds to the specified parameter type and can be 0-10, a-d, etc. The correspondence between the specified parameter type and the specified parameter range may be as shown in table 1.
TABLE 1
Specifying parameter types Specifying parameter ranges
Type of value 0-10
Character string type "the contents of Chinese characters,japan, USA "
Of the Boolean type true,false
The definition information may also include function description information of the target interface, which is used to describe the functions that the target interface can implement when the specified parameters are transmitted. For example, the target interface may be a median interface, the specified parameter type of the median interface is "numerical type", the specified parameter range is "0 to 10", the function description information is "median value of input parameters", and the definition information of the median interface is (numerical type, 0 to 10, median value of input parameters).
In practical application, definition information of any interface is contained in an interface file of the interface, the interface file is generally in a js (javascript) format, and it is inconvenient to acquire the definition information from the interface file in the format. Therefore, in the embodiment of the present invention, the format of the interface file of the target interface is converted from js format to xml (Extensible Markup Language) format, which is convenient for the test terminal to obtain the definition information from the interface file.
Specifically, the format conversion step may include the following steps one to four:
the method comprises the following steps: and acquiring a first interface file in a js format, wherein the first interface file comprises the definition information.
Step two: and converting the first interface file into a json (JavaScript Object Notation) format to obtain a second interface file.
Because it is difficult to directly convert the js-formatted interface file into the xml-formatted interface file, before converting the format of the interface file from the js format into the xml format, the test terminal may first convert the format of the interface file from the js format into the json format, and then convert the json-formatted interface file into the xml-formatted interface file.
After determining the first interface file in the js format, the test terminal can convert the first interface file into a second interface file in the json format according to the apidoc-swagger technical protocol.
Step three: and converting the second interface file into an xml format to obtain a third interface file.
Step four: and analyzing the third interface file to obtain the definition information.
The third interface file in the xml format has the characteristics of strong readability, standard format and high compatibility, so that the definition information is acquired from the third interface file in the xml format more quickly and efficiently than the definition information acquired from the first interface file in the js format. By executing the step of converting the format of the interface file, the efficiency of testing the target interface by the test terminal can be improved.
202. And the test terminal determines the test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface.
The specified parameter type and the specified parameter range are used to request the type and range of input parameters of the target interface, then if the target interface is operating normally, the target interface should return a correct response result when normal input parameters meeting the request are passed into the target interface. Therefore, normal input parameters can be transmitted to the target interface so as to judge whether the target interface can normally operate according to the returned response result.
On the other hand, if the target interface is functioning properly, the target interface should return an erroneous response result when other unsatisfactory input parameters are passed in to the target interface. Therefore, an abnormal input parameter can be transmitted to the target interface so as to judge whether the target interface can normally operate or not according to the returned response result.
Therefore, after the specified parameter type and the specified parameter range of the target interface are determined, the test terminal can determine a plurality of test input parameters which meet the requirements or do not meet the requirements for the interface, so as to more comprehensively and accurately test whether the target interface operates normally.
For the process of determining the test input parameters, the following steps one to four may be included:
step one, the test input parameter comprises a first test input parameter, and the first test input parameter is a parameter belonging to the specified parameter type and belonging to the specified parameter range: and the test terminal selects parameters belonging to the specified parameter type and the specified parameter range as test input parameters.
For example, for a median interface defining information as (numerical type, 0-10, median of input parameters), the test terminal may take 3 as the test input parameter.
Further, the test terminal may obtain a median value belonging to the specified parameter type in the specified parameter range, and determine the median value as the test input parameter.
Specifically, after the specified parameter range is obtained, the test terminal may determine a minimum boundary value and a maximum boundary value in the specified parameter range, and add the minimum boundary value and the maximum boundary value and divide by 2 to obtain a median of the specified parameter range. And then, the test terminal determines the type of the median, and when the type of the median is the specified parameter type, the median can be used as the median belonging to the specified parameter type. And when the type of the median is not the specified parameter type, performing type conversion on the median to convert the type of the median into the specified parameter type, thereby determining the median belonging to the specified parameter type.
For example, when the specified parameter range of the target interface is 0-100 and the specified parameter type is an integer type, the test terminal may determine that the specified parameter minimum value is 0 and the specified parameter maximum value is 100, determine that the specified parameter median value is 50, and take 50 as the test input parameter.
In practical application, when the test terminal transmits the test input parameters to the target interface, a "key-value" structure may be adopted to determine a data identifier for each test input parameter, where the data identifier is used as a key, the test input parameter is used as a value, and the data identifier may be a name of the test input parameter, a number assigned by the test terminal to the test input parameter, and the like.
And step two, the test terminal determines a second test input parameter according to the specified parameter type of the target interface, wherein the second test input parameter is a parameter which does not belong to the specified parameter type.
In order to test whether the target interface can return a response result including error prompt information when the input parameter with the type not meeting the requirement is transmitted to the target interface, the test terminal may obtain a first parameter belonging to the specified parameter type, convert the type of the first parameter to obtain a second parameter, and if the second parameter does not belong to the specified parameter type, the second parameter belongs to the second test input parameter, and the test terminal may determine the second parameter as the test input parameter.
In addition, the test terminal can directly randomly select any parameter from the specified parameter range to serve as a first parameter, and the type of the first parameter is converted to obtain a second parameter which does not belong to the specified parameter type. For example, the specified parameter range of the target interface is 0-100, the specified parameter type is an integer type, the test terminal may select 10, convert 10 into a floating point type to obtain 10.0, and use 10.0 as a test input parameter.
In addition, when the type of the first parameter cannot be converted, the test terminal can randomly select one parameter type different from the specified parameter type from the multiple parameter types, and randomly select a value belonging to the parameter type as a test input parameter. For example, when the specified parameter type is a numeric type, the test terminal may take "abc" belonging to a character string type as a test input parameter.
Consider the following scenario: the target interface is a registration interface which requires that the incoming normal user identifier cannot include special characters, and when the user wants to register a user identifier, an input operation is performed at the registration interface, and when the incoming user identifier includes special characters, the registration interface should return an error prompt message to prompt the user that the type of the user identifier input by the user is wrong, so that the user can input the normal user identifier with the type meeting the requirement again. Therefore, when the test terminal transmits the special characters to the registration interface, whether the registration interface operates normally can be determined according to whether the registration interface returns error prompt information.
And step three, the test terminal determines a third test input parameter according to the specified parameter range of the target interface, wherein the third test input parameter is a parameter which does not belong to the specified parameter range.
In order to test whether the target interface can return a response result including error prompt information when the input parameters of which the range is not satisfactory are transmitted to the target interface, the test terminal may determine a third test input parameter which does not belong to the specified parameter range according to the specified parameter range. For example, when the specified parameter range is 0-10, the test terminal may take 12 as the test input parameter.
In a possible implementation manner, the test terminal may determine a minimum boundary value of the specified parameter range and a maximum boundary value of the specified parameter range according to the specified parameter range, and respectively select the minimum boundary overflow value and the maximum boundary overflow value as the test input parameters. Wherein the minimum boundary overflow value refers to a value less than a minimum boundary value, and the maximum boundary overflow value refers to a value greater than the maximum boundary value. For example, the specified parameter ranges from 1 to 10, and the test terminal may use 0 and 11 as two test input parameters.
Consider the following scenario: the target interface is an age input interface which requires that the range of the normal age value should be between 0 and 130, and when the user wants to input his/her age value in the age input interface and the input value is 3000, the target interface should return an error prompt message to prompt the user that the input value range is incorrect, so that the user can input the age value belonging to the range of the normal age value again. Therefore, when the test terminal transmits a value 3000 to the age input interface, whether the age input interface operates normally can be determined according to whether the age input interface returns error prompt information.
And step four, the test terminal determines that the specified parameter types comprise the optional parameter types and determines a fourth test input parameter which is a null parameter.
The optional parameter type refers to a parameter that must be assigned.
When the specified parameter type of the target interface comprises a required parameter type, in order to test whether a response result comprising error prompt information can be returned by the target interface when the null parameter is transmitted to the target interface. After the specified parameter type is obtained by the test terminal, whether the specified parameter type comprises a necessary parameter type can be judged, and when the specified parameter type comprises the necessary parameter type, the null parameter is used as a fourth test input parameter.
In addition, if the data structure of the test input parameter adopted by the test terminal is a "key-value" structure, the test terminal can transmit the data identifier key of the test input parameter into the null parameter, so as to transmit the null parameter to the target interface.
Consider the following scenario: the target interface is a login interface for which the user password belongs to the requisite parameter type. That is, the login interface can only execute the login operation on the premise of acquiring the user password, and if the user password is not acquired, the login operation cannot be executed. Then, when the user triggers a login operation through the login interface, and wants to login based on the user identification without inputting the user password, the login interface should return, for example, "reminder: and if the user password cannot be null, the user is reminded to input the error prompt message of the user password, and the user is reminded to input the user password. Therefore, when the test terminal transmits the null parameter to the login interface, whether the login interface operates normally can be determined according to whether the login interface returns error prompt information.
Further, considering that in practical applications, the target interface may need to input a plurality of specified parameters at runtime, and determine a specified parameter type and a specified parameter range for each specified parameter in the definition information, when testing the target interface, a test input parameter combination is needed to be determined, and the test input parameter combination includes a plurality of test input parameters.
Then, when the definition information includes a plurality of specified parameter types and a plurality of specified parameter ranges corresponding to the specified parameter types of the target interface, the step 202 may further include the following steps 2021 and 2024:
2021. the test terminal takes the corresponding specified parameter types and specified parameter ranges as a group to obtain a plurality of groups.
Specifically, the test terminal may determine a plurality of input parameters of the target interface according to the definition information, determine the specified parameter type and the specified parameter range of each input parameter, respectively, and obtain a plurality of groups by using the specified parameter types and the specified parameter ranges corresponding to each other as a group, where the number of the groups is equal to the number of the plurality of input parameters.
2022. And the test terminal determines the alternative input parameters of each group according to the specified parameter type and the specified parameter range in each group.
Specifically, when determining the candidate input parameters for any one of the groups, the test terminal may determine four test input parameters, namely a first test input parameter, a second test input parameter, a third test input parameter, and a fourth test input parameter, for the group according to the type of the specified parameter and the range of the specified parameter in the group by using the above steps one to four, so as to obtain a plurality of candidate input parameters.
The plurality of candidate input parameters may be the same test input parameter, for example, the plurality of candidate input parameters may be all the first test input parameters, or may not be the same test input parameter, for example, the plurality of candidate input parameters may include the first test input parameter and the second test input parameter, which is not limited in this embodiment of the present invention.
2023. And the test terminal combines the alternative input parameters belonging to different groups to obtain various alternative parameter combinations.
After the test terminal determines the candidate input parameters for the groups respectively, one candidate input parameter can be randomly selected from each group, so that a plurality of candidate input parameters selected from different groups are combined to obtain a first candidate parameter combination. Thereafter, one candidate input parameter may be selected randomly from each group, and the candidate input parameters may be combined again to obtain a second candidate parameter combination, and so on to obtain a plurality of candidate parameter combinations.
2024. The test terminal selects a test input parameter combination from the multiple candidate parameter combinations, and determines each parameter in the test input parameter combination as a test input parameter.
After the test terminal obtains the multiple candidate parameter combinations, the multiple candidate parameter combinations can be analyzed according to a pair test algorithm, so that test input parameters are selected from the multiple candidate parameter combinations. In addition, the test terminal may also pass the plurality of alternative combinations into the test cluster tool, which may return a test input combination. The test combination tool may be a pict tool, an allpair tool, and the like, which is not limited in the embodiment of the present invention.
For example, the target interface may include three input parameters a, b, c, and the specified parameter type and specified parameter range for each input parameter may be as shown in table 2:
TABLE 2
Inputting parameters a b c
Specifying parameter types Integer type, mandatory parameter type Of the Boolean type Type of floating point number
Specifying parameter ranges 1-10 true/false 2.0-4.0
The test terminal can take the integer type and 1-10 corresponding to the input parameter a as a first grouping, the Boolean type and true/false corresponding to the input parameter b as a second grouping, and the floating point type and 2.0-4.0 corresponding to the input parameter c as a third grouping.
Then the test terminal may determine the alternative input parameter {5, "china", 6, null } for the first packet, the alternative input parameter { true, false, 30, null } for the second packet, and the alternative input parameter {2.0, 10, a, "abc" } for the third packet. Selecting 5 from the candidate input parameters of the first group, selecting true from the second group, selecting 2.0 from the third group, (5, true, 2.0) as the first candidate parameter combination, then selecting 6 from the candidate input parameters of the first group, selecting true from the second group, selecting 2.0 from the third group, and selecting (6, true, 2.0) as the second candidate parameter combination.
Because the alternative input parameters of the second group and the third group selected from the first alternative parameter combination and the second alternative parameter combination are the same, only the alternative input parameters of the first group selected are different, and the alternative input parameters 5 and 6 of the first group both belong to the first test input parameter and are normal input parameters, the test purpose can be achieved by selecting any one of the two first test input parameters as the test input parameter, so that the two alternative parameter combinations have redundant parameter combinations, and if the redundant parameter combinations are tested, the test time is wasted. Therefore, any one alternative parameter combination can be selected from the two alternative parameter combinations for testing, so that the condition of testing redundant parameter combinations is avoided, the testing time is saved, and the testing workload is reduced.
203. The test terminal transmits the test input parameters to the target interface.
For example, when the target interface is operated at the server, the test terminal and the target interface may perform data transmission based on HTTP (HyperText Transfer Protocol), that is, the test terminal may send an HTTP request to the target interface, where the HTTP request carries the test input parameters, so as to transmit the test input parameters to the target interface. The HTTP request may be a get request, a post request, and the like, which is not limited in the embodiment of the present invention.
204. The target interface operates based on the test input parameters and generates a test report.
The test report includes an actual response result of the target interface after the test input parameters are transmitted, and the test report is used for determining whether the target interface operates normally.
In addition, when the test terminal transmits different test input parameters to the target interface, the target interface can generate a test report corresponding to the test input parameters.
In a first possible implementation manner, when the test input parameter includes a first test input parameter, the test terminal determines a theoretical response result that should be obtained if the first test input parameter is transmitted to the target interface according to the function description information of the target interface in the definition information, determines that the target interface operates normally when an actual response result corresponding to the first test input parameter in the test report matches the theoretical response result, and determines that the target interface operates incorrectly when an actual response result corresponding to the second test input parameter in the test report does not match the theoretical response result.
Based on the example of table 1, the specified parameter type of the target interface is a numerical value type, the specified parameter range is 0 to 10, the function description information is "find the median of the input parameter", when 8 is transmitted to the target interface, the theoretical response result is 4, but when the target interface runs based on 8, the actual response result corresponding to 8 in the test report is 2, and at this time, it is determined that the target interface runs incorrectly.
In a second possible implementation manner, when the test input parameter includes a second test input parameter, the test terminal determines whether an actual response result corresponding to the second test input parameter in the test report includes error prompt information, determines that the target interface operates normally when the actual response result corresponding to the second test input parameter in the test report includes the error prompt information, and determines that the target interface operates incorrectly when the actual response result corresponding to the second test input parameter in the test report does not include the error prompt information.
Based on the example of table 1, the specified parameter type of the target interface is a numeric type, after "abc" belonging to a character string type is transmitted to the target interface, after the target interface operates based on "abc", an actual response result of the test report corresponding to "abc" includes error prompt information of "input parameter type is incorrect", and at this time, it may be determined that the target interface operates normally.
In a third possible implementation manner, when the test input parameter includes a third test input parameter, the test terminal determines whether an actual response result corresponding to the second test input parameter in the test report includes error prompt information, determines that the target interface operates normally when the actual response result corresponding to the third test input parameter in the test report includes the error prompt information, and determines that the target interface operates incorrectly when the actual response result corresponding to the third test input parameter in the test report does not include the error prompt information.
Based on the example in table 1, the specified parameter range of the target interface is 0 to 10, after 11 is transmitted to the target interface, and after the target interface operates based on 11, the actual response result of the test report corresponding to 11 includes the error prompt information of "input parameter range is incorrect", and at this time, it may be determined that the target interface operates normally.
In a fourth possible implementation manner, when the test input parameter includes a fourth test input parameter, the test terminal determines whether an actual response result corresponding to the second test input parameter in the test report includes error prompt information, determines that the target interface operates normally when the actual response result corresponding to the fourth test input parameter in the test report includes the error prompt information, and determines that the target interface operates incorrectly when the actual response result corresponding to the fourth test input parameter in the test report does not include the error prompt information.
The input parameter a of the target interface belongs to a necessary parameter type, the test terminal takes an empty parameter as a test input parameter a, and transmits the empty parameter to the target interface, so that after the target interface operates based on the empty parameter, a response result corresponding to the empty parameter in the test report includes error prompt information that the input parameter a cannot be empty, and at this time, the target interface can be determined to operate normally.
According to the method provided by the embodiment of the invention, the definition information of the target interface is obtained, the test input parameter of the target interface is determined according to the specified parameter type and the specified parameter range of the target interface, and the test input parameter is automatically transmitted to the target interface, so that the target interface runs based on the test input parameter, a test report is generated, the target interface can be tested without manually analyzing the definition information by a tester, the test time is saved, and the test efficiency is improved.
Furthermore, the format of the first interface file is converted from the js format to the xml format, so that the definition information can be conveniently acquired from the first interface file, and the testing efficiency is improved.
Furthermore, a test input parameter combination is selected from multiple candidate parameter combinations through an all-pairs algorithm, so that the condition of testing redundant parameter combinations is avoided, the test time is saved, and the test workload is reduced.
Fig. 3 is a schematic structural diagram of a subelement testing apparatus according to an embodiment of the present invention, as shown in fig. 3, the apparatus includes an obtaining module 301, a determining module 302, and a parameter importing module 303.
An obtaining module 301, configured to obtain definition information of a target interface, where the definition information includes a specified parameter type of the target interface and a corresponding specified parameter range, where the specified parameter type is a type of an input parameter when the target interface operates normally, and the specified parameter range is a range to which the input parameter belongs when the target interface operates normally;
a determining module 302, configured to determine a test input parameter of the target interface according to the specified parameter type and the specified parameter range of the target interface;
a parameter importing module 303, configured to import the test input parameter to the target interface, so that the target interface operates based on the test input parameter, and generate a test report, where the test report is used to determine whether the target interface operates normally.
According to the device provided by the embodiment of the invention, the definition information of the target interface is obtained, the test input parameter of the target interface is determined according to the specified parameter type and the specified parameter range of the target interface, and the test input parameter is automatically transmitted to the target interface, so that the target interface runs based on the test input parameter, a test report is generated, the target interface can be tested without manually analyzing the definition information by a tester, the test time is saved, and the test efficiency is improved.
In a possible implementation manner, the test input parameters include a first test input parameter, where the first test input parameter is a parameter that belongs to the specified parameter type and belongs to the specified parameter range, and the determining module 302 is further configured to determine, according to the function description information of the target interface in the definition information, a theoretical response result that should be obtained if the first test input parameter is transmitted to the target interface;
the determining module 302 is further configured to determine that the target interface operates normally when the actual response result corresponding to the first test input parameter in the test report matches the theoretical response result.
In another possible implementation manner, the determining module 302 is further configured to obtain a median value of the specified parameter range, and determine the median value as a test input parameter.
In another possible implementation manner, the test input parameter includes a second test input parameter, where the second test input parameter is a parameter that does not belong to the specified parameter type, and the determining module 302 is further configured to determine that the target interface operates normally when an actual response result corresponding to the second test input parameter in the test report includes error prompt information.
In another possible implementation manner, the determining module 302, according to the specified parameter type and the specified parameter range of the target interface, includes:
an acquisition unit, configured to acquire a first parameter belonging to the specified parameter type;
the type conversion unit is used for converting the type of the first parameter to obtain a second parameter, and the second parameter does not belong to the specified parameter type;
a determining unit for determining the second parameter as a test input parameter.
In another possible implementation manner, the test input parameter includes a third test input parameter, where the third test input parameter is a parameter that does not belong to the specified parameter range, and the determining module 302 is further configured to determine that the target interface operates normally when an actual response result corresponding to the third test input parameter in the test report includes error prompt information.
In another possible implementation manner, the specified parameter type includes a parameter type that is required to be selected, the test input parameter includes a fourth test input parameter, and the fourth test input parameter is a null parameter, and the determining module 302 is further configured to determine that the target interface operates normally when an actual response result corresponding to the fourth test input parameter in the test report includes an error prompt message.
In another possible implementation manner, the definition information includes a plurality of specified parameter types and a plurality of corresponding specified parameter ranges of the target interface, and the determining module 302 includes:
the grouping unit is used for taking the designated parameter types and the designated parameter ranges which correspond to each other as a group to obtain a plurality of groups;
the determining unit is used for determining the alternative input parameters of each group according to the specified parameter type and the specified parameter range in each group;
the combination unit is used for combining the alternative input parameters belonging to different groups to obtain a plurality of alternative parameter combinations;
and the selection unit is used for selecting a test input parameter combination from the multiple candidate parameter combinations and determining each parameter in the test input parameter combination as a test input parameter.
In another possible implementation manner, the obtaining module 301 includes:
an obtaining unit, configured to obtain a first interface file in a js format, where the first interface file includes the definition information;
the format conversion unit is used for converting the first interface file into a JavaScript object notation json format to obtain a second interface file;
the format conversion unit is further configured to convert the second interface file into an xml format of an extensible markup language to obtain a third interface file;
and the analysis unit is used for analyzing the third interface file to obtain the definition information.
It should be noted that: the interface testing apparatus provided in the above embodiment is only illustrated by dividing the functional modules when testing the interface, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the testing terminal is divided into different functional modules to complete all or part of the functions described above. In addition, the interface testing apparatus and the interface testing method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
The present embodiment provides a terminal, which can be used to execute the interface testing method provided in the above embodiments. Referring to fig. 4, the terminal 400 includes:
the terminal 400 may include RF (Radio Frequency) circuitry 110, memory 120 including one or more computer-readable storage media, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, a WiFi (Wireless Fidelity) module 170, a processor 180 including one or more processing cores, and a power supply 40. Those skilled in the art will appreciate that the terminal configuration shown in fig. 4 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the RF circuit 110 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, receives downlink information from a base station and then sends the received downlink information to the one or more processors 180 for processing; in addition, data relating to uplink is transmitted to the base station. In general, the RF circuitry 110 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the RF circuitry 110 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), and the like.
The memory 120 may be used to store software programs and modules, and the processor 180 executes various functional applications and data processing by operating the software programs and modules stored in the memory 120. The memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the terminal 400, and the like. Further, the memory 120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 120 may further include a memory controller to provide the processor 180 and the input unit 130 with access to the memory 120.
The input unit 130 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 130 may include a touch-sensitive surface 131 as well as other input devices 132. The touch-sensitive surface 131, also referred to as a touch display screen or a touch pad, may collect touch operations by a user on or near the touch-sensitive surface 131 (e.g., operations by a user on or near the touch-sensitive surface 131 using a finger, a stylus, or any other suitable object or attachment), and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface 131 may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 180, and can receive and execute commands sent by the processor 180. Additionally, the touch-sensitive surface 131 may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch-sensitive surface 131, the input unit 130 may also include other input devices 132. In particular, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 140 may be used to display information input by or provided to a user and various graphical user interfaces of the terminal 400, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 140 may include a Display panel 141, and optionally, the Display panel 141 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 131 may cover the display panel 141, and when a touch operation is detected on or near the touch-sensitive surface 131, the touch operation is transmitted to the processor 180 to determine the type of the touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of the touch event. Although in FIG. 4, touch-sensitive surface 131 and display panel 141 are shown as two separate components to implement input and output functions, in some embodiments, touch-sensitive surface 131 may be integrated with display panel 141 to implement input and output functions.
The terminal 400 can also include at least one sensor 150, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel 141 according to the brightness of ambient light, and a proximity sensor that may turn off the display panel 141 and/or a backlight when the terminal 400 is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured in the terminal 400, detailed descriptions thereof are omitted.
Audio circuitry 160, speaker 161, and microphone 162 may provide an audio interface between a user and terminal 400. The audio circuit 160 may transmit the electrical signal converted from the received audio data to the speaker 161, and convert the electrical signal into a sound signal for output by the speaker 161; on the other hand, the microphone 162 converts the collected sound signal into an electric signal, converts the electric signal into audio data after being received by the audio circuit 160, and then outputs the audio data to the processor 180 for processing, and then to the RF circuit 110 to be transmitted to, for example, another terminal, or outputs the audio data to the memory 120 for further processing. The audio circuit 160 may also include an earbud jack to provide communication of a peripheral headset with the terminal 400.
WiFi belongs to a short-distance wireless transmission technology, and the terminal 400 can help a user send and receive e-mails, browse web pages, access streaming media, and the like through the WiFi module 170, and provides wireless broadband internet access for the user. Although fig. 4 shows the WiFi module 170, it is understood that it does not belong to the essential constitution of the terminal 400, and may be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 180 is a control center of the terminal 400, connects various parts of the entire mobile phone using various interfaces and lines, and performs various functions of the terminal 400 and processes data by operating or executing software programs and/or modules stored in the memory 120 and calling data stored in the memory 120, thereby performing overall monitoring of the mobile phone. Optionally, processor 180 may include one or more processing cores; preferably, the processor 180 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 180.
The terminal 400 also includes a power source 40 (e.g., a battery) for powering the various components, which may preferably be logically connected to the processor 180 via a power management system to manage charging, discharging, and power consumption management functions via the power management system. The power supply 40 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
Although not shown, the terminal 400 may further include a camera, a bluetooth module, etc., which will not be described herein. In this embodiment, the display unit of the terminal is a touch screen display, and the terminal further includes a memory and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors. The one or more programs include instructions for implementing the operations performed by the test terminal in the embodiments described above.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (14)

1. An interface testing method, the method comprising:
acquiring a first interface file in a js format, wherein the first interface file comprises definition information of a target interface;
converting the first interface file into a JavaScript object representation json format according to an apidoc-swagger technical protocol to obtain a second interface file;
converting the second interface file into an extensible markup language (XML) format to obtain a third interface file;
analyzing the third interface file to obtain definition information of the target interface, wherein the definition information comprises a specified parameter type of the target interface and a corresponding specified parameter range, the specified parameter type refers to the type of input parameters when the target interface operates normally, and the specified parameter range refers to the range to which the input parameters belong when the target interface operates normally;
determining test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface;
the test input parameters are transmitted to the target interface, so that the target interface operates based on the test input parameters, and a test report corresponding to the test input parameters is generated, wherein the test report comprises an actual response result of the target interface after the test input parameters are transmitted, the test report is used for determining whether the target interface operates normally, and different test input parameters correspond to different test reports;
when the definition information includes a plurality of specified parameter types and corresponding specified parameter ranges of the target interface, determining the test input parameters of the target interface according to the specified parameter types and the specified parameter ranges of the target interface includes:
taking the designated parameter types and the designated parameter ranges which correspond to each other as a group to obtain a plurality of groups;
determining alternative input parameters of each group according to the specified parameter type and the specified parameter range in each group;
combining the alternative input parameters belonging to different groups to obtain a plurality of alternative parameter combinations;
when the multiple candidate parameter combinations have the redundancy parameter combination, any one of the candidate parameter combinations is selected from the redundancy parameter combinations to serve as a test input parameter combination, and each parameter in the test input parameter combination is determined to be the test input parameter.
2. The method of claim 1, wherein the test input parameters include a first test input parameter that is a parameter belonging to the specified parameter type and belonging to the specified parameter range, the method further comprising:
determining a theoretical response result which is obtained if the first test input parameter is transmitted to the target interface according to the function description information of the target interface in the definition information;
and when the actual response result corresponding to the first test input parameter in the test report is matched with the theoretical response result, determining that the target interface operates normally.
3. The method of claim 2, wherein determining the test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface comprises:
and acquiring a median value belonging to the specified parameter type in the specified parameter range, and determining the median value as a test input parameter.
4. The method of claim 1, wherein the test input parameters include a second test input parameter, the second test input parameter being a parameter that does not belong to the specified parameter type, the method further comprising:
and when the actual response result corresponding to the second test input parameter in the test report comprises error prompt information, determining that the target interface operates normally.
5. The method of claim 4, wherein determining the test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface comprises:
acquiring a first parameter belonging to the specified parameter type;
converting the type of the first parameter to obtain a second parameter, wherein the second parameter does not belong to the specified parameter type;
determining the second parameter as a test input parameter.
6. The method of claim 1, wherein the test input parameters include a third test input parameter, the third test input parameter being a parameter that does not fall within the specified parameter range, the method further comprising:
and when the actual response result corresponding to the third test input parameter in the test report comprises error prompt information, determining that the target interface operates normally.
7. The method of claim 1, wherein the specified parameter types include mandatory parameter types, wherein the test input parameters include a fourth test input parameter, and wherein the fourth test input parameter is a null parameter, wherein the method further comprises:
and when the actual response result corresponding to the fourth test input parameter in the test report comprises error prompt information, determining that the target interface operates normally.
8. An interface testing apparatus, the apparatus comprising:
the device comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first interface file in a js format, and the first interface file comprises definition information of a target interface; converting the first interface file into a JavaScript object representation json format according to an apidoc-swagger technical protocol to obtain a second interface file; converting the second interface file into an extensible markup language (XML) format to obtain a third interface file; analyzing the third interface file to obtain definition information of the target interface, wherein the definition information comprises a specified parameter type of the target interface and a corresponding specified parameter range, the specified parameter type refers to the type of input parameters when the target interface operates normally, and the specified parameter range refers to the range to which the input parameters belong when the target interface operates normally;
the determining module is used for determining the test input parameters of the target interface according to the specified parameter type and the specified parameter range of the target interface;
a parameter input module, configured to input the test input parameter to the target interface, so that the target interface operates based on the test input parameter, and generates a test report corresponding to the test input parameter, where the test report includes an actual response result of the target interface after the test input parameter is input, and the test report is used to determine whether the target interface operates normally, and different test input parameters correspond to different test reports;
when the definition information includes a plurality of specified parameter types and corresponding specified parameter ranges of the target interface, the determining module is further configured to obtain a plurality of groups by using the specified parameter types and the specified parameter ranges corresponding to each other as a group according to the specified parameter types and the specified parameter ranges of the target interface; determining alternative input parameters of each group according to the specified parameter type and the specified parameter range in each group; combining the alternative input parameters belonging to different groups to obtain a plurality of alternative parameter combinations; when the multiple candidate parameter combinations have the redundancy parameter combination, any one of the candidate parameter combinations is selected from the redundancy parameter combinations to serve as a test input parameter combination, and each parameter in the test input parameter combination is determined to be the test input parameter.
9. The apparatus according to claim 8, wherein the test input parameters include a first test input parameter, the first test input parameter is a parameter belonging to the specified parameter type and belonging to the specified parameter range, and the determining module is further configured to determine, according to the function description information of the target interface in the definition information, a theoretical response result that should be obtained if the first test input parameter is transmitted to the target interface;
the determining module is further configured to determine that the target interface operates normally when the actual response result corresponding to the first test input parameter in the test report matches the theoretical response result.
10. The apparatus of claim 9, wherein the determining module is further configured to obtain a median value of the specified parameter range belonging to the specified parameter type, and determine the median value as the test input parameter.
11. The apparatus according to claim 8, wherein the test input parameters include second test input parameters, the second test input parameters are parameters that do not belong to the specified parameter type, and the determining module is further configured to determine that the target interface operates normally when an actual response result corresponding to the second test input parameters in the test report includes error prompt information.
12. The apparatus of claim 11, wherein the determining module, according to the specified parameter type and the specified parameter range of the target interface, comprises:
an acquisition unit, configured to acquire a first parameter belonging to the specified parameter type;
the type conversion unit is used for converting the type of the first parameter to obtain a second parameter, and the second parameter does not belong to the specified parameter type;
a determining unit for determining the second parameter as a test input parameter.
13. The apparatus according to claim 8, wherein the test input parameters include a third test input parameter, the third test input parameter is a parameter that does not belong to the specified parameter range, and the determining module is further configured to determine that the target interface operates normally when an actual response result corresponding to the third test input parameter in the test report includes an error prompt message.
14. The apparatus according to claim 8, wherein the specified parameter types include a mandatory parameter type, the test input parameter includes a fourth test input parameter, the fourth test input parameter is a null parameter, and the determining module is further configured to determine that the target interface operates normally when an actual response result corresponding to the fourth test input parameter in the test report includes an error prompt message.
CN201611092061.0A 2016-12-01 2016-12-01 Interface test method and device Active CN106708676B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611092061.0A CN106708676B (en) 2016-12-01 2016-12-01 Interface test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611092061.0A CN106708676B (en) 2016-12-01 2016-12-01 Interface test method and device

Publications (2)

Publication Number Publication Date
CN106708676A CN106708676A (en) 2017-05-24
CN106708676B true CN106708676B (en) 2020-12-04

Family

ID=58935433

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611092061.0A Active CN106708676B (en) 2016-12-01 2016-12-01 Interface test method and device

Country Status (1)

Country Link
CN (1) CN106708676B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109975624B (en) * 2017-12-27 2022-01-25 无锡华润华晶微电子有限公司 Test system and test method
CN108415832B (en) * 2018-02-07 2021-03-02 平安科技(深圳)有限公司 Interface automation test method, device, equipment and storage medium
CN109344050B (en) * 2018-08-20 2023-07-21 中国平安人寿保险股份有限公司 Interface parameter analysis method and device based on structure tree
CN109522210A (en) * 2018-09-29 2019-03-26 中国平安人寿保险股份有限公司 Interface testing parameters analysis method, device, electronic device and storage medium
CN110046088A (en) * 2019-02-19 2019-07-23 阿里巴巴集团控股有限公司 A kind of interface test method, device and equipment
US11196744B2 (en) 2019-11-07 2021-12-07 Vmware, Inc. Access to physical resources based through identity provider
CN110865943A (en) * 2019-11-26 2020-03-06 太平金融科技服务(上海)有限公司 Interface testing method and device, computer equipment and storage medium
US11444950B2 (en) * 2020-04-24 2022-09-13 Vmware, Inc. Automated verification of authenticated users accessing a physical resource
CN111459773B (en) * 2020-04-30 2023-09-05 众能联合数字技术有限公司 System and method for monitoring and alarming swagger service
CN111796978B (en) * 2020-06-29 2021-06-29 苏州好玩友网络科技有限公司 Interface detection method, device, system, equipment and storage medium
CN112416691B (en) * 2020-12-09 2023-07-21 海光信息技术股份有限公司 Performance test method and system based on benchmark test tool

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572463A (en) * 2014-12-31 2015-04-29 广州酷狗计算机科技有限公司 Method and device for testing interface information

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7644368B2 (en) * 2005-06-29 2010-01-05 Sap Ag System and method for regression tests of user interfaces

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572463A (en) * 2014-12-31 2015-04-29 广州酷狗计算机科技有限公司 Method and device for testing interface information

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于Junit的接口测试框架的设计与实现;江屿;《中国优秀硕士学位论文全文数据库 信息科技辑》;20160515;I138-732 *

Also Published As

Publication number Publication date
CN106708676A (en) 2017-05-24

Similar Documents

Publication Publication Date Title
CN106708676B (en) Interface test method and device
CN107094294B (en) Network connection method and device
CN108959000B (en) Server pressure testing method, system and terminal
CN104852885B (en) Method, device and system for verifying verification code
CN106502906B (en) A kind of method and apparatus of test application program
CN108268366B (en) Test case execution method and device
CN106649126B (en) Method and device for testing application program
CN107204964B (en) Authority management method, device and system
CN108039963B (en) Container configuration method and device and storage medium
CN104516812A (en) Method and device for testing software
CN105302452B (en) Operation method and device based on gesture interaction
CN111078556B (en) Application testing method and device
CN108287706B (en) Data processing method and device
WO2018161540A1 (en) Fingerprint registration method and related product
CN106776301B (en) Subelement testing method and device
CN112749074B (en) Test case recommending method and device
CN104809055B (en) Application program testing method and device based on cloud platform
CN107122036B (en) Method and device for adjusting frequency of central processing unit
CN112000566B (en) Method and device for generating test cases
CN106302101B (en) Message reminding method, terminal and server
CN110413639A (en) Data check method and device, electronic equipment and computer readable storage medium
CN105095161B (en) Method and device for displaying rich text information
CN107967203B (en) Function judgment method and device based on executable file
CN108234275B (en) Method and device for releasing communication information
CN108269223B (en) Webpage graph drawing method and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 510660 Guangzhou City, Guangzhou, Guangdong, Whampoa Avenue, No. 315, self - made 1-17

Applicant after: Guangzhou KuGou Networks Co., Ltd.

Address before: 510000 B1, building, No. 16, rhyme Road, Guangzhou, Guangdong, China 13F

Applicant before: Guangzhou KuGou Networks Co., Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant