CN109446068B - Interface test method, device, computer equipment and storage medium - Google Patents

Interface test method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN109446068B
CN109446068B CN201811123485.8A CN201811123485A CN109446068B CN 109446068 B CN109446068 B CN 109446068B CN 201811123485 A CN201811123485 A CN 201811123485A CN 109446068 B CN109446068 B CN 109446068B
Authority
CN
China
Prior art keywords
interface
test
tested
data
interface test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811123485.8A
Other languages
Chinese (zh)
Other versions
CN109446068A (en
Inventor
贾江丽
里志仁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Health Insurance Company of China Ltd
Original Assignee
Ping An Health Insurance Company of China 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 Ping An Health Insurance Company of China Ltd filed Critical Ping An Health Insurance Company of China Ltd
Priority to CN201811123485.8A priority Critical patent/CN109446068B/en
Publication of CN109446068A publication Critical patent/CN109446068A/en
Application granted granted Critical
Publication of CN109446068B publication Critical patent/CN109446068B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

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

Abstract

The application relates to an interface testing method, an interface testing device, computer equipment and a storage medium. The method involves interface automation, including: receiving an interface test request, and determining an interface to be tested according to the interface test request; acquiring an interface test template corresponding to an interface to be tested; updating test parameters in the interface test template according to the interface test request to obtain an interface test case; and automatically testing the interface to be tested through the interface test case to obtain an interface test result. According to the interface test method, in the interface test process, the test template corresponding to the interface to be tested is updated according to the interface test request, so that the interface test case meeting the interface test request can be obtained rapidly, and the interface automation test is directly carried out through the interface test case, so that the efficiency of the interface test is improved effectively.

Description

Interface test method, device, computer equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an interface testing method, an apparatus, a computer device, and a storage medium.
Background
With the development of computer technology, more and more businesses are implemented through computer programs, such as financial services, social services, online shopping, etc., while data interactions between various business services, such as interactions between business systems and users, are implemented by calling predefined interfaces. To ensure that the various interfaces can meet the requirements for data interaction, the interfaces need to be tested after development is completed.
At present, a special developer usually extracts interface information according to interface definition, and compiles corresponding script codes according to data relation to carry out interface test. However, for increasingly complex service systems, the number of interfaces involved is huge, and the efficiency of interface testing is greatly affected by writing script codes one by one for interface testing.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an interface testing method, apparatus, computer device, and storage medium that can improve the efficiency of interface testing.
An interface testing method, the method comprising:
receiving an interface test request, and determining an interface to be tested according to the interface test request;
acquiring an interface test template corresponding to an interface to be tested;
updating test parameters in the interface test template according to the interface test request to obtain an interface test case;
and automatically testing the interface to be tested through the interface test case to obtain an interface test result.
In one embodiment, the test parameters include interface type, execution mode, test data, and result verification data; updating test parameters in an interface test template according to an interface test request, and obtaining an interface test case comprises the following steps:
Extracting interface type, execution mode, test data and result verification data from the interface test request;
the interface test template is configured through the interface type, the execution mode, the test data and the result verification data;
and generating an interface test case according to the configured interface test template.
In one embodiment, the step of automatically testing the interface to be tested through the interface test case to obtain the interface test result includes:
calling an interface to be tested;
carrying out automatic test on the interface to be tested through the interface test case to obtain an interface execution result;
and comparing the interface execution result with the result verification data to obtain an interface test result.
In one embodiment, before the step of obtaining the interface test template preset corresponding to the interface to be tested, the method further includes:
inquiring an interface code corresponding to an interface to be tested;
identifying a data flow path of an interface to be tested according to the interface code;
determining corresponding path dividing conditions according to the data flow paths;
and generating test parameters according to the path dividing conditions, and constructing an interface test template according to the test parameters.
In one embodiment, the interface test request comprises a flow test request; after the step of obtaining the interface test template corresponding to the interface to be tested, the method further comprises the following steps:
Combining interface test templates corresponding to the interfaces to be tested according to the flow test requests to obtain flow test templates;
and taking the flow test template as an interface test template.
In one embodiment, after the step of obtaining the interface test case, the method further includes:
inquiring a data encryption form corresponding to the interface to be tested, wherein the data encryption form records an encryption data type and an encryption mode corresponding to the encryption data type;
according to the type of the encrypted data and the encryption mode, encrypting and packaging the interface test cases to obtain the encrypted and packaged interface test cases;
and taking the encrypted and packaged interface test case as an interface test case.
In one embodiment, after the step of obtaining the interface test result, the method further includes:
when the interface test result is abnormal, acquiring a test intermediate variable in the automatic test process;
comparing the variable value of the test intermediate variable with a preset standard intermediate variable;
when the variable value comparison results are inconsistent, marking the code segment corresponding to the test intermediate variable as an error code, and sending out an error reporting prompt message.
An interface testing apparatus, the apparatus comprising:
The interface to be tested determining module is used for receiving the interface testing request and determining the interface to be tested according to the interface testing request;
the test template acquisition module is used for acquiring a preset interface test template corresponding to the interface to be tested;
the test case acquisition module is used for updating the test parameters in the interface test template according to the interface test request to obtain an interface test case;
and the interface test module is used for automatically testing the interface to be tested through the interface test case to obtain an interface test result.
A computer device comprising a memory storing a computer program and a processor which when executing the computer program performs the steps of:
receiving an interface test request, and determining an interface to be tested according to the interface test request;
acquiring an interface test template corresponding to an interface to be tested;
updating test parameters in the interface test template according to the interface test request to obtain an interface test case;
and automatically testing the interface to be tested through the interface test case to obtain an interface test result.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Receiving an interface test request, and determining an interface to be tested according to the interface test request;
acquiring an interface test template corresponding to an interface to be tested;
updating test parameters in the interface test template according to the interface test request to obtain an interface test case;
and automatically testing the interface to be tested through the interface test case to obtain an interface test result.
According to the interface test method, the device, the computer equipment and the storage medium, the interface to be tested is determined according to the received interface test request, the interface test template corresponding to the interface to be tested is obtained, the test parameters of the obtained interface test template are updated through the interface test request to obtain the interface test case, and finally the interface to be tested is automatically tested through the interface test case to obtain the interface test result. In the interface test process, the test template corresponding to the interface to be tested is updated according to the interface test request, so that the interface test case meeting the interface test request can be obtained rapidly, and the interface automation test is carried out directly through the interface test case, so that the efficiency of the interface test is improved effectively.
Drawings
FIG. 1 is an application scenario diagram of an interface testing method in one embodiment;
FIG. 2 is a flow chart of an interface testing method in one embodiment;
FIG. 3 is a flow chart of the steps for building an interface test template in one embodiment;
FIG. 4 is a flow chart of an interface testing method according to another embodiment;
FIG. 5 is a block diagram of an interface test apparatus according to one embodiment;
fig. 6 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The interface testing method provided by the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The terminal 102 sends an interface test request to the server 104, the server 104 determines an interface to be tested according to the interface test request after receiving the interface test request, acquires a corresponding preset interface test template from a database according to the interface to be tested, updates test parameters in the acquired interface test template according to the interface test request to obtain an interface test case, and finally automatically tests the interface to be tested through the interface test case to obtain an interface test result. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smartphones, tablet computers, and portable wearable devices, and the server 104 may be implemented by a stand-alone server or a server cluster composed of a plurality of servers.
In one embodiment, as shown in fig. 2, an interface testing method is provided, and the method is applied to the server 104 in fig. 1 for illustration, and includes the following steps:
step S201: and receiving an interface test request, and determining an interface to be tested according to the interface test request.
The interface test request may be a message sent by the terminal 102 for performing an interface automation test, which may include information of an interface to be tested, such as an interface name, an interface number, and identification information of an interface to be tested. After receiving the interface test request, the server 104 extracts the interface information to be tested from the interface test request, and determines the interface to be tested.
Step S203: and acquiring an interface test template corresponding to the interface to be tested.
The interface test template is a data file corresponding to various interfaces and used for recording test parameters, and specifically may be an Excel table file, a Txt text file or an Xml (Extensible Markup Language ) file, which may include, but is not limited to, interface test data such as an interface test serial number, an interface name, test parameters, a verification result, an execution mode, a variable, and the like. Different test cases can be obtained by configuring test parameters in the interface test template. The different types of the interfaces can correspond to different test parameters, such as the interfaces of Post and Get types, which correspond to different execution modes, and the corresponding test parameters can be set in a targeted manner by configuring the corresponding interface test templates for the different interfaces, so that other intermediate processing is not needed, and the test efficiency is improved. After the interface to be tested is determined, a corresponding interface test template can be inquired and obtained according to the interface identification information such as the type, the name, the test serial number and the like of the interface to be tested.
Step S205: and updating the test parameters in the interface test template according to the interface test request to obtain an interface test case.
The interface test case is a test file for performing a test task on the interface, and related tests on the interface can be realized by executing the interface test case. After the interface test template is obtained, the test parameters in the interface test template can be updated according to the test request parameters included in the interface test request, so that the required interface test case is obtained. In a specific application, the test parameters include interface type, execution mode, test data and verification result, firstly, the test request parameters are extracted from the interface test request, each test parameter in the interface test template is configured one by one according to the test request parameters, and after the configuration is completed, the corresponding interface test case is generated according to the updated test template.
Step S207: and automatically testing the interface to be tested through the interface test case to obtain an interface test result.
After the interface test case is obtained, the interface test case is executed to realize automatic test of the interface to be tested, and finally an interface test result is obtained. In specific application, the obtained interface test case can be executed through a TestNG test suite, an Ant script or a Jenkins tool to call a corresponding interface to be tested and perform automatic test to obtain an interface execution result, and finally the result execution result is compared with preset result verification data to obtain an interface test result, so that the rapid automatic test of the interface to be tested is realized.
According to the interface test method, the interface to be tested is determined according to the received interface test request, the interface test template corresponding to the interface to be tested is obtained, the test parameters of the obtained interface test template are updated through the interface test request to obtain the interface test case, and finally the interface to be tested is automatically tested through the interface test case to obtain the interface test result. In the interface test process, the test template corresponding to the interface to be tested is updated according to the interface test request, so that the interface test case meeting the interface test request can be obtained rapidly, and the interface automation test is carried out directly through the interface test case, so that the efficiency of the interface test is improved effectively.
In one embodiment, the test parameters include interface type, execution mode, test data, and result verification data; updating test parameters in an interface test template according to an interface test request, and obtaining an interface test case comprises the following steps: extracting interface type, execution mode, test data and result verification data from the interface test request; the interface test template is configured through the interface type, the execution mode, the test data and the result verification data; and generating an interface test case according to the configured interface test template.
In this embodiment, the test parameters include an interface type, an execution mode, test data and result verification data, where the interface type includes Get type, is used to obtain information, and is used to query data in multiple ways; post type for submitting data to the specified resource location; put type, used for uploading the latest data, namely, carry on the data updating; and Delete type for data deletion. The execution mode corresponds to the interface type, for example, for a Get type interface, the execution mode is Get, and for a Post type, the execution mode corresponds to Post. The test data is test data, and is used as interface input data in test, and the interface processes the test data; the result verification data is used for verifying the execution result of the interface to obtain the interface test result, so as to judge whether the interface meets the requirement.
After the interface test template is obtained, the corresponding test parameters are extracted from the interface test request, and the interface test template is correspondingly configured through the test parameters. Specifically, when the test parameters in the interface test template are empty, the test parameters such as the interface type, the execution mode, the test data, the result verification data and the like can be directly added into the interface test template; if the test parameters in the interface test template are default parameters, modifying the default parameters in the interface test template according to the test parameters extracted from the interface test request so as to realize configuration updating of the interface test template. After the configured interface test template is obtained, a corresponding interface test case is generated, and the interface test case can be used for interface automation test. The corresponding interface test cases can be obtained rapidly by carrying out configuration updating on the corresponding interface test templates through the interface test requests, so that the processing efficiency of the interface test is improved.
In one embodiment, the step of automatically testing the interface to be tested through the interface test case to obtain the interface test result includes: calling an interface to be tested; carrying out automatic test on the interface to be tested through the interface test case to obtain an interface execution result; and comparing the interface execution result with the result verification data to obtain an interface test result.
In this embodiment, after obtaining an interface test case corresponding to an interface test request, an interface to be tested is called, specifically, the interface test case may be executed by using a TestNG test suite, an Ant script, or a Jenkins tool, and a corresponding interface to be tested is called by using the interface test case, and further, an automated test is performed on the interface to be tested according to the interface test, so as to obtain an interface execution result. After the interface to be tested is tested through the interface test case, the interface execution result is obtained, and then the interface execution result is compared with result verification data in the interface test request, so that the interface test result is obtained. In addition, the result verification data can be derived from the interface test request in advance, a corresponding result verification data set is constructed, and the interface execution result is compared with the result verification data in the result verification data set to obtain the interface test result.
Generally, the interface test is a functional test, and by comparing the interface execution result with preset result verification data, whether the interface test result meets the interface functional requirement can be determined according to the comparison result. In specific application, the success rate of the interface test can be counted for the plurality of times of executing different interface test cases, and the problem of deviation of the interface test result caused by the abnormal interface execution result can be avoided.
In one embodiment, as shown in fig. 3, before the step of obtaining the interface test template preset corresponding to the interface to be tested, the method further includes a step of constructing the interface test template, specifically including:
step S301: and inquiring an interface code corresponding to the interface to be tested.
In this embodiment, the interface test template is preset according to different interfaces, and before the interface test is performed on the interface to be tested, the interface code corresponding to the interface to be tested is queried. The interface code is an interface code program file written by a developer, and the data stream processing information, such as a data stream path, of the interface to be tested can be obtained by analyzing the interface code.
Step S303: and identifying the data flow path of the interface to be tested according to the interface code.
The data flow path is various branches of data processing of the interface, and can be identified according to the obtained interface codes. Specifically, the data flow path identification may be performed according to the feature code in the interface code, for example, IF statements commonly used in the C language for judging branches. In addition, generally, for program code with complex functions, a developer writes the function interpretation fields of the corresponding code segments in the code, and can identify the data flow path based on the function interpretation fields hidden in the interface code.
Step S305: and determining corresponding path dividing conditions according to the data flow paths.
After the data flow paths are determined, the path dividing conditions of the data flow paths are further determined. For example, after splitting a judging operation into 2 data flow paths, the judging condition is a path dividing condition corresponding to the 2 data flow paths. And obtaining the path dividing condition of the interface to be tested by traversing and analyzing each data flow path.
Step S307: and generating test parameters according to the path dividing conditions, and constructing an interface test template according to the test parameters.
After the path dividing condition is obtained, corresponding test parameters are generated according to the path dividing condition, and corresponding interface test templates are constructed according to the generated test parameters. For example, for different types of interfaces such as Get type, post type, put type, and Delete type, 4 data flow paths may be divided, i.e., the interface type may be used as a test parameter. When the method is applied specifically, the path dividing conditions can be screened to control the number of the path dividing conditions, and the appropriate path dividing conditions are extracted from the number of the path dividing conditions to generate corresponding test parameters.
In the embodiment, the interface code of the interface to be tested is queried to generate the test parameters, and the corresponding interface test template is constructed according to the obtained test parameters, so that the obtained interface test template is closely connected with the interface to be tested, the pertinence is strong, and the processing efficiency of the interface automatic test of the interface test case generated by the interface test template can be effectively improved.
In one embodiment, the interface test request comprises a flow test request; after the step of obtaining the interface test template corresponding to the interface to be tested, the method further comprises the following steps: combining interface test templates corresponding to the interfaces to be tested according to the flow test requests to obtain flow test templates; and taking the flow test template as an interface test template.
For interfaces with relatively independent structures and functions, relatively independent interface tests can be performed; and for interfaces in a series of flow processes, a plurality of interfaces are involved in the flow processes, and when the interfaces are tested, the interfaces involved in the flow processes can be tested in series so as to improve the efficiency of testing the flow interfaces. Specifically, when the interface test request that the terminal 102 may send includes a flow test request, the interface test request received by the server 104 includes each interface to be tested in the flow, after the interface test templates corresponding to each interface to be tested are obtained by querying, each interface test template is combined according to the flow test request, for example, in a series of flows including underwriting, premium calculation, policy generation, and the like in an insurance business flow, different interfaces are involved, and the interface test templates corresponding to each interface may be combined according to the flow, so as to obtain the flow test template corresponding to the flow. And finally, the flow test template can be used as an interface test template, test parameter configuration is carried out on the flow test template according to a flow test request to obtain a flow test case, and flow interface test is carried out through the flow test case to obtain an interface test result.
In this embodiment, when testing the flow interface, the interface test templates corresponding to the interfaces to be tested can be combined according to the flow requirements to obtain the flow test templates, and the subsequent test operation is performed through the flow test templates, so that the efficiency of testing the closely-related flow interfaces is improved.
In one embodiment, after the step of obtaining the interface test case, the method further includes: inquiring a data encryption form corresponding to the interface to be tested, wherein the data encryption form records an encryption data type and an encryption mode corresponding to the encryption data type; according to the type of the encrypted data and the encryption mode, encrypting and packaging the interface test cases to obtain the encrypted and packaged interface test cases; and taking the encrypted and packaged interface test case as an interface test case.
In the present embodiment, for an interface to be tested involving encrypted data processing, a data encryption function is provided to ensure data security. Specifically, after the interface test case is obtained, inquiring a data encryption form corresponding to the interface to be tested, encrypting and packaging the interface test case according to the encrypted data type and the corresponding encryption mode recorded in the data encryption form, and automatically testing the interface to be tested through the interface test case after encrypting and packaging. The data encryption form can be preset according to each interface, and the set encryption data type and the corresponding encryption mode are set according to the service application requirements of the interface so as to meet the actual application requirements. By encrypting and packaging the interface test cases, the data security can be effectively ensured in the subsequent automatic test process.
In one embodiment, after the step of obtaining the interface test result, the method further comprises: when the interface test result is abnormal, acquiring a test intermediate variable in the automatic test process; comparing the variable value of the test intermediate variable with a preset standard intermediate variable; when the variable value comparison results are inconsistent, marking the code segment corresponding to the test intermediate variable as an error code, and sending out an error reporting prompt message.
In this embodiment, when an interface test result is detected to be abnormal, the interface error may be tracked and located, so as to prompt a developer, so that the developer can quickly process the error code. Specifically, when the abnormality of the test interface is detected, if the result does not meet the requirement of the interface function, test intermediate variables in the automatic test process are obtained, variable value comparison is carried out on each test intermediate variable and a preset standard intermediate variable in sequence, after the variable value comparison is carried out on each test intermediate variable in a traversing manner, error codes can be positioned, and meanwhile, error reporting prompt information is sent out to remind a developer of carrying out error code processing. When the variable value comparison result is inconsistent, the code segment corresponding to the inconsistent test intermediate variable is marked as an error code, such as adding error identification information, and meanwhile, an error reporting prompt message, such as an error reporting prompt window or an error reporting voice message, is generated and sent.
In one embodiment, as shown in fig. 4, an interface testing method is provided, which is applied to the server 104 shown in fig. 1 for illustration, and specifically includes:
step S401: receiving an interface test request, and determining an interface to be tested according to the interface test request;
step S402: and acquiring an interface test template corresponding to the interface to be tested.
In this embodiment, the server 104 receives an interface test request sent by the terminal 102, extracts identification information of an interface to be tested from the interface test request, determines the interface to be tested according to the identification information, and obtains an interface test template corresponding to the interface to be tested from a preset test template database. The interface test templates are stored in a test template database preset by the server 104, and are data files corresponding to various interfaces and used for recording test parameters, and different test cases can be obtained by configuring the test parameters in the interface test templates.
Step S403: judging whether the interface test request is a flow test request, if so, executing step S404; otherwise, step S406 is entered;
step S404: combining interface test templates corresponding to the interfaces to be tested according to the flow test requests to obtain flow test templates;
Step S405: and taking the flow test template as an interface test template.
In this embodiment, whether the interface test request is a flow test request is further detected, if yes, it is indicated that the interface to be tested is a closely-related flow interface, and according to the flow test request, the interface test templates corresponding to the interfaces to be tested are combined to obtain a flow test template, and the flow test template is used as the interface test template to perform subsequent automated interface test processing.
Step S406: extracting interface type, execution mode, test data and result verification data from the interface test request;
step S407: the interface test template is configured through the interface type, the execution mode, the test data and the result verification data;
step S408: and generating an interface test case according to the configured interface test template.
After the interface test template is obtained, the corresponding test parameters are extracted from the interface test request, and the interface test template is correspondingly configured through the test parameters. In this embodiment, the interface type, the execution mode, the test data and the result verification data are extracted from the interface test request, the interface test template is configured through the interface type, the execution mode, the test data and the result verification data, and finally the interface test case is generated according to the configured interface test template. The corresponding interface test cases can be obtained rapidly by carrying out configuration updating on the corresponding interface test templates through the interface test requests, so that the processing efficiency of the interface test is improved.
Step S409: and carrying out encryption packaging treatment on the interface test case according to a preset encryption configuration rule.
In the present embodiment, for an interface to be tested involving encrypted data processing, a data encryption function is provided to ensure data security. Specifically, after the interface test case is obtained, inquiring a data encryption form corresponding to the interface to be tested, encrypting and packaging the interface test case according to the encrypted data type and the corresponding encryption mode recorded in the data encryption form, and automatically testing the interface to be tested through the interface test case after encrypting and packaging.
Step S410: automatically testing an interface to be tested through an interface test case to obtain an interface test result;
step S411: and when the interface test result is abnormal, performing error code positioning.
After the interface test case is obtained, the interface to be tested is automatically tested through the interface test case, and an interface test result is obtained. Specifically, it may include: calling an interface to be tested; carrying out automatic test on the interface to be tested through the interface test case to obtain an interface execution result; and comparing the interface execution result with the result verification data to obtain an interface test result. After the interface test result is obtained, the interface test result can be detected, and if the detection result is abnormal, error code positioning is performed. Specifically, when the interface test result is abnormal, acquiring a test intermediate variable of an automatic test process; comparing the variable value of the test intermediate variable with a preset standard intermediate variable; when the variable value comparison results are inconsistent, marking the code segment corresponding to the test intermediate variable as an error code, and sending out an error reporting prompt message.
It should be understood that, although the steps in the flowcharts of fig. 2-4 are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in fig. 2-4 may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor do the order in which the sub-steps or stages are performed necessarily occur sequentially, but may be performed alternately or alternately with at least a portion of the sub-steps or stages of other steps or steps.
In one embodiment, as shown in fig. 5, there is provided an interface test apparatus comprising: the device comprises an interface to be tested determining module 501, a test template obtaining module 503, a test case obtaining module 505 and an interface testing module 507, wherein:
the interface to be tested determining module 501 is configured to receive an interface test request, and determine an interface to be tested according to the interface test request;
A test template obtaining module 503, configured to obtain a preset interface test template corresponding to an interface to be tested;
the test case acquisition module 505 is configured to update test parameters in the interface test template according to the interface test request to obtain an interface test case;
the interface test module 507 is configured to automatically test the interface to be tested through the interface test case, so as to obtain an interface test result.
According to the interface testing device, the interface to be tested is determined according to the received interface testing request through the interface determining module to be tested, the interface testing template corresponding to the interface to be tested is obtained through the testing template obtaining module, the testing parameters of the obtained interface testing template are updated through the interface testing request through the testing case obtaining module, the interface testing case is obtained, and finally the interface testing module performs automatic testing on the interface to be tested through the interface testing case directly, so that an interface testing result is obtained. In the interface test process, the test template corresponding to the interface to be tested is updated according to the interface test request, so that the interface test case meeting the interface test request can be obtained rapidly, and the interface automation test is carried out directly through the interface test case, so that the efficiency of the interface test is improved effectively.
In one embodiment, the test parameters include interface type, execution mode, test data, and result verification data; the test case acquisition module 505 includes a test parameter extraction unit, a test template configuration unit, and a test case generation unit, where: the test parameter extraction unit is used for extracting interface type, execution mode, test data and result verification data from the interface test request; the test template configuration unit is used for configuring an interface test template through the interface type, the execution mode, the test data and the result verification data; and the test case generating unit is used for generating an interface test case according to the configured interface test template.
In one embodiment, the interface test module 507 includes an interface retrieving unit, an execution result obtaining unit, and a test result obtaining unit, where: the interface calling unit is used for calling the interface to be tested; the execution result acquisition unit is used for automatically testing the interface to be tested through the interface test case to obtain an interface execution result; and the test result acquisition unit is used for comparing the interface execution result with the result verification data to obtain an interface test result.
In one embodiment, the system further comprises an interface code query module, a data path identification module, a partition condition determination module and a test template construction module, wherein: the interface code inquiry module is used for inquiring the interface code corresponding to the interface to be tested; the data path identification module is used for identifying a data flow path of the interface to be tested according to the interface code; the dividing condition determining module is used for determining corresponding path dividing conditions according to the data flow paths; and the test template construction module is used for generating test parameters according to the path dividing conditions and constructing an interface test template according to the test parameters.
In one embodiment, the interface test request comprises a flow test request; the system further comprises a test template combination module and a flow test template acquisition module, wherein: the test template combination module is used for combining the interface test templates corresponding to the interfaces to be tested according to the flow test request to obtain a flow test template; the flow test template acquisition module is used for taking the flow test template as an interface test template.
In one embodiment, the system further comprises an encryption form query module and a use case encryption packaging module, wherein: the encryption form query module is used for encrypting and packaging the interface test cases according to the encryption data type and the encryption mode to obtain the encrypted and packaged interface test cases; and the case encryption packaging module is used for taking the encrypted and packaged interface test case as an interface test case.
In one embodiment, the system further comprises an intermediate variable acquisition module, a variable value comparison module and an error reporting and prompting module, wherein: the intermediate variable acquisition module is used for acquiring a test intermediate variable in an automatic test process when the interface test result is abnormal; the variable value comparison module is used for comparing the variable value of the test intermediate variable with a preset standard intermediate variable; and the error reporting prompting module is used for marking the code segment corresponding to the test intermediate variable as an error code and sending out an error reporting prompting message when the variable value comparison results are inconsistent.
For specific limitations of the interface test device, reference may be made to the above description of the interface test method, and the description thereof will not be repeated here. The respective modules in the above-described interface test apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 6. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing test template data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an interface test method.
It will be appreciated by those skilled in the art that the structure shown in fig. 6 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided comprising a memory storing a computer program and a processor that when executing the computer program performs the steps of:
receiving an interface test request, and determining an interface to be tested according to the interface test request;
acquiring an interface test template corresponding to an interface to be tested;
updating test parameters in the interface test template according to the interface test request to obtain an interface test case;
and automatically testing the interface to be tested through the interface test case to obtain an interface test result.
In one embodiment, the test parameters include interface type, execution mode, test data, and result verification data; the processor when executing the computer program also implements the steps of: extracting interface type, execution mode, test data and result verification data from the interface test request; the interface test template is configured through the interface type, the execution mode, the test data and the result verification data; and generating an interface test case according to the configured interface test template.
In one embodiment, the processor when executing the computer program further performs the steps of: calling an interface to be tested; carrying out automatic test on the interface to be tested through the interface test case to obtain an interface execution result; and comparing the interface execution result with the result verification data to obtain an interface test result.
In one embodiment, the processor when executing the computer program further performs the steps of: inquiring an interface code corresponding to an interface to be tested; identifying a data flow path of an interface to be tested according to the interface code; determining corresponding path dividing conditions according to the data flow paths; and generating test parameters according to the path dividing conditions, and constructing an interface test template according to the test parameters.
In one embodiment, the interface test request comprises a flow test request; the processor when executing the computer program also implements the steps of: combining interface test templates corresponding to the interfaces to be tested according to the flow test requests to obtain flow test templates; and taking the flow test template as an interface test template.
In one embodiment, the processor when executing the computer program further performs the steps of: inquiring a data encryption form corresponding to the interface to be tested, wherein the data encryption form records an encryption data type and an encryption mode corresponding to the encryption data type; according to the type of the encrypted data and the encryption mode, encrypting and packaging the interface test cases to obtain the encrypted and packaged interface test cases; and taking the encrypted and packaged interface test case as an interface test case.
In one embodiment, the processor when executing the computer program further performs the steps of: when the interface test result is abnormal, acquiring a test intermediate variable in the automatic test process; comparing the variable value of the test intermediate variable with a preset standard intermediate variable; when the variable value comparison results are inconsistent, marking the code segment corresponding to the test intermediate variable as an error code, and sending out an error reporting prompt message.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of:
receiving an interface test request, and determining an interface to be tested according to the interface test request;
acquiring an interface test template corresponding to an interface to be tested;
updating test parameters in the interface test template according to the interface test request to obtain an interface test case;
and automatically testing the interface to be tested through the interface test case to obtain an interface test result.
In one embodiment, the test parameters include interface type, execution mode, test data, and result verification data; the computer program when executed by the processor also performs the steps of:
In one embodiment, the computer program when executed by the processor further performs the steps of: extracting interface type, execution mode, test data and result verification data from the interface test request; the interface test template is configured through the interface type, the execution mode, the test data and the result verification data; and generating an interface test case according to the configured interface test template.
In one embodiment, the computer program when executed by the processor further performs the steps of: calling an interface to be tested; carrying out automatic test on the interface to be tested through the interface test case to obtain an interface execution result; and comparing the interface execution result with the result verification data to obtain an interface test result.
In one embodiment, the computer program when executed by the processor further performs the steps of: inquiring an interface code corresponding to an interface to be tested; identifying a data flow path of an interface to be tested according to the interface code; determining corresponding path dividing conditions according to the data flow paths; and generating test parameters according to the path dividing conditions, and constructing an interface test template according to the test parameters.
In one embodiment, the interface test request comprises a flow test request; the computer program when executed by the processor also performs the steps of: combining interface test templates corresponding to the interfaces to be tested according to the flow test requests to obtain flow test templates; and taking the flow test template as an interface test template.
In one embodiment, the computer program when executed by the processor further performs the steps of: inquiring a data encryption form corresponding to the interface to be tested, wherein the data encryption form records an encryption data type and an encryption mode corresponding to the encryption data type; according to the type of the encrypted data and the encryption mode, encrypting and packaging the interface test cases to obtain the encrypted and packaged interface test cases; and taking the encrypted and packaged interface test case as an interface test case.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples merely represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the invention. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application is to be determined by the claims appended hereto.

Claims (10)

1. An interface testing method, the method comprising:
receiving an interface test request, and determining each interface to be tested according to the interface test request; each interface to be tested belongs to interfaces in the same series of processes;
inquiring an interface code corresponding to the interface to be tested;
identifying a data flow path of the interface to be tested according to the interface code;
Determining corresponding path dividing conditions according to the data flow paths;
generating test parameters according to the path dividing conditions, and constructing an interface test template according to the test parameters;
obtaining interface test templates corresponding to the interface types of the interfaces to be tested respectively;
combining the interface test templates according to a flow test request included in the interface test request to obtain a flow test template;
extracting interface type, execution mode, test data and result verification data from the interface test request;
configuring the flow test template through the interface type, the execution mode, the test data and the result verification data;
generating an interface test case according to the configured flow test template;
carrying out automatic test on each interface to be tested through the interface test case to obtain an interface test result;
when the interface test result is abnormal, acquiring a test intermediate variable in an automatic test process;
comparing the variable value of the test intermediate variable with a preset standard intermediate variable;
and when the variable value comparison results are inconsistent, marking the code segment corresponding to the test intermediate variable as an error code, and sending out an error reporting prompt message.
2. The method of claim 1, wherein the step of automatically testing each interface to be tested by the interface test case to obtain an interface test result comprises:
calling each interface to be tested;
carrying out automatic test on each interface to be tested through the interface test case to obtain an interface execution result;
and comparing the interface execution result with the result verification data to obtain an interface test result.
3. The method of claim 1, wherein the interface types include Get, post, put, and Delete types.
4. A method according to any one of claims 1 to 3, further comprising, after the step of generating interface test cases from the configured flow test templates:
inquiring a preset data encryption form corresponding to the interface to be tested, wherein the data encryption form records an encryption data type and an encryption mode corresponding to the encryption data type;
according to the encrypted data type and the encryption mode, the interface test case is encrypted and packaged to obtain an encrypted and packaged interface test case;
And taking the interface test case after encryption packaging as the interface test case.
5. An interface testing apparatus, the apparatus comprising:
the interface to be tested determining module is used for receiving the interface testing request and determining each interface to be tested according to the interface testing request; each interface to be tested belongs to interfaces in the same series of processes;
the interface code query module is used for querying the interface code corresponding to the interface to be tested;
the data path identification module is used for identifying the data flow path of the interface to be tested according to the interface code;
the dividing condition determining module is used for determining corresponding path dividing conditions according to the data flow paths;
the test template construction module is used for generating test parameters according to the path dividing conditions and constructing an interface test template according to the test parameters;
the test template acquisition module is used for acquiring interface test templates corresponding to the interface types of the interfaces to be tested respectively;
the test case acquisition module is used for combining the interface test templates according to the flow test requests included in the interface test requests to obtain flow test templates; extracting interface type, execution mode, test data and result verification data from the interface test request; configuring the flow test template through the interface type, the execution mode, the test data and the result verification data; generating an interface test case according to the configured flow test template;
The interface test module is used for automatically testing each interface to be tested through the interface test cases to obtain an interface test result;
the intermediate variable acquisition module is used for acquiring a test intermediate variable in an automatic test process when the interface test result is abnormal;
the variable value comparison module is used for comparing the variable value of the test intermediate variable with a preset standard intermediate variable;
and the error reporting prompting module is used for marking the code segment corresponding to the test intermediate variable as an error code and sending out an error reporting prompting message when the variable value comparison results are inconsistent.
6. The apparatus of claim 5, wherein the device comprises a plurality of sensors,
the interface test module is also used for calling each interface to be tested; carrying out automatic test on each interface to be tested through the interface test case to obtain an interface execution result; and comparing the interface execution result with the result verification data to obtain an interface test result.
7. The apparatus of claim 5, wherein the interface types include Get, post, put, and Delete types.
8. The apparatus according to any one of claims 5 to 7, further comprising:
The encryption form query module is used for querying a preset data encryption form corresponding to the interface to be tested, wherein the data encryption form records an encryption data type and an encryption mode corresponding to the encryption data type; according to the encrypted data type and the encryption mode, the interface test case is encrypted and packaged to obtain an encrypted and packaged interface test case;
and the case encryption packaging module is used for taking the interface test case after encryption packaging as the interface test case.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 4 when the computer program is executed.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 4.
CN201811123485.8A 2018-09-26 2018-09-26 Interface test method, device, computer equipment and storage medium Active CN109446068B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811123485.8A CN109446068B (en) 2018-09-26 2018-09-26 Interface test method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811123485.8A CN109446068B (en) 2018-09-26 2018-09-26 Interface test method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109446068A CN109446068A (en) 2019-03-08
CN109446068B true CN109446068B (en) 2024-04-05

Family

ID=65544407

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811123485.8A Active CN109446068B (en) 2018-09-26 2018-09-26 Interface test method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109446068B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109992508A (en) * 2019-03-22 2019-07-09 恒生电子股份有限公司 Test exemple automation generation method, device and electronic equipment
CN109933534B (en) * 2019-03-26 2023-02-24 上海上湖信息技术有限公司 Method and device for determining financial test object
CN110365967A (en) * 2019-06-27 2019-10-22 视联动力信息技术股份有限公司 A kind of test method and device
CN110337076A (en) * 2019-07-09 2019-10-15 深圳壹账通智能科技有限公司 SMS platform interface test method, device, computer equipment and storage medium
CN110750442B (en) * 2019-09-06 2022-08-19 深圳平安医疗健康科技服务有限公司 Test case generation method, device, equipment and storage medium
CN112732548B (en) * 2019-10-14 2024-01-26 腾讯科技(深圳)有限公司 Interface testing method and device
CN111159025B (en) * 2019-12-23 2022-10-18 武汉联影医疗科技有限公司 Application program interface testing method and device, computer equipment and storage medium
CN111324546A (en) * 2020-03-20 2020-06-23 普信恒业科技发展(北京)有限公司 Task testing method and device
CN113515436A (en) * 2020-04-09 2021-10-19 马上消费金融股份有限公司 Interface testing method and device
CN111581083B (en) * 2020-04-26 2024-02-09 抖音视界有限公司 Interface testing method and device, electronic equipment and storage medium
CN111752826A (en) * 2020-06-03 2020-10-09 五八有限公司 Interface testing method and device, electronic equipment and storage medium
CN112100078B (en) * 2020-09-27 2024-05-03 中国建设银行股份有限公司 Method, device and equipment for generating interface test case
CN112035308A (en) * 2020-11-03 2020-12-04 卡斯柯信号(北京)有限公司 Method and device for generating system interface test table
CN112199300B (en) * 2020-11-13 2022-08-19 新华三大数据技术有限公司 Interface testing method and device, electronic equipment and storage medium
CN112527630B (en) * 2020-11-18 2023-07-07 平安消费金融有限公司 Test case generation method, device, computer equipment and storage medium
CN113094263A (en) * 2021-03-30 2021-07-09 四川新网银行股份有限公司 Method for generating automatic interface test based on template
CN113326208A (en) * 2021-08-03 2021-08-31 深圳市维度数据科技股份有限公司 Interface test method and device

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101145993A (en) * 2007-10-11 2008-03-19 中兴通讯股份有限公司 A multi-point access interface test method and its test system
CN104503917A (en) * 2015-01-04 2015-04-08 牟永敏 Method and system for analyzing change impact domain based on data flow function invoking path
CN106886494A (en) * 2017-03-07 2017-06-23 深圳国泰安教育技术股份有限公司 A kind of automatic interface testing method and its system
CN107122258A (en) * 2017-04-18 2017-09-01 上海雷腾软件股份有限公司 Method and apparatus for the state code check of test interface
CN107171897A (en) * 2017-07-14 2017-09-15 上海瀚银信息技术有限公司 A kind of interface test method and data-interface test system
CN107203459A (en) * 2016-03-16 2017-09-26 阿里巴巴集团控股有限公司 Interface performance test method and apparatus
CN107402884A (en) * 2017-07-31 2017-11-28 深圳乐信软件技术有限公司 Generate the method and device of interface testing code
CN107844421A (en) * 2017-10-31 2018-03-27 平安科技(深圳)有限公司 Interface test method, device, computer equipment and storage medium
CN108446190A (en) * 2017-02-16 2018-08-24 杭州海康威视数字技术股份有限公司 interface test method and device
CN108549606A (en) * 2018-04-16 2018-09-18 成都医云科技有限公司 interface test method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101145993A (en) * 2007-10-11 2008-03-19 中兴通讯股份有限公司 A multi-point access interface test method and its test system
CN104503917A (en) * 2015-01-04 2015-04-08 牟永敏 Method and system for analyzing change impact domain based on data flow function invoking path
CN107203459A (en) * 2016-03-16 2017-09-26 阿里巴巴集团控股有限公司 Interface performance test method and apparatus
CN108446190A (en) * 2017-02-16 2018-08-24 杭州海康威视数字技术股份有限公司 interface test method and device
CN106886494A (en) * 2017-03-07 2017-06-23 深圳国泰安教育技术股份有限公司 A kind of automatic interface testing method and its system
CN107122258A (en) * 2017-04-18 2017-09-01 上海雷腾软件股份有限公司 Method and apparatus for the state code check of test interface
CN107171897A (en) * 2017-07-14 2017-09-15 上海瀚银信息技术有限公司 A kind of interface test method and data-interface test system
CN107402884A (en) * 2017-07-31 2017-11-28 深圳乐信软件技术有限公司 Generate the method and device of interface testing code
CN107844421A (en) * 2017-10-31 2018-03-27 平安科技(深圳)有限公司 Interface test method, device, computer equipment and storage medium
CN108549606A (en) * 2018-04-16 2018-09-18 成都医云科技有限公司 interface test method and device

Also Published As

Publication number Publication date
CN109446068A (en) 2019-03-08

Similar Documents

Publication Publication Date Title
CN109446068B (en) Interface test method, device, computer equipment and storage medium
CN109474578B (en) Message checking method, device, computer equipment and storage medium
CN110209652B (en) Data table migration method, device, computer equipment and storage medium
WO2020186786A1 (en) File processing method and apparatus, computer device and storage medium
CN108427613B (en) Abnormal interface positioning method and device, computer equipment and storage medium
CN110134658B (en) Log monitoring method, device, computer equipment and storage medium
CN110008117A (en) Page test method, device, computer equipment and storage medium
CN112491602B (en) Behavior data monitoring method and device, computer equipment and medium
CN110908778B (en) Task deployment method, system and storage medium
CN109542764B (en) Webpage automatic testing method and device, computer equipment and storage medium
CN109361628B (en) Message assembling method and device, computer equipment and storage medium
CN108256322B (en) Security testing method and device, computer equipment and storage medium
CN111078507A (en) Data monitoring method, system, computer equipment and storage medium
CN109389299B (en) Workflow process deployment method, workflow process deployment device, computer equipment and storage medium
CN112860778B (en) Database management method, device, equipment and medium for desktop application program
WO2020232883A1 (en) Script defect scanning method and apparatus, computer device and storage medium
WO2021120628A1 (en) Blockchain-based sensitive word detection method and apparatus, computer device and computer-readable storage medium
CN110750443A (en) Webpage testing method and device, computer equipment and storage medium
CN111124872A (en) Branch detection method and device based on difference code analysis and storage medium
CN110275703B (en) Method and device for assigning key value to data, computer equipment and storage medium
CN111324375A (en) Code management method and device, computer equipment and storage medium
CN113377669A (en) Automatic testing method and device, computer equipment and storage medium
CN112862449A (en) Structural chemical industry bill generation method and device, computer equipment and storage medium
CN109542947B (en) Data statistical method, device, computer equipment and storage medium
CN115629940A (en) Micro-service full-link tracking method, device, system and 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
GR01 Patent grant
GR01 Patent grant