CN113326208A - Interface test method and device - Google Patents

Interface test method and device Download PDF

Info

Publication number
CN113326208A
CN113326208A CN202110883480.0A CN202110883480A CN113326208A CN 113326208 A CN113326208 A CN 113326208A CN 202110883480 A CN202110883480 A CN 202110883480A CN 113326208 A CN113326208 A CN 113326208A
Authority
CN
China
Prior art keywords
interface
target
test
keywords
keyword
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
Application number
CN202110883480.0A
Other languages
Chinese (zh)
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.)
Shenzhen Dimension Data Technology Co Ltd
Original Assignee
Shenzhen Dimension Data 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 Shenzhen Dimension Data Technology Co Ltd filed Critical Shenzhen Dimension Data Technology Co Ltd
Priority to CN202110883480.0A priority Critical patent/CN113326208A/en
Publication of CN113326208A publication Critical patent/CN113326208A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing

Abstract

The application provides an interface testing method and equipment, comprising the following steps: extracting the identification of the target engineering resource and the identification of the target interface from the test instruction, sending a downloading request to the development server, and receiving the target engineering resource of the development server, wherein the downloading request is generated according to the identification of the target engineering resource, extracting interface information of a plurality of interfaces from the target engineering resource, wherein the interface information comprises interface types and interface parameters, determining a target test template program from the test template program according to the interface type of the target interface, generating test parameters according to the interface parameters, inputting the test parameters into the target test template program, and then operating the target test template program to obtain a test result of the target interface. The scheme can realize the automatic interface test and the interface information management.

Description

Interface test method and device
Technical Field
The present application relates to the field of internet technologies, and in particular, to an interface testing method and device.
Background
At present, developers need to manually write interface documents, writing errors in the interface documents often occur, or the interface documents need to be updated and synchronized to relevant personnel when subsequent interfaces are updated, and the interface documents need to be updated repeatedly, so that the developers and testers cannot obtain interface information in time, and the efficiency is low.
When a tester executes a test, the tester needs to write an interface test script, and the tester needs to be familiar with codes, so that the requirement on the code level of the tester is high.
Disclosure of Invention
The application provides an interface testing method and equipment, and aims to provide a scheme capable of realizing automatic interface testing and interface information management.
In a first aspect, an embodiment of the present application provides an interface testing method, where the method is applied to an interface server, and the method includes:
extracting the identification of the target engineering resource and the identification of the target interface from the test instruction;
sending a downloading request to a development server, and receiving target engineering resources of the development server; the downloading request is generated according to the identification of the target engineering resource;
extracting interface information of a plurality of interfaces from target engineering resources; the interface information comprises an interface type and interface parameters;
determining a target test template program from the test template programs according to the interface type of the target interface, and generating test parameters according to the interface parameters;
and inputting the test parameters into the target test template program and then operating the target test template program to obtain the test result of the target interface.
In an embodiment, extracting interface information of a plurality of interfaces from engineering resources specifically includes:
reading a source code under a storage path of an interface code in the target engineering resource, and partitioning the source code to obtain target codes of a plurality of areas;
aiming at the target code of each region, identifying the target code to obtain a plurality of keywords and contents corresponding to the keywords;
and when the keywords and the contents corresponding to the keywords meet the preset interface identification conditions, determining the interface information of the interfaces according to the keywords and the contents corresponding to the keywords.
In the technical scheme, the interface information of the interfaces is determined according to the keywords and the content corresponding to the keywords by identifying the keywords and the content corresponding to the keywords in the target code, so that the target code is accurately identified.
In an embodiment, identifying the target code to obtain a plurality of keywords and contents corresponding to the keywords specifically includes:
for each line of target codes, performing annotation information identification on the target codes, and determining a target character string template from character string templates corresponding to the keywords according to the annotation information;
extracting a character string from the target code, and comparing the similarity of the extracted character string with a target character string template;
and when the similarity meets the keyword recognition condition, taking the extracted character string as a keyword, and extracting the character string around the keyword as the content corresponding to the keyword.
In the technical scheme, the character string template is determined by utilizing the annotation information of each line of codes, and then the character string template is compared with the extracted character string, so that the keywords and the content corresponding to the keywords can be identified through the two steps, and the identification efficiency and the identification accuracy are improved.
In an embodiment, the method for recognizing the content of the keyword includes that the keyword and the content corresponding to the keyword meet a preset interface recognition condition, and specifically includes:
when the key words and the content corresponding to the key words represent the interface address;
when the keywords and the content corresponding to the keywords represent an interface request mode;
when the keywords and the content corresponding to the keywords represent interface port numbers;
when the keywords and the content corresponding to the keywords represent input parameters;
when the keyword and the content corresponding to the keyword represent the output parameter;
when the keywords and the content corresponding to the keywords represent abnormal output;
when the keyword and the content corresponding to the keyword represent the status code description information;
when the keyword and the content corresponding to the keyword represent version information.
In the above technical solution, the codes of the interfaces are analyzed, the 8 features are selected as interface features, the codes in the preset area satisfying the features are used as one interface, and the interface information of the interface is determined, so as to realize the identification of the interface.
In an embodiment, determining interface information of a plurality of interfaces according to a plurality of keywords and contents corresponding to the keywords specifically includes:
and taking the keywords representing the interface address and the content corresponding to the keywords identified in the preset area, the keywords representing the interface request mode and the content corresponding to the keywords, the keywords representing the interface port number and the content corresponding to the keywords, the keywords representing the input parameters and the content corresponding to the keywords, the keywords representing the output parameters and the content corresponding to the keywords, the keywords representing abnormal output and the content corresponding to the keywords, the keywords representing the state code description information and the content corresponding to the keywords representing the version information and the content corresponding to the keywords as the interface information of the same interface.
In an embodiment, the generating of the test parameter according to the interface parameter specifically includes any one of the following:
generating a test parameter within the parameter range according to the parameter range of the input parameter;
generating a test parameter outside the parameter range according to the parameter range of the input parameter;
and generating the test parameters of the boundary values according to the parameter range of the input parameters.
In an embodiment, the method further comprises:
and after receiving the update information of the target engineering resource sent by the client, generating a test instruction according to the target engineering resource.
In an embodiment, the step of running the target test template program after inputting the test parameters into the target test template program to obtain the test result of the target interface specifically includes:
acquiring output data of a target test template program after test parameters are input;
and comparing the output data with the output parameters of the target interface, and outputting the test state of the target interface according to the comparison result.
In an embodiment, the method further comprises:
receiving a query instruction sent by a client; wherein the query instruction comprises an identification of the target engineering resource;
and returning the interface information and the test state of each interface in the target engineering resource to the client.
In an embodiment, the method further comprises:
receiving a derivation instruction sent by a client; wherein the query instruction comprises an identifier of the target interface;
acquiring interface information of a target interface and a preset interface document template;
and sending the interface information of the target interface and the preset interface document template to the client so that the client generates an interface document according to the interface information and the preset interface document template.
In a second aspect, an embodiment of the present application provides a server, including: a memory, a processor;
a memory; for storing computer instructions executable by a processor;
wherein the processor, when executing the computer instructions, is adapted to carry out the interface testing method as claimed in the first aspect and the alternative.
In a third aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer instructions are stored, and the computer instructions are used to implement the interface testing method according to the first aspect and the alternative when executed by a processor.
In a fourth aspect, an embodiment of the present application provides a computer program product, which includes computer instructions that, when executed by a processor, implement the interface testing method according to the first aspect and the alternative.
The interface test method and the equipment provided by the application can extract the identification of the target engineering resource and the identification of the target interface from the test instruction after receiving the test instruction, generate a download request according to the identification of the target engineering resource to download the target engineering resource from the development server, extract the interface information of a plurality of interfaces from the target engineering resource, determine the target test template program from the test template program according to the interface type of the target interface, generate the test parameters according to the interface parameters, input the test parameters into the target test template program and then operate the target test template program to obtain the test result of the target interface, namely, the test of the target interface in the target engineering resource indicated in the test instruction can be completed only by triggering the test instruction without compiling corresponding test codes aiming at each interface in different engineering resources, the requirement on the testing personnel is reduced.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
FIG. 1 is a block diagram of an interface test system according to another embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of an interface test system according to an embodiment of the present application;
fig. 3 is a schematic flowchart of an interface testing method according to another embodiment of the present application;
fig. 4 is a schematic flowchart of an interface testing method according to another embodiment of the present application;
fig. 5 is a schematic structural diagram of an interface testing apparatus according to another embodiment of the present application;
fig. 6 is a schematic structural diagram of an interface server according to another embodiment of the present application.
With the above figures, there are shown specific embodiments of the present application, which will be described in more detail below. These drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the inventive concepts to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
To solve the existing problem, as shown in fig. 1, the present application provides an interface test system, which can implement the following functions:
(1) the information of the interface used in the project or product can be inquired, added, deleted or modified, so that the information symmetry is ensured, developers can automatically test whether the compiled interface is correct and whether the interface is smooth through the system, and meanwhile, export of interface documents is supported.
(2) And a visual page is developed on the system, and testers can automatically test through interfaces required by the visual page configuration of the system and automatically test when test conditions are met. The test conditions can include that the interface automatic test is started at regular time or the interface automatic test is started after the version is released every time, the test result can also be automatically sent to the client side of the personnel corresponding to the project, so that part of the testers who do not know the codes can also complete the interface automatic test, meanwhile, the test result is timely synchronous, the problem is timely found, and the development efficiency and the test efficiency are improved.
The embodiment of the application provides an interface testing method and equipment, and aims to provide a scheme capable of realizing automatic interface testing and interface information management. In order to achieve the purpose, the technical idea of the application is as follows: after receiving the test instruction, acquiring the target engineering resource from the development server according to the test instruction, identifying the source code in the target engineering resource to obtain interface information of the interface, determining a target test template program and test parameters according to the interface information, and acquiring a test result of the interface according to the target test template program and the test parameters to realize automatic test. And the visual processing can be carried out according to the extracted interface information, and the latest information of the interface can be sent to the client of each project member in time, so that the all-round management of the interface in the engineering resource can be realized.
As shown in fig. 2, an embodiment of the present application provides an interface test system, which includes a client 101, a development server 102, and an interface server 103. The client 101 is in communication connection with the development server 102, the client 101 is also in communication connection with the interface server 103, and the development server 102 is also in communication connection with the interface server 103.
The client 101 is configured to download a development template from the development server 102, generate engineering resources according to the development template, and transmit the engineering resources back to the development server 102. The interface server 103 is used for downloading the engineering resources from the development server 102, extracting interface information of a plurality of interfaces from the engineering resources, and performing processing such as interface testing and interface display according to the interface information. The interface server 103 specifically runs the interface testing method described in the following embodiments, and reference may be made to the content described in the following embodiments, which is not described herein again.
As shown in fig. 3, an embodiment of the present application provides an interface testing method, which is applied to an interface testing system, and the method specifically includes the following steps:
s201, the interface server extracts the identification of the target engineering resource and the identification of the target interface from the test instruction.
In this step, the test instruction may be initiated by the client, or may be automatically generated by the interface server when the test condition is detected to be satisfied. For example: and generating a test instruction when the time interval from the last test reaches a test period.
The test instruction comprises an identification of the target engineering resource and an identification of the target interface, wherein the target engineering resource comprises the target interface.
S202, the interface server sends a downloading request to the development server.
In this step, after acquiring the identifier of the target engineering resource and the identifier of the target interface, the interface server generates a download request according to the identifier of the target engineering resource, so as to download the target engineering resource from the development server.
S203, the interface server receives the target engineering resource from the development server.
In this step, after receiving the download request, the development server searches the target engineering resource from the plurality of locally stored engineering resources according to the identifier of the target engineering resource, and transmits the target engineering resource back to the interface server.
S204, the interface server extracts interface information of a plurality of interfaces from the target engineering resources.
The interface refers to interaction points between an external system and a system and between internal subsystems. The interface information includes an interface type and interface parameters.
The interface includes external interface and internal interface, and wherein, internal interface includes again: the upper layer service is connected with the lower layer service interface and the same level interface. Common web interfaces: one is an interface to the http protocol and the other is a web service interface such as: soup, rmi, rpc protocols.
In this embodiment, for an http request interface, a common http request manner includes: get, post, put, delete, etc. That is, the interface types are classified as get, post, put, delete. Wherein get refers to query interface, post refers to add interface, put refers to modify interface, delete refers to delete interface.
The interface parameters refer to input parameters and output parameters of the interface.
S205, the interface server determines a target test template program from the test template programs according to the interface type of the target interface, and generates test parameters according to the interface parameters.
In the step, test template programs with different interface types are stored in the interface server, and after the interface server extracts the interface information of a plurality of interfaces from the target engineering resources, the interface server finds the interface information of the target interface from the interface information of the plurality of interfaces.
And determining a target test template program from the plurality of test template programs according to the one-to-one correspondence between the test template programs and the interface types of the target interface, and generating test parameters according to the interface parameters of the target interface.
In an embodiment, the range of a certain parameter of the target interface is 1-20 character strings, and then the character strings within 1-20 can be randomly generated as the test parameter, or more than 20 character strings can be randomly generated as the test parameter.
S206, the interface server operates the target test template program after inputting the test parameters into the target test template program so as to obtain the test result of the target interface.
In this step, after the test parameters are obtained, the test parameters are input into the target test template program, and the target test template program with the input test parameters is operated, so as to obtain the test result of the target interface.
In the technical scheme, after the interface server receives the test instruction, the target engineering resources are read from the development server, and the interface information of the target interface is extracted from the target engineering resources, so that the target test template program can be determined according to the interface type of the target interface, test parameters are generated, the test parameters can be input into the target test template program and then run, and the test result of the target interface is obtained.
As shown in fig. 4, an embodiment of the present application provides an interface testing method, which is applied to an interface testing system, and the method specifically includes the following steps:
s301, the interface server extracts the identification of the target engineering resource and the identification of the target interface from the test instruction.
In this step, as an embodiment, after uploading the update data of the target engineering resource to the development server, the client may directly send the update information of the interface in the target engineering resource to the interface server, or after receiving the update data of the target engineering resource, the development server sends the update information of the interface in the target engineering resource to the interface server, and after receiving the update information of the interface in the target engineering resource, the interface server generates the test instruction according to the identifier of the target engineering resource.
In the technical scheme, the user uploads the updated data of the target engineering resource through the client, so that the test can be triggered, and the test efficiency can be improved.
When generating the test instruction, the test condition may be determined according to the identifier of the target interface and the preconfigured test requirement, for example: whether an anomaly test or a boundary value test is required at the time of the test. By pre-configuring the test requirements by the user, the test can be triggered according to the configured test requirements after the user uploads the updated data of the target engineering resources through the client, and the test efficiency is further improved.
S302, the interface server sends a downloading request to the development server.
S303, the interface server receives the target engineering resources from the development server.
Here, the steps are already described in detail in the above steps S202 to S203, and are not described again here.
S304, the interface server extracts interface information of a plurality of interfaces from the target engineering resources.
In this step, when extracting interface information of a plurality of interfaces from engineering resources, reading a source code under a storage path of an interface code in the target engineering resource, and performing partition processing on the source code to obtain target codes of a plurality of areas. And aiming at the target code of each area, identifying the target code to obtain a plurality of keywords and contents corresponding to the keywords, and determining interface information of a plurality of interfaces according to the keywords and the contents corresponding to the keywords when the keywords and the contents corresponding to the keywords meet a preset interface identification condition.
When the source code is read, each storage path under the target engineering resource can be scanned, so that the storage path of the interface code is determined. And reading the source code under the storage path of the interface code.
When the source code is identified, the source code may be partitioned to obtain object codes of a plurality of regions, so that the object code of each region corresponds to one interface. The partitioning process may be performed according to a delimiter of each interface code. Because the extracted source code contains a plurality of interfaces, the extracted source code is partitioned, so that the interface identification is carried out on the target code in each region, and the identification accuracy can be improved.
Each line of object code may be scanned line by line for the object code of each region. And performing annotation information identification on the target codes for each line of target codes, determining a target character string template from character string templates corresponding to the keywords according to the annotation information, performing character string extraction on the target codes, performing similarity comparison on the extracted character strings and the target character string template, taking the extracted character strings as the keywords when the similarity meets the keyword identification conditions, and extracting the character strings around the keywords as contents corresponding to the keywords.
The following illustrates the process of identifying object code:
@ApiImplicitParams(
{
@ ApiImplicititparam (name = "project Id", value = "item id", dataType = "string", paramType = "query", required = true),
@ ApiImplicititparam (name = "queType", value = "questionnaire type", dataType = "int", paramType = "query", required = true)
}
) V/for specifying input parameters of an interface
By identifying the annotation information of the code, the input parameters of the line code for specifying the interface are determined, and the character string template corresponding to the input parameters is selected, for example: the character string template is "Param", "name", "value", "dataType", "paramType", and "required", the character string is extracted from the code, the extracted character string is compared with the similarity of the character string template, and if the similarity reaches a certain threshold, the character string is determined as a keyword, that is, keywords "Param", "name", "value", "dataType", "paramType", and "required" are determined from the code, the keywords all represent input parameters, the character strings near the keywords are identified, and the content corresponding to each keyword is obtained.
The content corresponding to the keyword "name" is "project id", the content corresponding to the keyword "value" is "item id", the content of the keyword is "dataType" corresponding to "string", the content of the keyword "paramType" is corresponding to "query", and the content of the keyword "required" is corresponding to "tube".
After extracting the keywords and the content corresponding to the keywords from the target code, judging that the keywords and the content corresponding to the keywords meet the preset interface identification condition, and if the keywords and the content corresponding to the keywords meet the preset interface identification condition, taking the keywords and the content corresponding to the keywords as interface information.
The preset interface identification condition specifically comprises the following steps:
when the key words and the content corresponding to the key words represent the interface address;
when the keywords and the content corresponding to the keywords represent an interface request mode;
when the keywords and the content corresponding to the keywords represent interface port numbers;
when the keywords and the content corresponding to the keywords represent input parameters;
when the keyword and the content corresponding to the keyword represent the output parameter;
when the keywords and the content corresponding to the keywords represent abnormal output;
when the keyword and the content corresponding to the keyword represent the status code description information;
when the keyword and the content corresponding to the keyword represent version information.
Typically, the code of the written interface mainly includes the following:
1. the interface address, i.e. the memory path of the interface.
2. The request mode is generally divided into a post type and a get type, and may further include a put type and a delete type.
3. Port number.
4. Input parameters, wherein the input parameters typically include the following information:
1) parameter names, such as: builder
2) Types, such as: number of
3) Whether padding is necessary, such as: if yes, the flag is 1, otherwise the flag is 0
4) Field lengths, such as: 20
5) Parameter values are specified, such as: male is marked as 1 and female is marked as 2
6) Parameter descriptions, such as: sex
5. Output parameters, wherein the output parameters typically include the following information:
1) parameter names, such as: address _ category
2) Types, such as: string
3) The description of the return values, such as: the urban area is marked as 1, the suburban area is marked as 2
4) Parameter descriptions, such as: classes of addresses
6. Abnormal participation and output of interface
1) Incomplete parameter name of input parameter and wrong parameter name of output interface
2) The parameter value of the input parameter is not in accordance with the expectation, and the value of the interface output parameter name is wrong
7. For the description of the different status codes, for example, the following status codes
200/201/202/203/204/205/206
300/301/302/303/304/305/307
400/401/403/404/405/406/407/408/409/410/411/412/413/414/415/416/ 417/500/501/502/503/504/505
8. Version information and description of an interface
1) The first version of the interface version is V1.0, and mainly comprises which interfaces
2) Subsequent updates to the interface version, e.g. to V1.1, which contents have been updated
If the keywords and the content corresponding to each keyword are identified from the target code as 8 items of content, the keywords corresponding to the 8 items of content and the content corresponding to each keyword are used as interface information of the same interface.
That is, the content corresponding to the keyword and the keyword representing the interface address, the content corresponding to the keyword and the keyword representing the interface request mode, the content corresponding to the keyword and the keyword representing the interface port number, the content corresponding to the keyword and the keyword representing the input parameter, the content corresponding to the keyword and the keyword representing the output parameter, the content corresponding to the keyword and the keyword representing the abnormal output, the content corresponding to the keyword and the keyword representing the status code description information, and the content corresponding to the keyword and the keyword representing the version information are used as the interface information of the same interface.
S305, the interface server determines a target test template program from the test template programs according to the interface type of the target interface and generates test parameters according to the interface parameters.
At this step, the manner of determining the target test template program is described in detail in S205, and is not described herein again.
When the test parameters are generated according to the interface parameters, any one of the following modes can be adopted: and generating the test parameters in the parameter range according to the parameter range of the input parameters. And generating the test parameters out of the parameter range according to the parameter range of the input parameters. And generating the test parameters of the boundary values according to the parameter range of the input parameters.
The test parameters within the parameter range are generated for forward test, the test parameters outside the parameter range are generated for abnormal test, and the test parameters for generating the boundary value are used for boundary value test. The specific selection of which test mode can be determined according to the test instruction.
S306, the interface server operates the target test template program after inputting the test parameters into the target test template program so as to obtain the test result of the target interface.
In this step, when obtaining the test result of the target interface, the output data of the target test template program after the test parameters are input is obtained first, and then the output data is compared with the output parameters of the target interface, and the test state of the target interface is output according to the comparison result.
For example: the output parameter of the target test template program is used for representing address classification, and the specific data of the parameter is '1' or '2'. Wherein "1" represents an urban area and "2" represents a suburban area. After the target test template program is actually run, the output parameter is "1", that is, the data of the actual output parameter is consistent with the data of the specified output parameter, the interface passes the test, and the test state is set to pass the test.
S307, the interface server receives the query instruction sent by the client.
In this step, the query instruction includes the identifier of the target engineering resource, and the interface server analyzes the query instruction to obtain the identifier of the target engineering resource.
S308, the interface server returns the interface information and the test state of each interface in the target engineering resource to the client.
In this step, after acquiring the interface information of each interface in the target engineering resource in S304 and the test state of each interface in S306, the interface server stores the interface information of each interface in the target engineering resource and the test state of each interface locally, and after receiving a query instruction for querying each interface in the target engineering resource, returns the interface information and the test state of each interface in the target engineering resource to the client, so that the client can display the interface information and the test state of each interface in the target engineering resource.
S309, the interface server receives the export instruction sent by the client.
In this step, the query instruction includes an identifier of the target interface, and the interface server parses the export instruction after receiving the export instruction sent by the client, so as to obtain the identifier of the target interface.
S310, the interface server obtains interface information of the target interface and a preset interface document template.
In this step, the interface server selects interface information of the target interface from interface information of each interface in the target engineering resource stored locally, and reads an interface document template stored locally.
S311, the interface server sends the interface information of the target interface and the preset interface document template to the client.
And S312, the client generates an interface document according to the interface information and the preset interface document template.
In this step, the client fills the interface information into a preset interface document template to generate an interface document.
In the technical scheme, after a developer submits a code to a development server and deploys a version package, the latest relevant information of each interface of the project can be displayed by accessing the interface server through a client, whether the test state of the interface is normal or not can be displayed, meanwhile, the developer can export an interface document through the operation page, the process of writing the document by the developer is omitted, the export document is in one-to-one correspondence with the code, and the problem that the developer wrote the interface document by himself carelessly (for example, the hand filling parameters are not normally filled) is solved.
S313, the interface server sends the update information of the interface of the target engineering resource to the client.
In the step, if the version number of the interface is detected to be updated, the information is automatically and synchronously sent to each client, and the interface information is timely synchronized to the client used by the corresponding project-related personnel.
S314, the interface server sends the test state of the interface of the target engineering resource to the client.
In this step, the interface server sends the test state to the client used by the corresponding project related personnel after running the target test template program to obtain the test state of the target interface.
In the technical scheme, after the interface automatic test task is configured, when the test task reaches the starting condition, the interface automatic test can be started, the test result of the interface can be automatically output to the client used by the corresponding project related personnel after the test is finished, whether the state of the interface is normal or not can be known in time, and the abnormity of the related interface can be adjusted in time.
As shown in fig. 5, an embodiment of the present application provides an interface testing apparatus 500, where the apparatus 500 includes:
an obtaining module 401, configured to extract an identifier of a target engineering resource and an identifier of a target interface from a test instruction;
a sending and receiving module 402, configured to send a download request to the development server, and receive a target engineering resource of the development server; the downloading request is generated according to the identification of the target engineering resource;
a processing module 403, configured to extract interface information of a plurality of interfaces from the target engineering resource; the interface information comprises an interface type and interface parameters;
the processing module 403 is further configured to determine a target test template program from the test template programs according to the interface type of the target interface, and generate test parameters according to the interface parameters;
the processing module 403 is further configured to run the target test template program after inputting the test parameters into the target test template program, so as to obtain a test result of the target interface.
In an embodiment, the processing module 403 is specifically configured to:
reading a source code under a storage path of an interface code in a target engineering resource, and partitioning the source code to obtain target codes of a plurality of areas;
aiming at the target code of each region, identifying the target code to obtain a plurality of keywords and contents corresponding to the keywords;
and when the keywords and the contents corresponding to the keywords meet the preset interface identification conditions, determining the interface information of the interfaces according to the keywords and the contents corresponding to the keywords.
In an embodiment, the processing module 403 is specifically configured to:
for each line of target codes, performing annotation information identification on the target codes, and determining a target character string template from character string templates corresponding to the keywords according to the annotation information;
extracting a character string from the target code, and comparing the similarity of the extracted character string with a target character string template;
and when the similarity meets the keyword recognition condition, taking the extracted character string as a keyword, and extracting the character string around the keyword as the content corresponding to the keyword.
In an embodiment, the plurality of keywords and the content corresponding to the keywords satisfy a preset interface identification condition, and specifically include at least one of the following:
when the key words and the content corresponding to the key words represent the interface address;
when the keywords and the content corresponding to the keywords represent an interface request mode;
when the keyword and the content corresponding to the keyword represent the port number;
when the keywords and the content corresponding to the keywords represent input parameters;
when the keyword and the content corresponding to the keyword represent the output parameter;
when the keywords and the content corresponding to the keywords represent abnormal output;
when the keyword and the content corresponding to the keyword represent the status code description information;
when the keyword and the content corresponding to the keyword represent version information.
In an embodiment, the processing module 403 is specifically configured to:
the method comprises the steps of taking keywords representing interface addresses and content corresponding to the keywords, keywords representing interface request modes and content corresponding to the keywords, keywords representing interface numbers and content corresponding to the keywords, keywords representing input parameters and content corresponding to the keywords, keywords representing output parameters and content corresponding to the keywords, keywords representing abnormal output and content corresponding to the keywords, keywords representing state code description information and content corresponding to the keywords representing version information and content corresponding to the keywords as interface information of the same interface.
In an embodiment, the processing module 403 is specifically configured to execute any one of the following:
generating a test parameter within the parameter range according to the parameter range of the interface parameter;
generating a test parameter outside the parameter range according to the parameter range of the interface parameter;
and generating the test parameters of the boundary values according to the parameter range of the interface parameters.
In an embodiment, the processing module 403 is specifically configured to:
after receiving the update information of the interface in the target engineering resource sent by the client, generating a test instruction according to the target engineering resource;
or
And generating a test instruction when the time interval from the last test reaches a test period.
In an embodiment, the processing module 403 is specifically configured to:
acquiring output data of a target test template program after test parameters are input;
and comparing the output data with the output parameters of the target interface, and outputting the test state of the target interface according to the comparison result.
In an embodiment, the sending and receiving module 402 is specifically configured to:
receiving a query instruction sent by a client; wherein the query instruction comprises a target engineering resource;
and returning the interface information and the test state of each interface in the target engineering resource to the client.
In an embodiment, the sending and receiving module 402 is specifically configured to:
receiving a derivation instruction sent by a client; wherein the query instruction comprises a target interface;
acquiring interface information of a target interface and a preset interface document template;
and sending the interface information of the target interface and the preset interface document template to the client so that the client generates an interface document according to the interface information and the preset interface document template.
As shown in fig. 6, an embodiment of the present application provides an interface server 500, where the interface server 500 includes a memory 501 and a processor 502.
Wherein the memory 501 is used for storing computer instructions executable by the processor;
the processor 502, when executing computer instructions, performs the steps of the methods in the embodiments described above. Reference may be made in particular to the description relating to the method embodiments described above.
Alternatively, the memory 501 may be separate or integrated with the processor 502. When the memory 501 is provided separately, the interface server further includes a bus for connecting the memory 501 and the processor 502.
The embodiment of the present application further provides a computer-readable storage medium, in which computer instructions are stored, and when the processor executes the computer instructions, the steps in the method in the foregoing embodiment are implemented.
Embodiments of the present application further provide a computer program product, which includes computer instructions, and when the computer instructions are executed by a processor, the computer instructions implement the steps of the method in the above embodiments.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (11)

1. An interface test method, which is applied to an interface server, is characterized in that the method comprises the following steps:
extracting the identification of the target engineering resource and the identification of the target interface from the test instruction;
sending a downloading request to a development server, and receiving the target engineering resource sent by the development server; wherein the download request is generated according to the identification of the target engineering resource;
extracting interface information of a plurality of interfaces from the target engineering resources; the interface information comprises an interface type and interface parameters;
determining a target test template program from the test template programs according to the interface type of the target interface, and generating test parameters according to the interface parameters;
and after the test parameters are input into the target test template program, operating the target test template program to obtain a test result of the target interface.
2. The method according to claim 1, wherein extracting interface information of a plurality of interfaces from engineering resources specifically comprises:
reading a source code under a storage path of an interface code in the target engineering resource, and partitioning the source code to obtain target codes of a plurality of areas;
aiming at the target code of each region, identifying the target code to obtain a plurality of keywords and contents corresponding to the keywords;
and when the plurality of keywords and the content corresponding to the keywords meet a preset interface identification condition, determining the interface information of the interface according to the plurality of keywords and the content corresponding to the keywords.
3. The method according to claim 2, wherein identifying the target code to obtain a plurality of keywords and contents corresponding to the keywords comprises:
for each line of target codes, performing annotation information identification on the target codes, and determining a target character string template from character string templates corresponding to the keywords according to the annotation information;
extracting character strings of the target code, and comparing the similarity of the extracted character strings with the target character string template;
and when the similarity meets a keyword recognition condition, taking the extracted character string as the keyword, and extracting the character string around the keyword as the content corresponding to the keyword.
4. The method according to claim 2, wherein the plurality of keywords and the content corresponding to the keywords satisfy a preset interface recognition condition, and specifically comprises:
when the keyword and the content corresponding to the keyword represent an interface address;
when the keyword and the content corresponding to the keyword represent an interface request mode;
when the keyword and the content corresponding to the keyword represent an interface port number;
when the keyword and the content corresponding to the keyword represent input parameters;
when the keyword and the content corresponding to the keyword represent output parameters;
when the keyword and the content corresponding to the keyword represent abnormal output;
when the keyword and the content corresponding to the keyword represent state code description information;
and when the keyword and the content corresponding to the keyword represent version information.
5. The method according to claim 4, wherein determining the interface information of the plurality of interfaces according to the plurality of keywords and the content corresponding to the keywords specifically comprises:
and taking the keywords representing the interface address and the content corresponding to the keywords, the keywords representing the interface request mode and the content corresponding to the keywords, the keywords representing the interface port number and the content corresponding to the keywords, the keywords representing the input parameters and the content corresponding to the keywords, the keywords representing the output parameters and the content corresponding to the keywords, the keywords representing abnormal output and the content corresponding to the keywords, the keywords representing the state code description information and the content corresponding to the keywords representing the version information and the content corresponding to the keywords as the interface information of the same interface.
6. The method according to claim 4, wherein generating test parameters according to the interface parameters specifically includes any one of:
generating a test parameter within the parameter range according to the parameter range of the input parameter;
generating a test parameter outside the parameter range according to the parameter range of the input parameter;
and generating a test parameter of the boundary value according to the parameter range of the input parameter.
7. The method according to any one of claims 1 to 5, further comprising:
and after receiving the update information of the target engineering resource sent by the client, generating the test instruction according to the identifier of the target engineering resource.
8. The method according to any one of claims 1 to 5, wherein the step of running the target test template program after inputting the test parameters into the target test template program to obtain the test result of the target interface specifically comprises:
acquiring output data of the target test template program after the test parameters are input;
and comparing the output data with the output parameters of the target interface, and outputting the test state of the target interface according to the comparison result.
9. The method of claim 8, further comprising:
receiving a query instruction sent by a client; wherein the query instruction includes an identification of a target engineering resource;
and returning the interface information and the test state of each interface in the target engineering resource to the client.
10. The method of claim 9, further comprising:
receiving a derivation instruction sent by a client; wherein the query instruction includes an identification of a target interface;
acquiring interface information of the target interface and a preset interface document template;
and sending the interface information of the target interface and a preset interface document template to the client so that the client generates an interface document according to the interface information and the preset interface document template.
11. A server, comprising: a memory, a processor;
a memory; for storing computer instructions executable by the processor;
wherein the processor, when executing the computer instructions, is configured to implement the interface testing method of any one of claims 1 to 10.
CN202110883480.0A 2021-08-03 2021-08-03 Interface test method and device Pending CN113326208A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110883480.0A CN113326208A (en) 2021-08-03 2021-08-03 Interface test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110883480.0A CN113326208A (en) 2021-08-03 2021-08-03 Interface test method and device

Publications (1)

Publication Number Publication Date
CN113326208A true CN113326208A (en) 2021-08-31

Family

ID=77426847

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110883480.0A Pending CN113326208A (en) 2021-08-03 2021-08-03 Interface test method and device

Country Status (1)

Country Link
CN (1) CN113326208A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116680171A (en) * 2023-05-22 2023-09-01 前海飞算云智软件科技(深圳)有限公司 Test method, device, storage medium and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102096631A (en) * 2009-12-11 2011-06-15 华为技术有限公司 Interface testing method and device
CN109446068A (en) * 2018-09-26 2019-03-08 平安健康保险股份有限公司 Interface test method, device, computer equipment and storage medium
CN109446071A (en) * 2018-09-26 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, interface test device, electronic equipment and storage medium
CN110096434A (en) * 2019-03-28 2019-08-06 咪咕文化科技有限公司 A kind of interface test method and device
CN112540924A (en) * 2020-12-15 2021-03-23 中国平安人寿保险股份有限公司 Interface automation test method, device, equipment and storage medium
CN112597018A (en) * 2020-12-22 2021-04-02 未来电视有限公司 Interface test case generation method, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102096631A (en) * 2009-12-11 2011-06-15 华为技术有限公司 Interface testing method and device
CN109446068A (en) * 2018-09-26 2019-03-08 平安健康保险股份有限公司 Interface test method, device, computer equipment and storage medium
CN109446071A (en) * 2018-09-26 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, interface test device, electronic equipment and storage medium
CN110096434A (en) * 2019-03-28 2019-08-06 咪咕文化科技有限公司 A kind of interface test method and device
CN112540924A (en) * 2020-12-15 2021-03-23 中国平安人寿保险股份有限公司 Interface automation test method, device, equipment and storage medium
CN112597018A (en) * 2020-12-22 2021-04-02 未来电视有限公司 Interface test case generation method, device, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116680171A (en) * 2023-05-22 2023-09-01 前海飞算云智软件科技(深圳)有限公司 Test method, device, storage medium and electronic equipment
CN116680171B (en) * 2023-05-22 2024-03-08 前海飞算云智软件科技(深圳)有限公司 Test method, device, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN107656874B (en) Interface testing method and device, simulation baffle and system
CN107844421B (en) Interface testing method and device, computer equipment and storage medium
WO2018000998A1 (en) Interface generation method, apparatus and system
CN107145784B (en) Vulnerability scanning method and device and computer readable medium
EP4040311A1 (en) Utilizing machine learning and natural language processing to extract and verify vaccination data
CN111240653A (en) Interface document generation method and device and readable storage medium
CN110990053A (en) Method for creating and using machine learning scheme template and device
CN111679975A (en) Document generation method and device, electronic equipment and medium
CN108804315B (en) Test method and device applied to dynamic development, electronic equipment and storage medium
CN107341106B (en) Application compatibility detection method, development terminal and storage medium
CN113326208A (en) Interface test method and device
CN111181805A (en) Micro-service test baffle generation method and system based on test case
CN113434395A (en) Automatic generation method, device, equipment and medium of test case
CN113268245A (en) Code analysis method, device and storage medium
CN111859076A (en) Data crawling method and device, computer equipment and computer readable storage medium
CN111309371A (en) Query method and device
US20160170718A1 (en) Rte code generating method and apparatus performing the same
CN116483344A (en) Code generation method and device, terminal equipment and computer readable storage medium
CN110716866A (en) Code quality scanning method and device, computer equipment and storage medium
CN114386853A (en) Data auditing processing method, device and equipment based on universal auditing model
CN114281688A (en) Codeless or low-code automatic case management method and device
CN109086145B (en) Data generation method and device and computer storage medium
CN113742559A (en) Keyword detection method and device, electronic equipment and storage medium
CN113885876A (en) Parameter checking method, device, storage medium and computer system
CN111695031A (en) Label-based searching method, device, server and storage medium

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210831

RJ01 Rejection of invention patent application after publication