CN112948195B - Interface testing method, device, electronic equipment and storage medium - Google Patents

Interface testing method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112948195B
CN112948195B CN202110345264.0A CN202110345264A CN112948195B CN 112948195 B CN112948195 B CN 112948195B CN 202110345264 A CN202110345264 A CN 202110345264A CN 112948195 B CN112948195 B CN 112948195B
Authority
CN
China
Prior art keywords
interface
tested
test
parameter
interface identifier
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
CN202110345264.0A
Other languages
Chinese (zh)
Other versions
CN112948195A (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.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech 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 CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202110345264.0A priority Critical patent/CN112948195B/en
Publication of CN112948195A publication Critical patent/CN112948195A/en
Application granted granted Critical
Publication of CN112948195B publication Critical patent/CN112948195B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Test And Diagnosis Of Digital Computers (AREA)
  • Tests Of Electronic Circuits (AREA)

Abstract

The invention discloses a method, a device, electronic equipment and a storage medium for interface test, and relates to the technical field of automatic programming. One embodiment of the method comprises the following steps: acquiring test data, and acquiring request parameters and response parameters corresponding to the interface identifiers to be tested from the test data; inquiring a test model corresponding to the interface identifier to be tested, and calling the test model to test each interface to be tested based on the request parameter and the response parameter corresponding to the interface identifier to be tested to obtain a test result; judging whether the test result is passing or not; if yes, storing a test result; if not, generating an interface defect record corresponding to the interface identifier to be tested based on the preset format and the test result so as to store the interface defect record. According to the embodiment, the problems that the conventional test mode needs a certain degree of manual intervention, the test process takes longer and the test efficiency is lower can be solved.

Description

Interface testing method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of automatic programming, and in particular, to a method and apparatus for testing an interface, an electronic device, and a storage medium.
Background
In the current interface test mode, a manual test or a semi-automatic test is generally adopted, and the semi-automatic test mode refers to that an analog front end (client) sends data to a server, and after corresponding response data are obtained, whether the response data are accurate or not is judged manually so as to determine whether the tested interface normally exchanges data or not. However, in the existing test mode, a certain degree of manual intervention is required, so that the test process takes longer and the test efficiency is lower.
Disclosure of Invention
In view of the above, embodiments of the present invention provide a method, an apparatus, an electronic device, and a storage medium for testing an interface, which can solve the problems that in the existing test mode, a certain degree of manual intervention is required, resulting in a long time spent in a test process and a low test efficiency.
To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided a method of interface testing.
The method for testing the interface comprises the following steps: acquiring test data, and acquiring request parameters and response parameters corresponding to the interface identifiers to be tested from the test data; inquiring a test model corresponding to the interface identifier to be tested, and calling the test model to test each interface to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested to obtain a test result, wherein the test model comprises operation logic among interfaces to be tested and parameter information corresponding to each interface identifier to be tested; judging whether the test result is passing or not; if yes, storing the test result; if not, generating an interface defect record corresponding to the interface identifier to be tested based on a preset format and the test result so as to store the interface defect record.
In one embodiment, before the querying the test model corresponding to the interface identifier to be tested, the method further includes:
receiving a test file, and acquiring parameter information of each interface to be tested in the test file and operation logic between the interfaces to be tested;
generating a Schema file corresponding to each interface to be tested based on the parameter information of each interface to be tested;
calling a preset test template to generate a test model of the interface to be tested based on the operation logic between the Schema file and the test interface;
and storing the corresponding relation between the interface identifier to be tested and the test model.
In yet another embodiment, the calling the test model to test each interface to be tested based on the request parameter and the response parameter corresponding to the interface identifier to be tested includes:
acquiring parameter information of each interface to be tested in the test model;
judging whether the request parameters and response parameters corresponding to the interface identifier to be tested are the same as the parameter information of the interface to be tested;
if not, determining that the test result is that the test fails;
if yes, acquiring operation logic of each interface to be tested in the test model, determining an execution sequence corresponding to the interface identifier to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested, judging whether the operation logic is consistent with the execution sequence, if yes, determining that the test result is test passing, and if not, determining that the test result is not pass.
In yet another embodiment, the determining, based on the request parameter and the response parameter corresponding to the interface identifier to be tested, an execution order corresponding to the interface identifier to be tested includes:
acquiring time information of a request parameter and a response parameter corresponding to the interface identifier to be tested;
and determining the execution sequence corresponding to the interface identifier to be tested based on the time information.
In yet another embodiment, the time information includes a timestamp of a request parameter and a response parameter corresponding to the interface identifier to be tested.
In yet another embodiment, the parameter information includes a request parameter format, a request parameter value, a response parameter format, and a response parameter value corresponding to the test interface.
In yet another embodiment, the acquiring test data includes:
acquiring log data of a terminal or a server corresponding to the interface to be tested;
and extracting the test data from the log data based on the interface identifier to be tested.
In yet another embodiment, after the generating the interface defect record corresponding to the interface identifier to be tested based on the preset format and the test result, the method further includes:
obtaining interface defect records corresponding to the interface identifiers to be tested so as to count the corresponding record quantity;
Judging whether the recording quantity is larger than a preset quantity threshold value or not;
if yes, sending alarm prompt information; if not, not executing operation on the record quantity.
In yet another embodiment, after said storing said test result, further comprising:
and updating the test state corresponding to the interface to be tested into a test success state.
To achieve the above object, according to another aspect of an embodiment of the present invention, there is provided an apparatus for interface testing.
The device for testing the interface comprises: the acquisition unit is used for acquiring test data, and acquiring request parameters and response parameters corresponding to the interface identifiers to be tested from the test data; the test unit is used for inquiring a test model corresponding to the interface identifier to be tested, and calling the test model to test each interface to be tested based on the request parameter and the response parameter corresponding to the interface identifier to be tested to obtain a test result, wherein the test model comprises operation logic among the interfaces to be tested and parameter information corresponding to each interface identifier to be tested; the judging unit is used for judging whether the test result is passing or not; the storage unit is used for storing the test result if yes; if not, generating an interface defect record corresponding to the interface identifier to be tested based on a preset format and the test result so as to store the interface defect record.
In one embodiment, the apparatus further comprises:
the receiving unit is also used for receiving the test file, and acquiring parameter information of each interface to be tested in the test file and operation logic between the interfaces to be tested;
the generating unit is used for generating a Schema file corresponding to each interface to be tested based on the parameter information of each interface to be tested;
the generating unit is further configured to invoke a preset test template to generate a test model of the interface to be tested based on operation logic between the Schema file and the test interface;
the storage unit is further used for storing the corresponding relation between the interface identifier to be tested and the test model.
In a further embodiment, the test unit is specifically configured to:
acquiring parameter information of each interface to be tested in the test model;
judging whether the request parameters and response parameters corresponding to the interface identifier to be tested are the same as the parameter information of the interface to be tested;
if not, determining that the test result is that the test fails;
if yes, acquiring operation logic of each interface to be tested in the test model, determining an execution sequence corresponding to the interface identifier to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested, judging whether the operation logic is consistent with the execution sequence, if yes, determining that the test result is test passing, and if not, determining that the test result is not pass.
In a further embodiment, the test unit is specifically configured to:
acquiring time information of a request parameter and a response parameter corresponding to the interface identifier to be tested;
and determining the execution sequence corresponding to the interface identifier to be tested based on the time information.
In yet another embodiment, the time information includes a timestamp of a request parameter and a response parameter corresponding to the interface identifier to be tested.
In yet another embodiment, the parameter information includes a request parameter format, a request parameter value, a response parameter format, and a response parameter value corresponding to the test interface.
In a further embodiment, the acquiring unit is specifically configured to:
acquiring log data of a terminal or a server corresponding to the interface to be tested;
and extracting test data from the log data based on the interface identifier to be tested.
In yet another embodiment, the obtaining unit is further configured to obtain an interface defect record corresponding to the interface identifier to be tested, so as to count the number of corresponding records;
the judging unit is further used for judging whether the recording quantity is larger than a preset quantity threshold value or not;
the apparatus further comprises:
the alarm unit is used for sending alarm prompt information if yes; if not, not executing operation on the record quantity.
In a further embodiment, the memory unit is further configured to:
and updating the test state corresponding to the interface to be tested into a test success state.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an electronic apparatus.
An electronic device according to an embodiment of the present invention includes: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the interface testing method provided by the embodiment of the invention.
To achieve the above object, according to still another aspect of an embodiment of the present invention, a computer-readable medium is provided.
A computer readable medium of an embodiment of the present invention has stored thereon a computer program which, when executed by a processor, implements a method for interface testing provided by the embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: in the embodiment of the invention, the test data of the interfaces to be tested, namely the request parameters and the response parameters, can be obtained, then the corresponding test model is inquired based on the interfaces to be tested, the test model comprises the parameter information of each interface to be tested and the operation logic between the interfaces to be tested, so the test model can be called to test the interfaces to be tested based on the request parameters and the response parameters corresponding to the interfaces to be tested, the test result is obtained, and the interface defect record corresponding to the interfaces to be tested is generated when the test result is that the test fails. In the embodiment of the invention, the interface to be tested can be tested through the test model to obtain the test result, the automatic test of the interface is realized without manual participation, the time spent in the test process is reduced, and the efficiency of the interface test is improved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of a system architecture of a method of interface testing according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of one main flow of a method of interface testing according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of one main flow of a test model generation method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of test data versus Schema file alignment code according to an embodiment of the invention;
FIG. 5 is a schematic diagram of the main units of an apparatus for interface testing according to an embodiment of the present invention;
FIG. 6 is a diagram of yet another exemplary system architecture in which embodiments of the present invention may be applied;
FIG. 7 is a schematic diagram of a computer system suitable for use in implementing embodiments of the present invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It is noted that embodiments of the invention and features of the embodiments may be combined with each other without conflict.
The embodiment of the invention provides a system for interface test, which can be used for a scene of interface test. Specifically, fig. 1 is a schematic diagram of an architecture of a system for interface testing according to an embodiment of the present invention.
As shown in fig. 1, the system for interface testing may include a Schema management module, an automatic verification service module, and an offline Bug library.
The Schema management module is used for generating and storing a test model, wherein the test model comprises operation logic among interfaces to be tested and parameter information corresponding to each interface identifier to be tested. The parameter information corresponding to each interface identifier to be tested can include a request parameter and a response parameter, and specifically can be a request parameter format, a request parameter value, a response parameter format and a response parameter value. The operation logic may represent a call relationship between interfaces to be tested, and one or more different interfaces are typically called for a request data process, so that whether a problem occurs in operation between interfaces may also be tested based on the call relationship of the interfaces. The automatic check service module is used for executing the test process of the interface to be tested and obtaining the test result. The automatic checking service module can acquire test data for testing the interface from a terminal or a server where the on-line interface is located, and then can inquire a test model corresponding to the interface to be tested from the Schema management module, so that a test process of the interface to be tested can be executed, and a test result is obtained.
The Schema management module can obtain test files of the interfaces from the interface definition server, and the test files can define the interfaces, including parameter information of the interfaces and operation logic between the interfaces. In particular, the test file may be an API interface document, which is typically developed and defined by a developer and stored in an interface definition server. The interfaces stored in the interface definition server are also online and synchronized to the corresponding terminal and the corresponding server for operation, so that the test data of the interface to be tested can be obtained from the terminal or the server in the embodiment of the invention.
The interface test results may include that the test is passed or not passed, and when the test result is not passed, the test result is not in accordance with the expected test result, so that the interface to be tested has holes (bug), so that the interfaces to be tested and the test results of the interfaces to be tested may be stored, that is, interface defect records may be generated and stored, so that the data passing through the stored interfaces may be adjusted. Therefore, the offline Bug library in the interface test system can store the test results as interface defect records of interfaces to be tested, which are failed in the test.
It should be noted that, in the embodiment of the present invention, the system for interface testing is generally managed by a tester, for example, the system for interface testing is configured and the like.
An embodiment of the present invention provides a method for testing an interface, which may be performed by a system for testing an interface of a system architecture shown in fig. 1, as shown in fig. 2, and includes the following steps.
S201: and acquiring test data, and acquiring request parameters and response parameters corresponding to the interface identifiers to be tested from the test data.
The test data is generally obtained from a terminal or a server where the interface to be tested is located, and the interface generally receives a request message and then returns a response message corresponding to the request message when running, so that the test data includes a request parameter and a response parameter corresponding to each interface identifier to be tested, the specific request parameter may be the request message, and the response parameter may be a response message corresponding to the request message.
Specifically, the manner of acquiring the test parameters in this step may specifically be: acquiring log data of a terminal or a server corresponding to an interface to be tested; and extracting test data from the log data based on the interface identifier to be tested.
The terminal or the server corresponding to the interface to be tested operates, and the data of each operation is usually stored in log data, so that in the step, the log can be obtained from the terminal or the server corresponding to the interface to be tested, and then according to the test requirement, test data, namely request parameters and response parameters of the interface to be tested, are extracted from the log based on the interface identifier to be tested.
In this step, in order to reduce data transmission and reduce the transmission resources used, a related program may be configured at a terminal or a server corresponding to the interface to be tested, so as to automatically extract test data from a log of the terminal or the server, and then the terminal or the server sends the extracted test data to a system tested at the interface.
S202: inquiring a test model corresponding to the interface identifier to be tested, and calling the test model to test each interface to be tested based on the request parameter and the response parameter corresponding to the interface identifier to be tested, so as to obtain a test result.
The test model comprises operation logic among interfaces to be tested and parameter information corresponding to each interface identifier to be tested.
The interface test system stores test templates corresponding to the test interfaces, and the test templates comprise operation logic among the interfaces to be tested and parameter information corresponding to the identifiers of the interfaces to be tested, so that whether the interfaces to be tested meet expected requirements can be tested based on the operation logic and the parameter information of the interfaces to be tested through the test templates.
Specifically, the present step may be performed as: acquiring parameter information of each interface to be tested in the test model, wherein the parameter information comprises a request parameter format, a request parameter value, a response parameter format and a response parameter value corresponding to the test interface; judging whether the request parameters and response parameters corresponding to the interface identification to be tested are identical with the parameter information of the interface to be tested; if not, determining that the test result is that the test is not passed; if yes, acquiring the operation logic of each interface to be tested in the test model, determining the execution sequence corresponding to the interface to be tested based on the request parameter and the response parameter corresponding to the interface to be tested, judging whether the operation logic is consistent with the execution sequence, if yes, determining that the test result is passing, and if not, determining that the test result is not passing.
In this step, the parameter information of each interface to be tested in the test model may be obtained first, so as to determine the request parameter and the response parameter of each interface to be tested. The parameter information specifically includes a request parameter format, a request parameter value, a response parameter format and a response parameter value corresponding to the test interface, that is to say, the request parameter and the response parameter of the interface to be tested need to be judged from two aspects of the parameter format and the parameter value, so that the judgment of whether the request parameter and the response parameter corresponding to the identification of the interface to be tested are identical with the parameter information of the interface to be tested can be performed. If the received message and the request message of the interface to be tested are different, the received message and the request message of the interface to be tested do not meet the expected requirement, namely, the parameters transmitted by the interface to be tested have errors, and the fact that the test of the interface to be tested fails can be determined at the moment, namely, the test result is that the test fails; if the parameters are the same, the received message and the request message of the interface to be tested meet the expected requirements, namely the parameters transmitted by the interface to be tested are correct, and then whether the calling relationship among the interfaces to be tested meets the requirements can be judged.
And judging whether the calling relation among the interfaces to be tested meets the expected requirement, acquiring the running logic of each interface to be tested in the test model, determining the execution sequence corresponding to the interface identifier to be tested based on the request parameter and the response parameter corresponding to the interface identifier to be tested, and judging whether the running logic is consistent with the execution sequence. Specifically, each request parameter and each response parameter include a time stamp, so that the execution sequence corresponding to the interface identifier to be tested can be determined based on the time stamps. If the running logic is consistent with the execution sequence, and the calling relation among the interfaces to be tested meets the expected requirement, the test result can be determined as the passing of the test; if the running logic and the execution sequence are inconsistent, and the calling relation among the interfaces to be tested does not meet the expected requirement, the test result can be determined as that the test is not passed.
S203: judging whether the test result is passing or not.
Wherein the test results include test pass and test fail. The test can meet the test requirement by indicating the interface to be tested, and can be not adjusted any more; the test does not show that the interface to be tested does not meet the test requirement, and the interface to be tested needs to be adjusted.
S204: if yes, storing a test result; if not, generating an interface defect record corresponding to the interface identifier to be tested based on the preset format and the test result so as to store the interface defect record.
The interface to be tested passes the test, so that the test result can be directly stored, and the test state of the interface to be tested can be updated to be a success state (success state). The interface to be tested is not tested, and the interface to be tested is required to be adjusted later, so that an interface defect record corresponding to the interface identifier to be tested can be generated based on a preset format and a test result, and the interface defect record is stored, so that the interface to be tested is convenient to check later, and meanwhile, the test state of the interface to be tested can be updated to be a fail state.
It should be noted that some interfaces are generally important, if the number of times of failed tests is too high, the interfaces need to be processed in time, so in the embodiment of the invention, the interfaces to be tested which are failed to be tested can be counted, that is, the interface defect records corresponding to the identification of the interface to be tested are obtained, so that the corresponding record number is counted. The number of records represents the number of failures of the interface test to be tested, and then it may be determined whether the number of records is greater than a preset number threshold, which may be set based on requirements, for example, may be set to 5. If the number of records is greater than a preset number threshold, the number of times of the test failure of the interface to be tested is larger, and an alarm prompt message can be sent so as to adjust the interface in time; if the number of records is not greater than the preset number threshold, the number of failures of the interface to be tested is small, and the operation can be temporarily not performed on the number of records.
In the embodiment of the invention, the test data of the interfaces to be tested, namely the request parameters and the response parameters, can be obtained, then the corresponding test model is inquired based on the interfaces to be tested, the test model comprises the parameter information of each interface to be tested and the operation logic between the interfaces to be tested, so the test model can be called to test the interfaces to be tested based on the request parameters and the response parameters corresponding to the interfaces to be tested, the test result is obtained, and the interface defect record corresponding to the interfaces to be tested is generated when the test result is that the test fails. In the embodiment of the invention, the interface to be tested can be tested through the test model to obtain the test result, the automatic test of the interface is realized without manual participation, the time spent in the test process is reduced, and the efficiency of the interface test is improved.
The method for generating the test template in the embodiment of the present invention is specifically described below with reference to the system architecture shown in fig. 1. As shown in fig. 3, the method includes the following steps.
S301: and receiving a test file, and acquiring parameter information of each interface to be tested in the test file and operation logic among the interfaces to be tested.
The test file is developed by a developer, and may include parameter information of each interface to be tested and operation logic between each interface to be tested, and specifically may be an API interface document.
S302: and generating a Schema file corresponding to each interface to be tested based on the parameter information of each interface to be tested.
After the interface test system obtains the test file, the interface test system can automatically generate a Schema file corresponding to each interface to be tested based on the parameter information of each interface to be tested in the test file. The Schema file may be used for testing request parameters and response parameters of the interface to be tested, specifically, comparing each field in the request parameters and response parameters with a corresponding field in the Schema file, where the comparison code may be as shown in fig. 4.
S303: and calling a preset test template to generate a test model of the interface to be tested based on the operation logic between the Schema file and the test interface.
The embodiment of the invention can preset the test template, so that the preset test template can be called to generate the test model of the interface to be tested after the operation logic between the Schema file and the test interface is acquired in the step.
S304: and storing the corresponding relation between the interface identifier to be tested and the test model.
After the test model is generated, the test model can be stored, and the corresponding relation between the interface identifier to be tested and the test model is stored, so that the test model can be conveniently inquired through the interface identifier to be tested.
In the embodiment of the invention, the test model can be generated in advance, then the interface to be tested is tested through the test model to obtain the test result, the automatic test of the interface is realized without manual participation, the time spent in the test process is reduced, and the efficiency of the interface test is improved.
In order to solve the problems existing in the prior art, an embodiment of the present invention provides an apparatus 500 for testing an interface, as shown in fig. 5, the apparatus 500 includes:
an obtaining unit 501, configured to obtain test data, and obtain a request parameter and a response parameter corresponding to each interface identifier to be tested from the test data;
the test unit 502 is configured to query a test model corresponding to the interface identifier to be tested, and call the test model to test each interface to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested, so as to obtain a test result, where the test model includes operation logic between interfaces to be tested and parameter information corresponding to each interface identifier to be tested;
A judging unit 503, configured to judge whether the test result is passing or not;
a storage unit 504, configured to store the test result if yes; if not, generating an interface defect record corresponding to the interface identifier to be tested based on a preset format and the test result so as to store the interface defect record.
It should be understood that the manner of implementing the embodiment of the present invention is the same as that of implementing the embodiment shown in fig. 2, and will not be described herein.
In one implementation manner of the embodiment of the present invention, the apparatus 500 further includes:
the receiving unit is also used for receiving the test file, and acquiring parameter information of each interface to be tested in the test file and operation logic between the interfaces to be tested;
the generating unit is used for generating a Schema file corresponding to each interface to be tested based on the parameter information of each interface to be tested;
the generating unit is further configured to invoke a preset test template to generate a test model of the interface to be tested based on operation logic between the Schema file and the test interface;
the storage unit 504 is further configured to store a correspondence between the interface identifier to be tested and the test model.
In yet another implementation manner of the embodiment of the present invention, the test unit 502 is specifically configured to:
acquiring parameter information of each interface to be tested in the test model;
judging whether the request parameters and response parameters corresponding to the interface identifier to be tested are the same as the parameter information of the interface to be tested;
if not, determining that the test result is that the test fails;
if yes, acquiring operation logic of each interface to be tested in the test model, determining an execution sequence corresponding to the interface identifier to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested, judging whether the operation logic is consistent with the execution sequence, if yes, determining that the test result is test passing, and if not, determining that the test result is not pass.
In yet another implementation manner of the embodiment of the present invention, the test unit is specifically configured to:
acquiring time information of a request parameter and a response parameter corresponding to the interface identifier to be tested;
and determining the execution sequence corresponding to the interface identifier to be tested based on the time information.
In still another implementation manner of the embodiment of the present invention, the time information includes a timestamp of a request parameter and a response parameter corresponding to the interface identifier to be tested.
In still another implementation manner of the embodiment of the present invention, the parameter information includes a request parameter format, a request parameter value, a response parameter format, and a response parameter value corresponding to the test interface.
In yet another implementation manner of the embodiment of the present invention, the obtaining unit 501 is specifically configured to:
acquiring log data of a terminal or a server corresponding to the interface to be tested;
and extracting test data from the log data based on the interface identifier to be tested.
In another implementation manner of the embodiment of the present invention, the obtaining unit 501 is further configured to obtain an interface defect record corresponding to the interface identifier to be tested, so as to count the number of corresponding records;
the judging unit 503 is further configured to judge whether the number of records is greater than a preset number threshold;
the apparatus 500 further comprises:
the alarm unit is used for sending alarm prompt information if yes; if not, not executing operation on the record quantity.
In another implementation manner of the embodiment of the present invention, the storage unit 504 is further configured to:
and updating the test state corresponding to the interface to be tested into a test success state.
It should be understood that the manner of implementing the embodiments of the present invention is the same as that of implementing the embodiments shown in fig. 2 or 3, and will not be described herein.
In the embodiment of the invention, the test data of the interfaces to be tested, namely the request parameters and the response parameters, can be obtained, then the corresponding test model is inquired based on the interfaces to be tested, the test model comprises the parameter information of each interface to be tested and the operation logic between the interfaces to be tested, so the test model can be called to test the interfaces to be tested based on the request parameters and the response parameters corresponding to the interfaces to be tested, the test result is obtained, and the interface defect record corresponding to the interfaces to be tested is generated when the test result is that the test fails. In the embodiment of the invention, the interface to be tested can be tested through the test model to obtain the test result, the automatic test of the interface is realized without manual participation, the time spent in the test process is reduced, and the efficiency of the interface test is improved.
According to an embodiment of the present invention, an electronic device and a readable storage medium are also provided.
The electronic equipment of the embodiment of the invention comprises: at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the one processor, and the instructions are executed by the at least one processor, so that the at least one processor performs the method for testing the interface provided by the embodiment of the invention.
Fig. 6 illustrates an exemplary system architecture 600 of a method of interface testing or an apparatus of interface testing to which embodiments of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 is used as a medium to provide communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 605 via the network 604 using the terminal devices 601, 602, 603 to receive or send messages, etc. Various client applications may be installed on the terminal devices 601, 602, 603.
The terminal devices 601, 602, 603 may be, but are not limited to, smartphones, tablets, laptop and desktop computers, and the like.
The server 605 may be a server providing various services, and may perform processing such as analysis on received data such as a product information query request, and feed back processing results (e.g., product information—just an example) to the terminal device.
It should be noted that, the method for testing an interface provided in the embodiment of the present invention is generally executed by the server 605, and accordingly, the device for testing an interface is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, there is illustrated a schematic diagram of a computer system 700 suitable for use in implementing embodiments of the present invention. The computer system shown in fig. 7 is only an example, and should not be construed as limiting the functionality and scope of use of the embodiments of the invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, ROM 702, and RAM 703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input section 706 including a keyboard, a mouse, and the like; an output portion 707 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 708 including a hard disk or the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. The drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read therefrom is mounted into the storage section 708 as necessary.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 709, and/or installed from the removable medium 711. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 701.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a unit, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present invention may be implemented in software or in hardware. The described units may also be provided in a processor, for example, described as: a processor includes an acquisition unit, a test unit, a determination unit, and a storage unit. The names of these units do not constitute a limitation on the unit itself in some cases, and for example, the acquisition unit may also be described as "a unit that acquires the function of the unit".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to perform the method of interface testing provided by the present invention.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (14)

1. A method of interface testing, comprising:
acquiring test data, and acquiring request parameters and response parameters corresponding to the interface identifiers to be tested from the test data;
inquiring a test model corresponding to the interface identifier to be tested, and calling the test model to test each interface to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested to obtain a test result, wherein the test model comprises operation logic among the interfaces to be tested and parameter information corresponding to each interface identifier to be tested;
Judging whether the test result is passing or not;
if yes, storing the test result; if not, generating an interface defect record corresponding to the interface identifier to be tested based on a preset format and the test result so as to store the interface defect record;
before the query of the test model corresponding to the interface identifier to be tested, the method further comprises:
receiving a test file, and acquiring parameter information of each interface to be tested in the test file and operation logic between the interfaces to be tested, wherein the test file is an API interface document;
generating a Schema file corresponding to each interface to be tested based on the parameter information of each interface to be tested;
calling a preset test template to generate a test model of the interface to be tested based on the operation logic between the Schema file and the test interface;
and storing the corresponding relation between the interface identifier to be tested and the test model.
2. The method according to claim 1, wherein the calling the test model to test each interface to be tested based on the request parameter and the response parameter corresponding to the interface identifier to be tested includes:
Acquiring parameter information of each interface to be tested in the test model;
judging whether the request parameters and response parameters corresponding to the interface identifier to be tested are the same as the parameter information of the interface to be tested;
if not, determining that the test result is that the test fails;
if yes, acquiring operation logic of each interface to be tested in the test model, determining an execution sequence corresponding to the interface identifier to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested, judging whether the operation logic is consistent with the execution sequence, if yes, determining that the test result is test passing, and if not, determining that the test result is not pass.
3. The method according to claim 2, wherein determining the execution order corresponding to the interface identifier to be tested based on the request parameter and the response parameter corresponding to the interface identifier to be tested includes:
acquiring time information of a request parameter and a response parameter corresponding to the interface identifier to be tested;
and determining the execution sequence corresponding to the interface identifier to be tested based on the time information.
4. A method according to claim 3, wherein the time information comprises a time stamp of a request parameter and a response parameter corresponding to the interface identifier to be tested.
5. The method of claim 1, wherein the parameter information includes a request parameter format, a request parameter value, a response parameter format, and a response parameter value corresponding to the test interface.
6. The method of claim 1, wherein the acquiring test data comprises:
acquiring log data of a terminal or a server corresponding to the interface to be tested;
and extracting the test data from the log data based on the interface identifier to be tested.
7. The method according to claim 1, further comprising, after the generating the interface defect record corresponding to the interface identifier to be tested based on the preset format and the test result:
obtaining interface defect records corresponding to the interface identifiers to be tested so as to count the corresponding record quantity;
judging whether the recording quantity is larger than a preset quantity threshold value or not;
if yes, sending alarm prompt information; if not, not executing operation on the record quantity.
8. The method of claim 1, further comprising, after said storing said test results:
and updating the test state corresponding to the interface to be tested into a test success state.
9. An apparatus for interface testing, comprising:
the acquisition unit is used for acquiring test data, and acquiring request parameters and response parameters corresponding to the interface identifiers to be tested from the test data;
the test unit is used for inquiring a test model corresponding to the interface identifier to be tested, and calling the test model to test each interface to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested to obtain a test result, wherein the test model comprises operation logic among the interfaces to be tested and parameter information corresponding to each interface identifier to be tested;
the judging unit is used for judging whether the test result is passing or not;
the storage unit is used for storing the test result if yes; if not, generating an interface defect record corresponding to the interface identifier to be tested based on a preset format and the test result so as to store the interface defect record;
the apparatus further comprises:
the receiving unit is used for receiving a test file, acquiring parameter information of each interface to be tested in the test file and operation logic between the interfaces to be tested, wherein the test file is an API interface document;
The generating unit is used for generating a Schema file corresponding to each interface to be tested based on the parameter information of each interface to be tested;
the generating unit is further configured to invoke a preset test template to generate a test model of the interface to be tested based on operation logic between the Schema file and the test interface;
the storage unit is further used for storing the corresponding relation between the interface identifier to be tested and the test model.
10. The device according to claim 9, characterized in that the test unit is specifically configured to:
acquiring parameter information of each interface to be tested in the test model;
judging whether the request parameters and response parameters corresponding to the interface identifier to be tested are the same as the parameter information of the interface to be tested;
if not, determining that the test result is that the test fails;
if yes, acquiring operation logic of each interface to be tested in the test model, determining an execution sequence corresponding to the interface identifier to be tested based on a request parameter and a response parameter corresponding to the interface identifier to be tested, judging whether the operation logic is consistent with the execution sequence, if yes, determining that the test result is test passing, and if not, determining that the test result is not pass.
11. The apparatus according to claim 9, wherein the acquisition unit is specifically configured to:
acquiring log data of a terminal or a server corresponding to the interface to be tested;
and extracting test data from the log data based on the interface identifier to be tested.
12. The apparatus according to claim 9, wherein the obtaining unit is further configured to obtain an interface defect record corresponding to the interface identifier to be tested, so as to count the number of corresponding records;
the judging unit is further used for judging whether the recording quantity is larger than a preset quantity threshold value or not;
the apparatus further comprises:
the alarm unit is used for sending alarm prompt information if yes; if not, not executing operation on the record quantity.
13. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-8.
14. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-8.
CN202110345264.0A 2021-03-31 2021-03-31 Interface testing method, device, electronic equipment and storage medium Active CN112948195B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110345264.0A CN112948195B (en) 2021-03-31 2021-03-31 Interface testing method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110345264.0A CN112948195B (en) 2021-03-31 2021-03-31 Interface testing method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112948195A CN112948195A (en) 2021-06-11
CN112948195B true CN112948195B (en) 2023-04-25

Family

ID=76231182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110345264.0A Active CN112948195B (en) 2021-03-31 2021-03-31 Interface testing method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112948195B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113538725B (en) * 2021-07-09 2023-06-06 深圳市湘凡科技有限公司 Method for testing hardware products and related equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189666A (en) * 2018-08-02 2019-01-11 腾讯科技(北京)有限公司 Interface test method, device and computer equipment
CN110221948A (en) * 2019-04-18 2019-09-10 深圳壹账通智能科技有限公司 Test script generation method, device, computer installation and storage medium
CN110334021A (en) * 2019-06-25 2019-10-15 深圳前海微众银行股份有限公司 Generation method, device, equipment and the storage medium of interface testing case
CN111309621A (en) * 2020-02-26 2020-06-19 江苏满运软件科技有限公司 Interface test method, system, equipment and storage medium
CN112306855A (en) * 2019-08-02 2021-02-02 北大方正集团有限公司 Interface automation test method, device, terminal and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110737575B (en) * 2018-07-20 2023-09-01 北京金山云网络技术有限公司 Interface testing method and device, electronic equipment and storage medium
CN109766262B (en) * 2018-12-15 2022-05-06 深圳壹账通智能科技有限公司 Interface data processing method, automatic testing method, device, equipment and medium
CN109947646A (en) * 2019-03-13 2019-06-28 平安信托有限责任公司 Interface test method, device, computer equipment and storage medium
CN110781070A (en) * 2019-09-06 2020-02-11 平安科技(深圳)有限公司 Big data test verification method and device, computer equipment and storage medium
CN111666222A (en) * 2020-07-09 2020-09-15 腾讯科技(深圳)有限公司 Test method and related device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189666A (en) * 2018-08-02 2019-01-11 腾讯科技(北京)有限公司 Interface test method, device and computer equipment
CN110221948A (en) * 2019-04-18 2019-09-10 深圳壹账通智能科技有限公司 Test script generation method, device, computer installation and storage medium
CN110334021A (en) * 2019-06-25 2019-10-15 深圳前海微众银行股份有限公司 Generation method, device, equipment and the storage medium of interface testing case
CN112306855A (en) * 2019-08-02 2021-02-02 北大方正集团有限公司 Interface automation test method, device, terminal and storage medium
CN111309621A (en) * 2020-02-26 2020-06-19 江苏满运软件科技有限公司 Interface test method, system, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
聂南 ; 谢晓东 ; 甘勇 ; 卢炎生 ; .基于XML API的组件扩展接口变异测试方法.计算机科学.2008,(第06期),全文. *

Also Published As

Publication number Publication date
CN112948195A (en) 2021-06-11

Similar Documents

Publication Publication Date Title
CN107122258B (en) Method and equipment for checking state code of test interface
CN109684188B (en) Test method and device
CN111221727A (en) Test method, test device, electronic equipment and computer readable medium
CN107632909B (en) Method and system for automatically testing device functions
CN112948195B (en) Interface testing method, device, electronic equipment and storage medium
CN113760697A (en) Interface testing method and device, electronic equipment and storage medium
CN109299124B (en) Method and apparatus for updating a model
CN114546830A (en) Regression testing method, regression testing device, electronic equipment and storage medium
CN107315672B (en) Method and device for monitoring server
CN109656791B (en) gPC performance test method and device based on Jmeter
CN112099814B (en) System and method for managing vehicle-mounted machine application software installation environment
CN114244427A (en) Method and device for checking optical fiber network port resources and computer readable medium
CN110362464B (en) Software analysis method and equipment
CN112084114A (en) Method and apparatus for testing an interface
CN108287792B (en) Method and apparatus for outputting information
CN112988589A (en) Interface testing method, device and system
CN111159988A (en) Model processing method and device, computer equipment and storage medium
CN112579428A (en) Interface testing method and device, electronic equipment and storage medium
CN113420010B (en) Database management method, device, electronic equipment and storage medium
CN113986661A (en) Log output method and device, electronic equipment and storage medium
CN113992491B (en) Application server group operation and maintenance management system, method and device
CN113157558B (en) System testing method and device
CN114449052B (en) Data compression method and device, electronic equipment and storage medium
CN109376023B (en) Method and equipment for generating calling information and issuing return code group
CN114968693A (en) Performance test method and device

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