CN117724983A - Interface testing method and device, storage medium and electronic equipment - Google Patents
Interface testing method and device, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN117724983A CN117724983A CN202410065373.0A CN202410065373A CN117724983A CN 117724983 A CN117724983 A CN 117724983A CN 202410065373 A CN202410065373 A CN 202410065373A CN 117724983 A CN117724983 A CN 117724983A
- Authority
- CN
- China
- Prior art keywords
- interface
- test
- target
- information
- template
- 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.)
- Pending
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 562
- 238000013515 script Methods 0.000 claims abstract description 158
- 238000000034 method Methods 0.000 claims abstract description 55
- 230000007547 defect Effects 0.000 claims description 27
- 238000012545 processing Methods 0.000 claims description 26
- 238000004590 computer program Methods 0.000 claims description 14
- 238000010276 construction Methods 0.000 claims description 12
- 238000012512 characterization method Methods 0.000 claims description 8
- 238000005516 engineering process Methods 0.000 abstract description 7
- 238000010586 diagram Methods 0.000 description 11
- 230000006870 function Effects 0.000 description 8
- 230000008569 process Effects 0.000 description 7
- 230000000694 effects Effects 0.000 description 6
- 230000005540 biological transmission Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000010998 test method Methods 0.000 description 3
- 239000008186 active pharmaceutical agent Substances 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 238000013475 authorization Methods 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000011835 investigation Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The application discloses an interface testing method, an interface testing device, a storage medium and electronic equipment, wherein the method is applied to the field of application program testing and comprises the following steps: under the condition of receiving an interface test instruction, acquiring target interface information of an interface to be tested from the interface test instruction; characterizing parameter information of a target application name containing interface by adopting a preset data structure to obtain a target dictionary; constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set; adding interface test parameters into a test template of the test template set to obtain a test script set; and testing the interface to be tested according to the test scripts in the test script set to obtain a test result. Through the application, the problem that the testing efficiency is low due to the fact that the parameters are manually and repeatedly assembled when a tester tests the application interface in the related technology is solved.
Description
Technical Field
The present invention relates to the field of application testing, and in particular, to an interface testing method, an apparatus, a storage medium, and an electronic device.
Background
Interfaces are typically employed in applications to communicate and interact between different software modules or systems. The interface defines the interaction mode between the modules, including data transmission format, communication protocol, function call specification, etc. Through the interfaces, operations such as data exchange, function call and the like can be realized among different modules, so that integration and cooperation of the system are realized. Common application interfaces include API (Application Programming Interface), web services interfaces, and the like.
In order to correctly communicate and cooperate with each other between the different parts of the system, whether the input and output of the interface meet the expectations can be verified, so that the potential problems can be found and solved, and the stability and reliability of the system are improved. Interface testing may also help developers and testers better understand the architecture and functionality of the system, thereby better performing development and testing tasks.
In the prior art, when an interface test is executed, an interface tester needs to carry out complicated parameter assembly according to interface parameter entering information of an API document center, and because the tester needs to repeatedly execute complicated parameter assembly operation during the test, the possibility of errors of the tester is increased, so that the tester needs to carry out repeated investigation and adjustment before the interface is communicated, which wastes time and labor, and reduces the working efficiency of the tester.
Aiming at the problem of lower testing efficiency caused by manually and repeatedly assembling parameters when a tester tests an application interface in the related technology, no effective solution is proposed at present.
Disclosure of Invention
The main purpose of the application is to provide an interface testing method, device, storage medium and electronic equipment, so as to solve the problem of lower testing efficiency caused by manually and repeatedly assembling parameters when a tester tests an application interface in the related technology.
To achieve the above object, according to one aspect of the present application, there is provided an interface testing method, including: under the condition that an interface test instruction is received, acquiring target interface information of an interface to be tested from the interface test instruction, wherein the target interface information at least comprises the following information: a target application name of the application to which the interface to be tested belongs; characterizing the parameter information of the interface contained in the target application name by adopting a preset data structure to obtain a target dictionary; constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set; adding interface test parameters into a test template of the test template set to obtain a test script set; and testing the interface to be tested according to the test scripts in the test script set to obtain a test result.
Further, obtaining the target interface information of the interface to be tested from the interface test instruction includes: obtaining at least one target application name in the interface test instruction, and obtaining interface test version information of the target application name, wherein the interface test version information at least comprises one of the following information: testing version information and regression version information; characterizing at least one target application name and an interface test version of the target application name by adopting a list structure to obtain a target list; and determining the target interface information according to the target list.
Further, characterizing the parameter information of the target application name containing interface by adopting a preset data structure, and obtaining a target dictionary includes: acquiring service information of at least one service contained in the target application name from a preset document to obtain a service information set; acquiring parameter information of at least one interface contained in each service in the service information set from the preset document to obtain an interface information set; and constructing a key value pair according to the target application name, the service information set and the interface information set, and determining the target dictionary according to the key value pair.
Further, constructing a test template of each interface in the target application name according to the target dictionary, and obtaining a test template set includes: determining each interface information contained in the target dictionary by traversing key value pairs in the target dictionary; constructing json objects corresponding to each interface according to the information of each interface to obtain a json object set; constructing an interface test template corresponding to each json object in the json object set; creating a corresponding folder for each json object, and storing the interface test template corresponding to each json object into the folder corresponding to each json object to obtain the test template set.
Further, adding interface test parameters in the test templates of the test template set to obtain a test script set includes: receiving interface test parameters input by a target object aiming at each test template in the test template set to obtain target parameters; adding the target parameters into each test template through target processing operation to obtain a test script corresponding to each test template, wherein the target processing operation at least comprises one of the following operations: replacing and splicing; and obtaining the test script set according to the test script corresponding to each test template.
Further, before the interface to be tested is tested according to the test scripts in the test script set to obtain a test result, the method further includes: generating a random code of each test script in the test script set through a preset method; adding the random code to the test scripts and updating each test script in the test script set.
Further, after testing the interface to be tested according to the test scripts in the test script set to obtain a test result, the method further includes: determining an interface with a code defect according to the test result to obtain a defect report; and sending the defect report to a target object.
To achieve the above object, according to another aspect of the present application, there is provided an interface test apparatus including: the device comprises an acquisition unit, a test unit and a test unit, wherein the acquisition unit is used for acquiring target interface information of an interface to be tested from an interface test instruction under the condition of receiving the interface test instruction, and the target interface information at least comprises the following information: a target application name of the application to which the interface to be tested belongs; the characterization unit is used for characterizing the parameter information of the interface contained in the target application name by adopting a preset data structure to obtain a target dictionary; the construction unit is used for constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set; the first adding unit is used for adding interface test parameters into the test templates of the test template set to obtain a test script set; and the test unit is used for testing the interface to be tested according to the test scripts in the test script set to obtain a test result.
Further, the acquisition unit includes: the first obtaining subunit is configured to obtain at least one of the target application names in the interface test instruction, and obtain interface test version information of the target application names, where the interface test version information includes at least one of the following information: testing version information and regression version information; the characterization subunit is used for characterizing at least one target application name and an interface test version of the target application name by adopting a list structure to obtain a target list; and the first determining subunit is used for determining the target interface information according to the target list.
Further, the characterization unit includes: the second acquisition subunit is used for acquiring service information of at least one service contained in the target application name in a preset document to obtain a service information set; a third obtaining subunit, configured to obtain parameter information of at least one interface included in each service in the service information set from the preset document, so as to obtain an interface information set; and the first construction subunit is used for constructing a key value pair according to the target application name, the service information set and the interface information set, and determining the target dictionary according to the key value pair.
Further, the construction unit includes: a second determining subunit, configured to traverse key value pairs in the target dictionary to determine each interface information included in the target dictionary; the second construction subunit is used for constructing json objects corresponding to each interface according to the information of each interface to obtain a json object set; the third construction subunit is used for constructing an interface test template corresponding to each json object in the json object set; the creating subunit is used for creating a corresponding folder for each json object, and storing the interface test template corresponding to each json object into the folder corresponding to each json object to obtain the test template set.
Further, the first adding unit includes: the receiving subunit is used for receiving interface test parameters input by a target object aiming at each test template in the test template set to obtain target parameters; the adding subunit is configured to add the target parameter to each test template through a target processing operation, and obtain a test script corresponding to each test template, where the target processing operation at least includes one of the following operations: replacing and splicing; and the third determining subunit is used for obtaining the test script set according to the test script corresponding to each test template.
Further, the apparatus further comprises: the generating unit is used for generating random codes of the test scripts by a preset method for each test script in the test script set before testing the interface to be tested according to the test scripts in the test script set to obtain a test result; and the second adding unit is used for adding the random code into the test scripts and updating each test script in the test script set.
Further, the apparatus further comprises: the determining unit is used for determining an interface with a code defect according to the test result after the interface to be tested is tested according to the test scripts in the test script set to obtain a test result, so as to obtain a defect report; and the sending unit is used for sending the defect report to a target object.
To achieve the above object, according to one aspect of the present application, there is provided a computer readable storage medium, including a stored computer program, wherein the computer program when run controls a device in which the computer readable storage medium is located to perform any one of the above interface test methods.
To achieve the above object, according to one aspect of the present application, there is provided an electronic device including one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement any one of the interface testing methods described above.
Through the application, the following steps are adopted: under the condition that an interface test instruction is received, acquiring target interface information of an interface to be tested from the interface test instruction, wherein the target interface information at least comprises the following information: a target application name of the application to which the interface to be tested belongs; characterizing the parameter information of the interface contained in the target application name by adopting a preset data structure to obtain a target dictionary; constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set; adding interface test parameters into a test template of the test template set to obtain a test script set; and testing the interface to be tested according to the test scripts in the test script set to obtain a test result, thereby solving the problem of lower test efficiency caused by manually and repeatedly assembling parameters when a tester tests the application interface in the related technology. The parameter information of the interface to be tested is represented through the preset data structure, the target dictionary is obtained, the nesting relation between the application and the interface can be clearly represented by the dictionary structure, so that the test template and the test script corresponding to each interface to be tested are rapidly generated according to the target dictionary, the problem that test parameters of the interface are repeatedly spliced by a tester, the problem that the test efficiency is low and the test accuracy is low is solved, the time of the tester is saved, and the effect of improving the test efficiency of the tester is achieved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, illustrate and explain the application and are not to be construed as limiting the application. In the drawings:
FIG. 1 is a flow chart of an interface testing method according to a first embodiment of the present application;
FIG. 2 is a schematic diagram I of an alternative interface testing method provided in accordance with an embodiment I of the present application;
FIG. 3 is a schematic diagram II of an alternative interface testing method according to a first embodiment of the present application;
fig. 4 is a schematic diagram of an interface testing device according to a second embodiment of the present application;
fig. 5 is a schematic diagram of an interface test electronic device according to a fifth embodiment of the present application.
Detailed Description
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, user information included in the interface, etc.) and the data (including, but not limited to, data used for analysis, stored data, displayed data, data included in the interface, etc.) related to the present application are information and data authorized by the user or fully authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related area, and are provided with corresponding operation entries for the user to select authorization or rejection.
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the present application described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
The present invention is described below in connection with preferred implementation steps, and fig. 1 is a flowchart of an interface testing method according to an embodiment of the present application, and as shown in fig. 1, the method includes the following steps:
step S101, under the condition that an interface test instruction is received, acquiring target interface information of an interface to be tested from the interface test instruction, wherein the target interface information at least comprises the following information: and the target application name of the application to which the interface to be tested belongs.
In the first embodiment, the interface test instruction refers to an instruction initiated by a tester to construct a test script for the interface test. In order to save the time of the tester and improve the working efficiency of the tester, the application name which the tester wants to test, namely the target application name, needs to be obtained from the interface test instruction, so that a corresponding interface test script is constructed according to the interface information contained in the target application name.
Step S102, representing parameter information of the interface included in the target application name by adopting a preset data structure to obtain a target dictionary.
In the first embodiment, in order to quickly generate a test script corresponding to one or more interfaces, a dictionary structure (i.e., the preset data structure) may be used to characterize parameter information of each interface in the target interface information, so as to obtain the target dictionary, so that the test script corresponding to each interface can be constructed according to the target dictionary, and a tester is prevented from manually querying the interface information of each interface and constructing the corresponding test script.
Step S103, constructing a test template of each interface in the target application name according to the target dictionary, and obtaining a test template set.
In the first embodiment, the interface information of each interface needs to be extracted from the target dictionary, and the test template corresponding to each interface is constructed according to the dictionary structure and the interface information of each interface, so that the effect that the test script can be automatically generated only by determining the parameters used by the test personnel is realized, repeated work required to be executed by the test personnel is reduced, the test efficiency of the test personnel is improved, and the accuracy of the test script is improved.
And step S104, adding interface test parameters into the test templates of the test template set to obtain a test script set.
After the test template is generated in the first embodiment, interface test parameters input by a tester are required to be received, and the interface test parameters are filled into the corresponding test templates to automatically generate test scripts, so that the tester can test the interface by adopting the test scripts.
Step S105, testing the interface to be tested according to the test scripts in the test script set to obtain a test result.
In the first embodiment, after a test script for an interface is generated, the test script is automatically called, the interface to be tested is tested, and data returned after the interface call is captured, so that the test result is obtained, a tester can analyze the tested interface according to the test result, find out the interface with a problem, and carry out subsequent work to ensure the normal operation of the interface.
In summary, in the interface testing method provided in the first embodiment of the present application, under the condition that an interface testing instruction is received, target interface information of an interface to be tested is obtained from the interface testing instruction, where the target interface information at least includes the following information: a target application name of an application to which the interface to be tested belongs; characterizing parameter information of a target application name containing interface by adopting a preset data structure to obtain a target dictionary; constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set; adding interface test parameters into a test template of the test template set to obtain a test script set; the interface to be tested is tested according to the test scripts in the test script set to obtain a test result, and the problem of low test efficiency caused by manually and repeatedly assembling parameters when a tester tests the application interface in the related technology is solved. The parameter information of the interface to be tested is represented through the preset data structure, the target dictionary is obtained, the nesting relation between the application and the interface can be clearly represented by the dictionary structure, so that the test template and the test script corresponding to each interface to be tested are rapidly generated according to the target dictionary, the problem that test parameters of the interface are repeatedly spliced by a tester, the problem that the test efficiency is low and the test accuracy is low is solved, the time of the tester is saved, and the effect of improving the test efficiency of the tester is achieved.
Optionally, in the method for testing an interface provided in the first embodiment of the present application, obtaining target interface information of an interface to be tested from an interface test instruction includes: obtaining at least one target application name in the interface test instruction, and obtaining interface test version information of the target application name, wherein the interface test version information at least comprises one of the following information: testing version information and regression version information; characterizing at least one target application name and an interface test version of the target application name by adopting a list structure to obtain a target list; and determining target interface information according to the target list.
In the first embodiment, in order to generate a test script required by a tester, at least one target application name input by a target object may be obtained in an interface test instruction, and at the same time, an interface version that the tester wants to test may also be obtained, where the interface version includes at least one of a test version and a regression version, different test versions correspond to different input parameters, and finally, a list or an array is constructed according to at least one target application name and the test version corresponding to the application name, so as to obtain the target interface information, thereby generating the test script required by the tester for the tester, and achieving the effect of improving the working efficiency of the tester. The test version refers to a version which is not tested by a tester, and the regression version refers to a version which is tested by the tester and modified by a developer and is used for carrying out regression test on the interface before the interface is on line.
Optionally, in the method for testing an interface provided in the first embodiment of the present application, characterizing, with a preset data structure, parameter information of a target application name including an interface, where obtaining the target dictionary includes: acquiring service information of at least one service contained in a target application name from a preset document to obtain a service information set; acquiring parameter information of at least one interface contained in each service in a service information set from a preset document to obtain an interface information set; and constructing a key value pair according to the target application name, the service information set and the interface information set, and determining a target dictionary according to the key value pair.
In the first embodiment, in order to quickly generate the test script, the parameter information of each interface may be converted into a dictionary structure (i.e., the above-mentioned preset data structure), so that the data structure of the interfaces, services and applications nested layer by layer can be clearly represented by adopting the dictionary structure.
Specifically, all services (services) included in the name of the target application and parameter information of interfaces included in each service may be obtained from an interface document center (i.e. the preset document), and a corresponding key value pair is constructed to obtain the target dictionary, where the parameter information may include information about the name of the parameter, the type of the parameter, whether filling is necessary, and the like. Examples of target dictionaries may be as follows: { 'application name': { 'service name 1': { 'interface 1': { 'parameter 1': device name, 'parameter 2': 'update time', 'interface 2': { 'parameter 1': device name, 'parameter 2': 'number of devices' } 'service name 2': { 'interface 1': { 'parameter 1': device name, 'parameter 2': 'number of devices', 'interface 2': { 'parameter 1': device name, 'parameter 2': 'number of devices' } }.
The interface document center, which may also be referred to as API (Application Programming Interface) document center, is a platform or tool for centrally managing and exposing API documents, which is typically used to help testers or developers quickly understand and use APIs, including information about the functions, parameters, request and response formats, etc. of the APIs.
Optionally, in the method for testing interfaces provided in the first embodiment of the present application, constructing a test template of each interface in the target application name according to the target dictionary, and obtaining the test template set includes: determining each interface information contained in the target dictionary by traversing key value pairs in the target dictionary; constructing json objects corresponding to each interface according to the information of each interface to obtain a json object set; constructing an interface test template corresponding to each json object in the json object set; creating a corresponding folder for each json object, and storing the interface test template corresponding to each json object into the folder corresponding to each json object to obtain a test template set.
In the first embodiment, in order to automatically generate the test script, the key value pairs in the target dictionary may be traversed, each interface information is converted into a preset data format, that is, the json object, and a test template is generated according to the json object, so that the test script is generated according to the test template.
In an alternative embodiment, to automatically generate the test script, each key value pair in the target dictionary may be traversed, and the key value pair corresponding to each interface is located, so as to obtain the input parameter information of each interface. And then determining the service name of the service to which the interface belongs according to the key value pair of the upper layer to which the key value pair corresponding to each interface belongs, and determining the application name of the application to which the interface belongs according to each interface key value pair to which the service name belongs, so that the input parameter information of each interface, the service name of the service to which the interface belongs and the application name of the application to which the interface belongs, namely each interface information contained in the target dictionary can be determined. And secondly, converting each interface information into a json object, and storing the json object in a json character string mode to obtain the test template. And finally, creating a folder according to the form of the application name/service name/interface name, and storing the test templates corresponding to each interface in the corresponding folder only to obtain the test template set.
Optionally, in the method for testing an interface provided in the first embodiment of the present application, adding interface test parameters to a test template of a test template set, the obtaining a test script set includes: receiving interface test parameters input by a target object aiming at each test template in the test template set to obtain target parameters; adding target parameters into each test template through target processing operation to obtain a test script corresponding to each test template, wherein the target processing operation at least comprises one of the following operations: replacing and splicing; and obtaining a test script set according to the test scripts corresponding to each test template.
In an alternative embodiment, after the test template is generated, the test parameters (i.e., the target parameters) input by the tester (i.e., the target objects) are required to be received, that is, the input parameters of the interface in the test template are acquired, all the parameters to be input in the test template are replaced by the target parameters, if the number of the received target parameters is inconsistent with the number of the received target parameters in the test template or the data types of the target parameters are inconsistent with the preset data types in the test template, corresponding prompt information is returned to the tester, and the target parameters input by the tester are received again until the target parameters conform to the input parameters in the test template. After the target parameters meeting the requirements are obtained, the target parameters are adopted to replace the input parameters of the interfaces in the test templates, splicing is carried out, the input parameters are filled into the positions of the input parameters in the input templates, and the test script corresponding to each test template is obtained.
Optionally, in the method for testing an interface provided in the first embodiment of the present application, before testing an interface to be tested according to a test script in a test script set to obtain a test result, the method further includes: generating random codes of the test scripts by a preset method aiming at each test script in the test script set; a random code is added to the test scripts and each test script in the set of test scripts is updated.
In the first embodiment, in order to reduce the operations that the tester needs to execute, a random code required when each interface is called may be generated by a random number generator and a custom algorithm before testing, and the random code is filled into each test script in the test script set, so that the tester can directly use the test script to test the interface, and the effect of improving the test efficiency of the tester is achieved.
Optionally, in the method for testing an interface provided in the first embodiment of the present application, after testing an interface to be tested according to a test script in a test script set to obtain a test result, the method further includes: determining an interface with a code defect according to the test result to obtain a defect report; a defect report is sent to the target object.
In an alternative embodiment, after the interfaces are tested by adopting the test script set, interfaces different from the expected test result are determined according to the actual test result, namely the interfaces with code defects (bug), and the test process, test data, test scripts and test results of the interfaces with code defects are filled into a preset defect list to obtain the defect report, and finally the defect report is sent to a tester and/or a developer, the tester continues to perform tracking test on the interfaces with code defects, and the developer adjusts and modifies the interfaces to ensure the normal operation of the interfaces.
Alternatively, in the first embodiment, the flow of generating the test template according to the present embodiment may be as shown in fig. 2. Step S201, determining a target application name of an interface to be tested and a test version of the interface to be tested; step S202, executing a script for generating the target dictionary to obtain the target dictionary, wherein the script for generating the target dictionary comprises: acquiring a service name and an input parameter of each interface from an API document center according to the target application name; according to the service name of the service contained in the target application name, interfaces contained in each service, and the input parameters of each interface construct a target dictionary; step S203, converting the interface information related to each interface in the target dictionary into json objects, and generating test templates corresponding to the interfaces according to the json objects to obtain the test template set.
Optionally, in the first embodiment, the flow of generating the test template according to the present embodiment may also be as shown in fig. 3. Step S301, receiving an application name of the interface to be tested input by the tester, and receiving a test version corresponding to the application name. Step S302, the service names of all the services under the application name are obtained from the API document center, and all the interfaces under each service name are obtained according to the test version. Step S303, the dictionary structure is encapsulated according to the interface name of each interface, the service name of each interface, and the application name of each interface (such as the related information in FIG. 3). Step S304, obtaining the input parameters of each interface according to the test version of each interface and updating the target dictionary. Step S305 creates a file directory according to the format of the application name/service name/interface name. Step S306, converting the related information of each interface in the target dictionary into json objects. Step S307, a test template file is created in the file directory. Step S308, writing the json object of each interface into a corresponding test template file to obtain the test template set.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
Example two
The second embodiment of the present application further provides an interface testing device, which needs to be described, where the interface testing device of the second embodiment of the present application may be used to execute the method for interface testing provided in the first embodiment of the present application. The following describes an interface testing device provided in the second embodiment of the present application.
Fig. 4 is a schematic diagram of an interface testing device according to a second embodiment of the present application. As shown in fig. 4, the apparatus includes: an acquisition unit 401, a characterization unit 402, a construction unit 403, a first addition unit 404 and a test unit 405.
Specifically, the obtaining unit 401 is configured to obtain, when receiving an interface test instruction, target interface information of an interface to be tested from the interface test instruction, where the target interface information includes at least the following information: and the target application name of the application to which the interface to be tested belongs.
And the characterization unit 402 is configured to characterize the parameter information of the interface included in the target application name by using a preset data structure, so as to obtain a target dictionary.
And the construction unit 403 is configured to construct a test template of each interface in the target application name according to the target dictionary, so as to obtain a test template set.
The first adding unit 404 is configured to add interface test parameters to the test templates of the test template set, so as to obtain a test script set.
And the test unit 405 is configured to test the interface to be tested according to the test scripts in the test script set, so as to obtain a test result.
In the interface testing device provided in the second embodiment of the present application, under the condition that an interface testing instruction is received by the obtaining unit 401, target interface information of an interface to be tested is obtained from the interface testing instruction, where the target interface information at least includes the following information: a target application name of an application to which the interface to be tested belongs; the characterization unit 402 characterizes the parameter information of the target application name containing interface by adopting a preset data structure to obtain a target dictionary; the construction unit 403 constructs a test template of each interface in the target application name according to the target dictionary to obtain a test template set; the first adding unit 404 adds interface test parameters in the test templates of the test template set to obtain a test script set; the test unit 405 tests the interface to be tested according to the test scripts in the test script set to obtain a test result, so that the problem of lower test efficiency caused by manually and repeatedly assembling parameters when a tester tests the application interface in the related art is solved. The parameter information of the interface to be tested is represented through the preset data structure, the target dictionary is obtained, the nesting relation between the application and the interface can be clearly represented by the dictionary structure, so that the test template and the test script corresponding to each interface to be tested are rapidly generated according to the target dictionary, the problem that test parameters of the interface are repeatedly spliced by a tester, the problem that the test efficiency is low and the test accuracy is low is solved, the time of the tester is saved, and the effect of improving the test efficiency of the tester is achieved.
Optionally, in the interface testing device provided in the second embodiment of the present application, the acquiring unit 401 includes: the first obtaining subunit is configured to obtain at least one target application name in the interface test instruction, and obtain interface test version information of the target application name, where the interface test version information at least includes one of the following information: testing version information and regression version information; the characterization subunit is used for characterizing at least one target application name and an interface test version of the target application name by adopting a list structure to obtain a target list; and the first determining subunit is used for determining the target interface information according to the target list.
Optionally, in the interface testing device provided in the second embodiment of the present application, the characterizing unit 402 includes: the second acquisition subunit is used for acquiring service information of at least one service contained in the target application name in a preset document to obtain a service information set; a third obtaining subunit, configured to obtain parameter information of at least one interface included in each service in the service information set in a preset document, to obtain an interface information set; and the first construction subunit is used for constructing key value pairs according to the target application name, the service information set and the interface information set, and determining a target dictionary according to the key value pairs.
Optionally, in the interface testing device provided in the second embodiment of the present application, the aforementioned building unit 403 includes: a second determination subunit, configured to traverse key value pairs in the target dictionary to determine each interface information included in the target dictionary; the second construction subunit is used for constructing json objects corresponding to each interface according to the information of each interface to obtain a json object set; the third construction subunit is used for constructing an interface test template corresponding to each json object in the json object set; the creating subunit is used for creating a corresponding folder for each json object, and storing the interface test template corresponding to each json object into the folder corresponding to each json object to obtain a test template set.
Optionally, in the interface testing apparatus provided in the second embodiment of the present application, the first adding unit 404 includes: the receiving subunit is used for receiving interface test parameters input by the target object aiming at each test template in the test template set to obtain target parameters; the adding subunit is configured to add the target parameter to each test template through a target processing operation, and obtain a test script corresponding to each test template, where the target processing operation at least includes one of the following operations: replacing and splicing; and the third determining subunit is used for obtaining a test script set according to the test scripts corresponding to each test template.
Optionally, in the interface testing device provided in the second embodiment of the present application, the device further includes: the generating unit is used for generating random codes of the test scripts by a preset method aiming at each test script in the test script set before testing the interface to be tested according to the test scripts in the test script set to obtain a test result; and the second adding unit is used for adding the random code into the test scripts and updating each test script in the test script set.
Optionally, in the interface testing device provided in the second embodiment of the present application, the device further includes: the determining unit is used for testing the interfaces to be tested according to the test scripts in the test script set to obtain test results, and determining the interfaces with code defects according to the test results to obtain defect reports; and the sending unit is used for sending the defect report to the target object.
The interface test device includes a processor and a memory, where the above-mentioned obtaining unit 401, characterizing unit 402, constructing unit 403, first adding unit 404, and test unit 405 are stored as program units, and the processor executes the above-mentioned program units stored in the memory to implement corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one kernel, and the working efficiency of the tester is improved by adjusting the kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
A third embodiment of the present invention provides a computer-readable storage medium having a program stored thereon, which when executed by a processor, implements an interface test method.
The fourth embodiment of the invention provides a processor, which is used for running a program, wherein the program runs to execute an interface test method.
As shown in fig. 5, a fifth embodiment of the present invention provides an electronic device, where the device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor implements the following steps when executing the program: under the condition that an interface test instruction is received, acquiring target interface information of an interface to be tested from the interface test instruction, wherein the target interface information at least comprises the following information: a target application name of an application to which the interface to be tested belongs; characterizing parameter information of a target application name containing interface by adopting a preset data structure to obtain a target dictionary; constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set; adding interface test parameters into a test template of the test template set to obtain a test script set; and testing the interface to be tested according to the test scripts in the test script set to obtain a test result.
The processor also realizes the following steps when executing the program: the obtaining the target interface information of the interface to be tested from the interface test instruction comprises the following steps: obtaining at least one target application name in the interface test instruction, and obtaining interface test version information of the target application name, wherein the interface test version information at least comprises one of the following information: testing version information and regression version information; characterizing at least one target application name and an interface test version of the target application name by adopting a list structure to obtain a target list; and determining target interface information according to the target list.
The processor also realizes the following steps when executing the program: characterizing parameter information of a target application name containing interface by adopting a preset data structure, and obtaining a target dictionary comprises: acquiring service information of at least one service contained in a target application name from a preset document to obtain a service information set; acquiring parameter information of at least one interface contained in each service in a service information set from a preset document to obtain an interface information set; and constructing a key value pair according to the target application name, the service information set and the interface information set, and determining a target dictionary according to the key value pair.
The processor also realizes the following steps when executing the program: constructing a test template of each interface in the target application name according to the target dictionary, wherein the step of obtaining the test template set comprises the following steps: determining each interface information contained in the target dictionary by traversing key value pairs in the target dictionary; constructing json objects corresponding to each interface according to the information of each interface to obtain a json object set; constructing an interface test template corresponding to each json object in the json object set; creating a corresponding folder for each json object, and storing the interface test template corresponding to each json object into the folder corresponding to each json object to obtain a test template set.
The processor also realizes the following steps when executing the program: adding interface test parameters in a test template of the test template set to obtain a test script set comprises: receiving interface test parameters input by a target object aiming at each test template in the test template set to obtain target parameters; adding target parameters into each test template through target processing operation to obtain a test script corresponding to each test template, wherein the target processing operation at least comprises one of the following operations: replacing and splicing; and obtaining a test script set according to the test scripts corresponding to each test template.
The processor also realizes the following steps when executing the program: before the interface to be tested is tested according to the test scripts in the test script set to obtain the test result, the method further comprises the following steps: generating random codes of the test scripts by a preset method aiming at each test script in the test script set; a random code is added to the test scripts and each test script in the set of test scripts is updated.
The processor also realizes the following steps when executing the program: after testing the interface to be tested according to the test scripts in the test script set to obtain a test result, the method further comprises the following steps: determining an interface with a code defect according to the test result to obtain a defect report; a defect report is sent to the target object.
The device herein may be a server, PC, PAD, cell phone, etc.
The present application also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: under the condition that an interface test instruction is received, acquiring target interface information of an interface to be tested from the interface test instruction, wherein the target interface information at least comprises the following information: a target application name of an application to which the interface to be tested belongs; characterizing parameter information of a target application name containing interface by adopting a preset data structure to obtain a target dictionary; constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set; adding interface test parameters into a test template of the test template set to obtain a test script set; and testing the interface to be tested according to the test scripts in the test script set to obtain a test result.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: the obtaining the target interface information of the interface to be tested from the interface test instruction comprises the following steps: obtaining at least one target application name in the interface test instruction, and obtaining interface test version information of the target application name, wherein the interface test version information at least comprises one of the following information: testing version information and regression version information; characterizing at least one target application name and an interface test version of the target application name by adopting a list structure to obtain a target list; and determining target interface information according to the target list.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: characterizing parameter information of a target application name containing interface by adopting a preset data structure, and obtaining a target dictionary comprises: acquiring service information of at least one service contained in a target application name from a preset document to obtain a service information set; acquiring parameter information of at least one interface contained in each service in a service information set from a preset document to obtain an interface information set; and constructing a key value pair according to the target application name, the service information set and the interface information set, and determining a target dictionary according to the key value pair.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: constructing a test template of each interface in the target application name according to the target dictionary, wherein the step of obtaining the test template set comprises the following steps: determining each interface information contained in the target dictionary by traversing key value pairs in the target dictionary; constructing json objects corresponding to each interface according to the information of each interface to obtain a json object set; constructing an interface test template corresponding to each json object in the json object set; creating a corresponding folder for each json object, and storing the interface test template corresponding to each json object into the folder corresponding to each json object to obtain a test template set.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: adding interface test parameters in a test template of the test template set to obtain a test script set comprises: receiving interface test parameters input by a target object aiming at each test template in the test template set to obtain target parameters; adding target parameters into each test template through target processing operation to obtain a test script corresponding to each test template, wherein the target processing operation at least comprises one of the following operations: replacing and splicing; and obtaining a test script set according to the test scripts corresponding to each test template.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: before the interface to be tested is tested according to the test scripts in the test script set to obtain the test result, the method further comprises the following steps: generating random codes of the test scripts by a preset method aiming at each test script in the test script set; a random code is added to the test scripts and each test script in the set of test scripts is updated.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: after testing the interface to be tested according to the test scripts in the test script set to obtain a test result, the method further comprises the following steps: determining an interface with a code defect according to the test result to obtain a defect report; a defect report is sent to the target object.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.
Claims (10)
1. An interface testing method, comprising:
under the condition that an interface test instruction is received, acquiring target interface information of an interface to be tested from the interface test instruction, wherein the target interface information at least comprises the following information: a target application name of the application to which the interface to be tested belongs;
characterizing the parameter information of the interface contained in the target application name by adopting a preset data structure to obtain a target dictionary;
constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set;
adding interface test parameters into a test template of the test template set to obtain a test script set;
and testing the interface to be tested according to the test scripts in the test script set to obtain a test result.
2. The method of claim 1, wherein obtaining target interface information for an interface to be tested from the interface test instruction comprises:
obtaining at least one target application name in the interface test instruction, and obtaining interface test version information of the target application name, wherein the interface test version information at least comprises one of the following information: testing version information and regression version information;
Characterizing at least one target application name and an interface test version of the target application name by adopting a list structure to obtain a target list;
and determining the target interface information according to the target list.
3. The method of claim 1, wherein characterizing the parameter information of the target application name-containing interface with a preset data structure, the target dictionary comprises:
acquiring service information of at least one service contained in the target application name from a preset document to obtain a service information set;
acquiring parameter information of at least one interface contained in each service in the service information set from the preset document to obtain an interface information set;
and constructing a key value pair according to the target application name, the service information set and the interface information set, and determining the target dictionary according to the key value pair.
4. The method of claim 1, wherein constructing a test template for each interface in the target application name from the target dictionary, the obtaining a set of test templates comprises:
determining each interface information contained in the target dictionary by traversing key value pairs in the target dictionary;
Constructing json objects corresponding to each interface according to the information of each interface to obtain a json object set;
constructing an interface test template corresponding to each json object in the json object set;
creating a corresponding folder for each json object, and storing the interface test template corresponding to each json object into the folder corresponding to each json object to obtain the test template set.
5. The method of claim 1, wherein adding interface test parameters to the test templates of the set of test templates, the obtaining the set of test scripts comprises:
receiving interface test parameters input by a target object aiming at each test template in the test template set to obtain target parameters;
adding the target parameters into each test template through target processing operation to obtain a test script corresponding to each test template, wherein the target processing operation at least comprises one of the following operations: replacing and splicing;
and obtaining the test script set according to the test script corresponding to each test template.
6. The method of claim 1, wherein prior to testing the interface under test according to test scripts in the set of test scripts to obtain test results, the method further comprises:
Generating a random code of each test script in the test script set through a preset method;
adding the random code to the test scripts and updating each test script in the test script set.
7. The method of claim 1, wherein after testing the interface under test according to test scripts in the set of test scripts to obtain a test result, the method further comprises:
determining an interface with a code defect according to the test result to obtain a defect report;
and sending the defect report to a target object.
8. An interface testing apparatus, comprising:
the device comprises an acquisition unit, a test unit and a test unit, wherein the acquisition unit is used for acquiring target interface information of an interface to be tested from an interface test instruction under the condition of receiving the interface test instruction, and the target interface information at least comprises the following information: a target application name of the application to which the interface to be tested belongs;
the characterization unit is used for characterizing the parameter information of the interface contained in the target application name by adopting a preset data structure to obtain a target dictionary;
the construction unit is used for constructing a test template of each interface in the target application name according to the target dictionary to obtain a test template set;
The first adding unit is used for adding interface test parameters into the test templates of the test template set to obtain a test script set;
and the test unit is used for testing the interface to be tested according to the test scripts in the test script set to obtain a test result.
9. A computer readable storage medium, characterized in that the computer readable storage medium comprises a stored computer program, wherein the computer program, when run, controls a device in which the computer readable storage medium is located to perform the interface testing method of any one of claims 1 to 7.
10. An electronic device comprising one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the interface testing method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410065373.0A CN117724983A (en) | 2024-01-16 | 2024-01-16 | Interface testing method and device, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410065373.0A CN117724983A (en) | 2024-01-16 | 2024-01-16 | Interface testing method and device, storage medium and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117724983A true CN117724983A (en) | 2024-03-19 |
Family
ID=90201732
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410065373.0A Pending CN117724983A (en) | 2024-01-16 | 2024-01-16 | Interface testing method and device, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117724983A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118277280A (en) * | 2024-05-30 | 2024-07-02 | 江苏曼荼罗软件股份有限公司 | Service interface self-test method, system, readable storage medium and equipment |
-
2024
- 2024-01-16 CN CN202410065373.0A patent/CN117724983A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118277280A (en) * | 2024-05-30 | 2024-07-02 | 江苏曼荼罗软件股份有限公司 | Service interface self-test method, system, readable storage medium and equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108595342B (en) | Unit testing method and device | |
CN110515848B (en) | Automatic test system and automatic test method | |
US20140282372A1 (en) | Code separation with semantic guarantees | |
US11422917B2 (en) | Deriving software application dependency trees for white-box testing | |
CN117724983A (en) | Interface testing method and device, storage medium and electronic equipment | |
CN104424093A (en) | Compatibility testing method and system | |
CN112241360A (en) | Test case generation method, device, equipment and storage medium | |
CN103186463B (en) | Determine the method and system of the test specification of software | |
CN111949543A (en) | Testing method and device based on distributed platform, electronic equipment and storage medium | |
CN110955409A (en) | Method and device for creating resources on cloud platform | |
CN111240987B (en) | Method and device for detecting migration program, electronic equipment and computer readable storage medium | |
CN114791885A (en) | Interface test method, device, equipment and medium | |
CN117687920A (en) | Interface testing method and device, storage medium and electronic equipment | |
CN110147313B (en) | Log output method and device | |
CN116841653A (en) | Execution method and device of operation and maintenance job, processor and electronic equipment | |
CN116860322A (en) | Front-end data source processing method, device, equipment and storage medium | |
CN113094281B (en) | Test method and device for hybrid App | |
EP2721494B1 (en) | System and method to in-line script dependencies | |
CN117348848A (en) | Operator development and processing method and device, electronic equipment, system and storage medium | |
CN115185570A (en) | JIRA system-based task flow processing method, system, device, medium, and computer program product | |
CN116521251A (en) | Service management method, device, computer equipment and storage medium | |
CN118261143B (en) | Json data analysis method, device, equipment and medium in Unity environment | |
CN117130895A (en) | Interface testing method, device, electronic equipment and medium | |
CN114944998B (en) | Internet of things system testing method and device based on simulator | |
CN117520160A (en) | Code coverage rate testing method and device, storage medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |