CN110609792A - Interface testing method and device, computer equipment and storage medium - Google Patents

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

Info

Publication number
CN110609792A
CN110609792A CN201910850723.3A CN201910850723A CN110609792A CN 110609792 A CN110609792 A CN 110609792A CN 201910850723 A CN201910850723 A CN 201910850723A CN 110609792 A CN110609792 A CN 110609792A
Authority
CN
China
Prior art keywords
interface
test
response value
test case
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910850723.3A
Other languages
Chinese (zh)
Inventor
范孝鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dasou Vehicle Software Technology Co Ltd
Original Assignee
Zhejiang Dasou Vehicle Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dasou Vehicle Software Technology Co Ltd filed Critical Zhejiang Dasou Vehicle Software Technology Co Ltd
Priority to CN201910850723.3A priority Critical patent/CN110609792A/en
Publication of CN110609792A publication Critical patent/CN110609792A/en
Pending legal-status Critical Current

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
    • 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/3688Test management for test execution, e.g. scheduling of test suites

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 comprises the following steps: acquiring an interface calling request, wherein the interface calling request comprises an external interface identifier; inquiring a test file corresponding to the external interface identifier in a database; the test file comprises a real response value corresponding to the external interface identifier; and reading the response value in the test file, and feeding the response value back to the test case for unit test to obtain a test result. By adopting the method, the influence of the response value of the third-party service in the test process can be avoided, so that the accuracy of the test result is improved.

Description

Interface testing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to an interface testing method and apparatus, a computer device, and a storage medium.
Background
With the development of internet technology, the types of network applications are more and more, and data testing needs to be performed on the network applications in the early stage or in the using process of various network applications, so that the accuracy and normal use of the network applications are guaranteed.
The traditional testing method is to test the network application by using an automated testing tool. In the automatic testing process, a third-party service is called through a request, and the network application is tested according to the return value of the third-party service.
The traditional test method is easily affected by the return value of the third-party service, so that the accuracy of the test result is reduced.
Disclosure of Invention
In view of the above, it is necessary to provide an interface testing method, an apparatus, a computer device and a storage medium capable of improving the accuracy of the test result.
In a first aspect, the present application provides an interface testing method, including:
acquiring an interface calling request, wherein the interface calling request comprises an external interface identifier;
inquiring a test file corresponding to the external interface identifier in a database; the test file comprises a real response value corresponding to the external interface identifier;
and reading the response value in the test file, and feeding back the response value to the test case for unit test to obtain a test result.
Acquiring an interface calling request, wherein the interface calling request comprises an external interface identifier; and inquiring a test file corresponding to the external interface identifier in a database; and reading the response value in the test file, and feeding the response value back to the test case for unit test to obtain a test result. Because the test file comprises the real response value corresponding to the external interface identification, the response value fed back to the test case is ensured to be accurate and reliable by directly calling the response values corresponding to all the interfaces of the test case in the database, the influence of the response value of the third-party service in the test process is avoided, and the accuracy of the test result is improved.
In one embodiment, before the obtaining the interface call request, the method includes:
and intercepting all interface calls of the test case.
Before the terminal acquires the interface calling request, all interface calls of the test case need to be intercepted, and then the interface calling request is acquired, so that the test case is prevented from calling the third-party service, and the influence of receiving the response value of the third-party service by the test result is avoided.
In one embodiment, before intercepting all interface calls of the test case, the method further includes:
judging the mode of the specific annotation tested by the unit;
and if the mode of the specific annotation is a replay mode, executing the step of acquiring the interface call request.
Before testing, the specific annotation mode of the unit test needs to be judged first, the specific annotation mode is determined, namely the purpose of the unit test is determined, and when the specific annotation mode is a replay mode, the purpose of the unit test is to test a test case to obtain a test result. In the testing process, response values corresponding to all interface calls of the test case in the database can be directly called for testing, so that an accurate testing result is ensured to be obtained.
In one embodiment, the method further comprises:
if the mode of the specific annotation is a recording mode, intercepting all interface calls of the test case to obtain an interface call request, wherein the interface call request comprises an external interface identifier;
sending the interface calling request to the third-party service;
receiving a response value returned by the third-party service according to the interface calling request;
and storing the response value and the interface calling request into the database.
If the specific annotation of the unit test is judged to be the recording mode, the unit test aims to record response values called by all interfaces of the test case. Intercepting all interface calls of the test case, sending an interface call request to a third-party service by using a test tool, receiving a response value returned to the test case by the third-party service, and storing the response value and the interface call request. When the test case is tested, the response value in the database can be directly called, the response value fed back to the test case is accurate and reliable, and the test use time is shortened.
In one embodiment, the storing the response value and the interface call request in the database includes:
taking the external interface name called by the interface calling request as a file name, and storing the response value and the interface calling request to a database;
and returning the response value to the test case.
The external interface name called by the interface calling request is used as a response value and a file name of the interface calling request, and when a unit is tested, in the process of inquiring a test file corresponding to the external interface identifier in a database, the file is convenient to inquire, the time for a test case to obtain the response value returned by the third-party service is reduced, the test time is shortened, and the test efficiency is improved.
In one embodiment, before storing the response value and the interface call request in the database, the method further includes:
calling a preset check function to check the response value;
and if the verification is passed, executing the step of storing the response value and the interface calling request into the database, and modifying the recording mode of the specific annotation into a playback mode.
In order to ensure that the response value in the test file stored in the recording mode is accurate and reliable, the stored response value is verified by calling the verification function, so that the response value fed back to the test case in the playback mode is accurate and reliable. After the test files corresponding to all the external interface identifications are recorded, the recording mode of the specific annotation is changed into a replay mode, the test case is tested, and the test files stored in the recording mode are utilized, so that the influence of the response value of a third party service in the test process is avoided, and the accuracy of the test result is improved.
In one embodiment, the feeding back the response value to the test case for unit test to obtain a test result includes:
comparing the result obtained by the unit test of the test case with the response value;
and if the result obtained by the unit test of the test case is consistent with the response value, the test is passed.
The result obtained by carrying out unit test on the test case is compared with the response value, if the comparison result is consistent, the test case passes the test, and the test result obtained by the method is not influenced by the response value of the third-party service, so that the method has higher accuracy.
In a second aspect, the present application provides an interface testing apparatus, the apparatus comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an interface calling request, and the interface calling request comprises an external interface identifier;
the query module is used for querying the test file corresponding to the external interface identifier in a database; the test file comprises a real response value corresponding to the external interface identifier;
and the reading module is used for reading the response value in the test file and feeding the response value back to the test case for unit test to obtain a test result.
In a third aspect, the present application provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the interface testing method according to any one of the first aspect when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of any of the interface testing methods of the first aspect.
The interface testing method, the interface testing device, the computer equipment and the storage medium have the following beneficial effects that:
acquiring an interface calling request, wherein the interface calling request comprises an external interface identifier; and inquiring a test file corresponding to the external interface identifier in a database; and reading the response value in the test file, and feeding the response value back to the test case for unit test to obtain a test result. Because the test file comprises the real response value corresponding to the external interface identification, the response value fed back to the test case is ensured to be accurate and reliable by directly calling the response values corresponding to all the interfaces of the test case in the database, the influence of the response value of the third-party service in the test process is avoided, and the accuracy of the test result is improved.
Drawings
Fig. 1 is an application environment diagram of an interface testing method in an embodiment of the present application;
fig. 2 is a schematic flowchart of an interface testing method provided in an embodiment of the present application;
FIG. 3 is a block diagram of a replay mode of an interface testing method provided in an embodiment of the present application;
fig. 4 is a schematic flowchart of another interface testing method provided in the embodiment of the present application;
fig. 5 is a block diagram of a recording mode of an interface testing method provided in an embodiment of the present application;
fig. 6 is a schematic flowchart of another interface testing method provided in the embodiment of the present application;
FIG. 7 is a block diagram of an interface testing apparatus provided in an embodiment of the present application;
FIG. 8 is a block diagram of another interface test apparatus provided in an embodiment of the present application;
FIG. 9 is a block diagram of another interface test apparatus provided in an embodiment of the present application;
fig. 10 is an internal structural diagram of a computer device provided in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The interface testing method provided by the application can be applied to the application environment shown in fig. 1. The terminal 101 and the third-party service 102 communicate through a network, the terminal 101 may be but is not limited to various personal computers, laptops, smartphones, tablets and portable wearable devices, and the third-party service 102 may be implemented by an independent server or a server cluster formed by a plurality of servers.
In an embodiment, as shown in fig. 2, an interface testing method is provided, which is described by taking the method as an example applied to the terminal in fig. 1, and includes the following steps:
s201, obtaining an interface calling request, wherein the interface calling request comprises an external interface identifier.
The interface calling request is used for requesting to call an interface of the third-party service so as to obtain a result fed back by the third-party service according to the interface calling request.
In this embodiment, in the unit test process, when the test case calls the external interface, the terminal may obtain all interface call requests of the test case, or obtain only part of the interface call requests of the test case, where the interface call requests include the external interface identifier. For example, the identifier of the external interface to be tested is labeled, and when the jmoclit tool detects that the interface calling request includes the labeled external interface identifier, the labeled external interface calling request is obtained. For example, a jmoclit tool is used to obtain all of the dubbo or hypertext Transfer Protocol (HTTP) call corresponding interface call requests of the test cases. Or marking the identifier of the dubbo calling interface of the test case, and acquiring an interface calling request corresponding to the dubbo calling through a jmoclit tool.
S202, inquiring a test file corresponding to the external interface identifier in a database; the test file comprises a real response value corresponding to the external interface identification.
In this embodiment, according to the interface call request acquired in S201, a test file corresponding to the external interface identifier is queried in the database, where the test file includes a real response value fed back by the interface call corresponding to the external interface identifier, and the response value is an accurate and reliable return value obtained from the third-party service by testing the test case when the third-party service operates normally. For example, the test case wants to obtain a user name through an interface call request, and queries a test file corresponding to an external interface identifier in a database according to the interface call request including the external interface identifier, wherein a response value in the test file is an accurate and reliable user name obtained from a third-party service when the third-party service operates normally.
S203, reading the response value in the test file, and feeding back the response value to the test case for unit test to obtain a test result.
Wherein the test result comprises a test pass and a test fail. The test shows that the test case can normally run and can be put into use; the test fails to show that the test case has errors or the external interface has faults, and the test case still needs to be improved and cannot be put into use.
In this embodiment, after the test file is queried in the database, the response value in the test file is read, and after the response value is fed back to the test case, the unit test is continuously executed to obtain the test result. For example, if the response value in the read test file includes a user name, the user name is fed back to the test case, and then the unit test is continuously executed to obtain a test result.
The interface testing method provided by the embodiment of the application obtains an interface calling request, wherein the interface calling request comprises an external interface identifier; and inquiring a test file corresponding to the external interface identifier in a database; and reading the response value in the test file, and feeding the response value back to the test case for unit test to obtain a test result. Because the test file comprises the real response value corresponding to the external interface identification, the response value fed back to the test case is ensured to be accurate and reliable by directly calling the response values corresponding to all the interfaces of the test case in the database, the influence of the response value of the third-party service in the test process is avoided, and the accuracy of the test result is improved.
In the embodiment shown in fig. 2, at step S201, an interface call request is obtained. Before, optionally, all interface calls of the test case are intercepted.
In this embodiment, in order to prevent the test case from calling an external real interface, that is, calling a third-party service, before obtaining an interface call request, the interface call of the test case needs to be intercepted, and a corresponding interface call request is obtained according to the intercepted interface call of the test case. Preferably, all interface calls of the test case can be intercepted, or only part of the interface calls of the test case can be intercepted. For example, all dubbo or hypertext Transfer Protocol (HTTP) calls of the test cases are intercepted by the jmoclit tool. Or marking the identifier of the dubbo calling interface of the test case, and intercepting only the dubbo calling of the test case through a jmockut tool.
According to the interface testing method provided by the embodiment of the application, all interface calls of the test case need to be intercepted before the terminal acquires the interface call request, and then the interface call request is acquired, so that the test case is prevented from calling the third-party service, and therefore the influence of the test result on the response value of the third-party service is avoided.
In the embodiment shown in fig. 2, at step S203, the response value in the test file is read. "the read response value is pre-recorded and stored in the database, and is directly called during testing. Therefore, all interface calls to the test case are intercepted at. Before, optionally, the mode of the specific annotation of the unit test can also be judged.
The specific annotation is to add an annotation on the unit test method, for example, to add a piece of program code on the unit test method, and the mode of the specific annotation includes a recording mode or a playback mode.
In this embodiment, before the unit test is performed, the specific annotation pattern is determined, and the specific annotation pattern determines the purpose of the unit test. When the specific annotated mode is a recording mode, the purpose of the unit test is to record response values called by all interfaces of the test case; when the specific annotated mode is a replay mode, the purpose of the unit test is to test the test case to obtain a test result.
In the above embodiments, the modes of the specific annotation include both a recording mode and a playback mode, and the two modes of the specific annotation will be further described in detail.
In the first case, if the mode of the specific annotation is the replay mode, the step of obtaining the interface call request is performed.
In this embodiment, after determining the pattern of the specific annotation tested by the unit this time, if the pattern of the specific annotation is the replay pattern, step S201 in fig. 2 is executed to obtain the interface call request. ". And then, the steps in fig. 2 are sequentially executed, and finally, a test result is obtained.
In this embodiment, as shown in fig. 3, a mode of a specific annotation is a process in a replay mode, and a first representation in fig. 3 is that a terminal intercepts all interface calls of a test case by using a jmockut tool to obtain an interface call request; secondly, the terminal queries a test file corresponding to the external interface identifier in a database according to the interface calling request acquired in the step one through a jmockut tool; and thirdly, reading the response value in the test file, and returning the response value to the test case for unit test to obtain a test result.
In the interface test method provided in the embodiment of the present application, before the test, the specific annotation pattern of the unit test needs to be determined, and the specific annotation pattern is determined, that is, the purpose of the unit test is determined. When the specific annotated mode is a replay mode, the purpose of the unit test is to test the test case to obtain a test result. In the testing process, response values corresponding to all interface calls of the test case in the database can be directly called for testing, so that an accurate testing result is ensured to be obtained.
In the second case, if the specific annotated mode is a recording mode, the purpose of the unit test is to record response values called by all interfaces of the test case, as shown in fig. 4, which specifically includes the following steps:
s401, intercepting all interface calls of the test case, and acquiring an interface call request, wherein the interface call request comprises an external interface identifier.
The interface calling request is used for requesting to call an interface of the third-party service so as to obtain a result fed back by the third-party service according to the interface calling request.
In this embodiment, the terminal intercepts all interface calls of the test case, or the terminal intercepts only the labeled interface call request, so as to avoid the test case calling an external real interface and obtain a corresponding interface call request, where the interface call request includes an external interface identifier. For example, the identifier of the external interface to be tested is labeled, and when the jmoclit tool detects that the interface call request includes the labeled external interface identifier, the interface call request is intercepted. For example, a jmoclit tool intercepts all of the dubbo or hypertext transfer Protocol (HTTP) calls of the test cases, and obtains an interface call request corresponding to all of the dubbo or HTTP calls of the test cases. Or intercepting only part of dubbo call of the test case by the jmoclit tool to obtain an interface call request corresponding to the dubbo call, so as to avoid the test case from calling an external real interface.
S402, sending the interface calling request to a third-party service.
In this embodiment, according to the interface call request acquired in S401, the interface call request is sent to the third-party service, and an interface of the third-party service is called. For example, the request parameter in the interface call request is transmitted to the third-party service through the jmoclit tool, and the transmission method may be a communication method such as hypertext transfer Protocol (HTTP) or 4G.
And S403, receiving a response value returned by the third-party service according to the interface calling request.
In this embodiment, after the interface call request is sent to the third-party service, the third-party service calls a corresponding interface according to the interface call request, and the terminal receives a response value returned by the third-party service, for example, after the interface call request acquired in S401 is sent to the third-party service by using a jmoclit tool, if the interface call request is to acquire a user name by calling a third-party service interface, the terminal receives the user name returned by the third-party server according to the interface call request.
And S404, storing the response value and the interface calling request into a database.
In this embodiment, after receiving a response value returned by the third-party service, the terminal feeds back the response value to the test case, and stores the interface invocation request and the corresponding response value in the database, and when the test case is tested and the interface is invoked by the test case, the terminal can directly invoke the response value in the database and feed back the response value to the test case for testing.
In this embodiment, as shown in fig. 5, a specific annotation mode is a process in a recording mode, and [1] in fig. 5 shows that a terminal intercepts all interface calls of a test case by using a jmoclit tool to obtain an interface call request; [2] the terminal sends the interface calling request acquired in the step (1) to a third-party service through a jmoclit tool; [3] the terminal receives a response value returned by the third-party service according to the interface calling request by using a jmoclit tool; [4] the terminal stores the interface calling request obtained in the step (1) and the corresponding response value received in the step (3) into a database through a jmoclit tool, and takes the external interface name called by the interface calling request as a file name; [5] it is shown that the terminal returns the response values stored in the database to the test case using the jmockut tool.
According to the interface test method provided by the embodiment of the application, if the specific annotation mode of the unit test is judged to be the recording mode, the unit test aims to record the response values called by all the interfaces of the test case. Intercepting all interface calls of the test case, sending an interface call request to a third-party service by using a test tool, receiving a response value returned to the test case by the third-party service, and storing the response value and the interface call request. When the test case is tested, the response value in the database can be directly called, the response value fed back to the test case is accurate and reliable, and the test use time is shortened.
On the basis of the embodiments shown in fig. 2 to 5, the response value and the interface call request are optionally stored in the database, as shown in fig. 6, and the storage process of the response value and the interface call request will be further explained below.
S601, taking the external interface name called by the interface calling request as a file name, and storing the response value and the interface calling request to a database.
In this embodiment, when the terminal receives a response value returned by the third-party service, the response value and the corresponding interface calling request are stored, and in the storage process, for convenience of querying and avoiding confusion of file naming, an external interface name called by the interface calling request is taken as a file name. For example, when the name of the third-party service interface called by the interface calling request is ABC, the corresponding response value and the test file stored by the interface calling request are named ABC.
And S602, returning the response value to the test case.
In this embodiment, after the response value and the corresponding interface test request are stored in the database, the response value is fed back to the test case, and the test unit is continuously executed. For example, if the response value received by the terminal is the user name, the user name and the corresponding interface call request are stored, and then the user name is fed back to the test file to continue executing the test unit.
According to the interface testing method, the external interface name called by the interface calling request is used as the response value and the file name of the interface calling request, file inquiry is facilitated in the process of inquiring the test file corresponding to the external interface identifier in the database during unit testing, the time for obtaining the response value returned by the third-party service by the test case is reduced, the testing time is shortened, and the testing efficiency is improved.
In the embodiment shown in fig. 4, the response value and the interface call request are stored in the database at step S404. Before, optionally, a preset check function is called to check the response value, so as to ensure the accuracy and reliability of the response value, and the following further explains the check process of the response value.
In this embodiment, after receiving the response value returned by the third-party service, the terminal invokes a preset verification function to verify the response value, optionally, if the verification is passed, the step of storing the response value and the interface invocation request in the database is executed, and the recording mode of the specific annotation is modified into the playback mode. Only if the received response value is accurate and reliable, the response value and the interface call request are stored in the database. And after recording response values called by all interfaces of the test case, modifying the recording mode of the specific annotation into a replay mode, and then carrying out unit test on the test case. For example, the response value received by the terminal is the user name XYZ, the user name XYZ is verified through the verification function, and if the verification is passed, the response value and the interface call request are stored, and the mode of the specific annotation is modified.
According to the interface testing method provided by the embodiment of the application, in order to ensure that the response value in the test file stored in the recording mode is accurate and reliable, the stored response value is verified by calling the verification function, so that the response value fed back to the test case in the playback mode is accurate and reliable. After the test files corresponding to all the external interface identifications are recorded, the recording mode of the specific annotation is changed into a replay mode, the test case is tested, and the test files stored in the recording mode are utilized, so that the influence of the response value of a third party service in the test process is avoided, and the accuracy of the test result is improved.
On the basis of the embodiments shown in fig. 2 to 6, step S203 in fig. 2 is further performed to feed back the response value to the test case for unit test, so as to obtain a test result. "explain, optionally, compare the result that the test case carries on the unit test with response value.
In this embodiment, after the unit test is performed on the test case to obtain the unit test result, the result is compared with the response value, and if the result obtained by performing the unit test on the test case is consistent with the response value, the test is passed. For example, if the result obtained by the test of the test case execution unit is user name XYZ, the user name XYZ is compared with the response value, and if the comparison result matches, the test performed on the test case passes.
According to the interface testing method provided by the embodiment of the application, the result obtained by carrying out unit testing on the test case is compared with the response value, if the comparison result is consistent, the test case passes the test, and the test result obtained by the method is not subjected to the response value of a third party service, so that the accuracy is higher.
It should be understood that although the various steps in the flow charts of fig. 1-6 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1-6 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 7, there is provided an interface apparatus 700 comprising: an obtaining module 701, an inquiring module 702 and a reading module 703, wherein:
the obtaining module 701 is configured to obtain an interface call request, where the interface call request includes an external interface identifier.
A query module 702, configured to query a database for a test file corresponding to the external interface identifier; the test file comprises a real response value corresponding to the external interface identification.
The reading module 703 is configured to read a response value in the test file, and feed back the response value to the test case for performing the unit test to obtain a test result.
In one embodiment, as shown in fig. 8, the apparatus further comprises:
and the intercepting module 704 is used for intercepting all interface calls of the test case.
In one embodiment, as shown in fig. 8, the apparatus further comprises:
the judging module 705 is used for judging the mode of the specific annotation of the unit test.
If the mode of the specific annotation is the replay mode, the obtaining module 701 is triggered to execute the step of obtaining the interface call request.
In an embodiment, if the mode of the specific annotation is a recording mode, the triggering and intercepting module 704 is configured to intercept all interface calls of the test case, and the triggering and obtaining module 701 is further configured to obtain an interface call request, where the interface call request includes an external interface identifier. As shown in fig. 8, the apparatus further includes:
a sending module 706, configured to send the interface call request to a third party service.
And the receiving module 707 is configured to receive a response value returned by the third-party service according to the interface call request.
A storage module 708, configured to store the response value and the interface call request in a database.
In one embodiment, as shown in FIG. 9, the storage module 708 comprises:
the storage unit 7081 is configured to store the response value and the interface call request in the database by using the external interface name called by the interface call request as a file name.
Returning unit 7082 is configured to return the response value to the test case.
In one embodiment, as shown in fig. 8, the apparatus further comprises:
the verifying module 709 is configured to invoke a preset verifying function to verify the response value.
If the check is passed, the trigger storage module 708 is configured to perform the step of storing the response value and the interface call request in the database.
A modification module 7010 for modifying the recording mode of the specific annotation to a playback mode.
In one embodiment, as shown in fig. 9, the reading module 703 includes:
a comparison unit 7031 configured to compare a result obtained by performing a unit test on the test case with the response value; and if the result obtained by the unit test of the test case is consistent with the response value, the test is passed.
For the specific definition of the interface testing device, reference may be made to the definition of the interface testing method above, and details are not described here. The modules in the interface testing device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 10. 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 comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing interface test 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 testing method.
Those skilled in the art will appreciate that the architecture shown in fig. 10 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring an interface calling request, wherein the interface calling request comprises an external interface identifier; inquiring a test file corresponding to the external interface identifier in a database; the test file comprises a real response value corresponding to the external interface identifier; and reading the response value in the test file, and feeding the response value back to the test case for unit test to obtain a test result.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
before obtaining the interface call request, the method further comprises: and intercepting all interface calls of the test case.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
before intercepting all interface calls of the test case, the method further comprises the following steps: judging the mode of the specific annotation tested by the unit; and if the mode of the specific annotation is a replay mode, executing the step of acquiring the interface call request.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
if the specific annotation mode is a recording mode, intercepting all interface calls of the test case to obtain an interface call request, wherein the interface call request comprises an external interface identifier; sending the interface calling request to a third-party service; receiving a response value returned by the third-party service according to the interface calling request; and storing the response value and the interface calling request into a database.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
storing the response value and the interface call request into a database, including: taking the external interface name called by the interface calling request as a file name, and storing the response value and the interface calling request into a database; and returning the response value to the test case.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
before storing the response value and the interface call request in the database, the method further comprises: calling a preset check function to check the response value; and if the verification is passed, executing the step of storing the response value and the interface calling request into the database, and modifying the recording mode of the specific annotation into a playback mode.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and feeding back the response value to the test case for unit test to obtain a test result, wherein the test result comprises the following steps: comparing the result obtained by the unit test of the test case with the response value; and if the result obtained by the unit test of the test case is consistent with the response value, the test is passed.
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:
acquiring an interface calling request, wherein the interface calling request comprises an external interface identifier; inquiring a test file corresponding to the external interface identifier in a database; the test file comprises a real response value corresponding to the external interface identifier; and reading the response value in the test file, and feeding the response value back to the test case for unit test to obtain a test result.
In one embodiment, the computer program when executed by the processor further performs the steps of:
before obtaining the interface call request, the method further comprises: and intercepting all interface calls of the test case.
In one embodiment, the computer program when executed by the processor further performs the steps of:
before intercepting all interface calls of the test case, the method further comprises the following steps: judging the mode of the specific annotation tested by the unit; and if the mode of the specific annotation is a replay mode, executing the step of acquiring the interface call request.
In one embodiment, the computer program when executed by the processor further performs the steps of:
if the specific annotation mode is a recording mode, intercepting all interface calls of the test case, and acquiring an interface call request, wherein the interface call request comprises an external interface identifier; sending the interface calling request to a third-party service; receiving a response value returned by the third-party service according to the interface calling request; and storing the response value and the interface calling request into a database.
In one embodiment, the computer program when executed by the processor further performs the steps of: storing the response value and the interface call request into a database, including: taking the external interface name called by the interface calling request as a file name, and storing the response value and the interface calling request into a database; and returning the response value to the test case.
In one embodiment, the computer program when executed by the processor further performs the steps of: before storing the response value and the interface call request in the database, the method further comprises: calling a preset check function to check the response value; and if the verification is passed, executing the step of storing the response value and the interface calling request into the database, and modifying the recording mode of the specific annotation into a playback mode.
In one embodiment, the computer program when executed by the processor further performs the steps of: and feeding back the response value to the test case for unit test to obtain a test result, wherein the test result comprises the following steps: comparing the result obtained by the unit test of the test case with the response value; and if the result obtained by the unit test of the test case is consistent with the response value, the test is passed.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile 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), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. An interface testing method, the method comprising:
acquiring an interface calling request, wherein the interface calling request comprises an external interface identifier;
inquiring a test file corresponding to the external interface identifier in a database; the test file comprises a real response value corresponding to the external interface identifier;
and reading the response value in the test file, and feeding back the response value to the test case for unit test to obtain a test result.
2. The method of claim 1, wherein before the obtaining the interface call request, further comprising:
and intercepting all interface calls of the test case.
3. The method according to claim 1 or 2, wherein before intercepting all interface calls of the test case, further comprising:
judging the mode of the specific annotation tested by the unit;
and if the mode of the specific annotation is a replay mode, executing the step of acquiring the interface call request.
4. The method of claim 3, further comprising:
if the mode of the specific annotation is a recording mode, intercepting all interface calls of the test case to obtain an interface call request, wherein the interface call request comprises an external interface identifier;
sending the interface calling request to the third-party service;
receiving a response value returned by the third-party service according to the interface calling request;
and storing the response value and the interface calling request into the database.
5. The method of claim 4, wherein storing the response value and the interface call request in the database comprises:
taking the external interface name called by the interface calling request as a file name, and storing the response value and the interface calling request to a database;
and returning the response value to the test case.
6. The method of claim 4, wherein prior to storing the response value and the interface call request in the database, further comprising:
calling a preset check function to check the response value;
and if the verification is passed, executing the step of storing the response value and the interface calling request into the database, and modifying the recording mode of the specific annotation into a playback mode.
7. The method according to claim 1, wherein feeding back the response value to the test case for unit testing to obtain a test result comprises:
comparing the result obtained by the unit test of the test case with the response value;
and if the result obtained by the unit test of the test case is consistent with the response value, the test is passed.
8. A unit testing apparatus, the apparatus comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an interface calling request, and the interface calling request comprises an external interface identifier;
the query module is used for querying the test file corresponding to the external interface identifier in a database; the test file comprises a real response value corresponding to the external interface identifier;
and the reading module is used for reading the response value in the test file and feeding the response value back to the test case for unit test to obtain a test result.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the interface test method according to any of claims 1 to 7 are implemented by the processor when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the interface testing method according to any one of claims 1 to 7.
CN201910850723.3A 2019-09-10 2019-09-10 Interface testing method and device, computer equipment and storage medium Pending CN110609792A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910850723.3A CN110609792A (en) 2019-09-10 2019-09-10 Interface testing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910850723.3A CN110609792A (en) 2019-09-10 2019-09-10 Interface testing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN110609792A true CN110609792A (en) 2019-12-24

Family

ID=68892791

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910850723.3A Pending CN110609792A (en) 2019-09-10 2019-09-10 Interface testing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110609792A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767210A (en) * 2020-06-12 2020-10-13 浙江大搜车软件技术有限公司 Policy testing method and device, computer equipment and storage medium
CN113220584A (en) * 2021-05-26 2021-08-06 京东科技控股股份有限公司 Page testing method and device, computer equipment and readable storage medium
CN113268421A (en) * 2021-05-21 2021-08-17 中国联合网络通信集团有限公司 Service call processing method, device, server and storage medium
CN114297084A (en) * 2021-12-31 2022-04-08 北京航天驭星科技有限公司 Method and device for testing satellite test, operation and control data interface, electronic equipment and medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685354A (en) * 2012-09-05 2014-03-26 百度在线网络技术(北京)有限公司 Method and device for testing based on RMI protocol
CN105515883A (en) * 2014-09-22 2016-04-20 阿里巴巴集团控股有限公司 Test method and system
CN109189665A (en) * 2018-08-01 2019-01-11 阿里巴巴集团控股有限公司 Data recording, data readback and the method and device tested automatically
CN109446063A (en) * 2018-09-18 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, device, computer equipment and storage medium
CN109656806A (en) * 2018-10-29 2019-04-19 口碑(上海)信息技术有限公司 A kind of the playback test method and device of interface data
CN110134597A (en) * 2019-04-25 2019-08-16 阿里巴巴集团控股有限公司 The regression testing method and its system of operation system fund security

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685354A (en) * 2012-09-05 2014-03-26 百度在线网络技术(北京)有限公司 Method and device for testing based on RMI protocol
CN105515883A (en) * 2014-09-22 2016-04-20 阿里巴巴集团控股有限公司 Test method and system
CN109189665A (en) * 2018-08-01 2019-01-11 阿里巴巴集团控股有限公司 Data recording, data readback and the method and device tested automatically
CN109446063A (en) * 2018-09-18 2019-03-08 深圳壹账通智能科技有限公司 Interface test method, device, computer equipment and storage medium
CN109656806A (en) * 2018-10-29 2019-04-19 口碑(上海)信息技术有限公司 A kind of the playback test method and device of interface data
CN110134597A (en) * 2019-04-25 2019-08-16 阿里巴巴集团控股有限公司 The regression testing method and its system of operation system fund security

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767210A (en) * 2020-06-12 2020-10-13 浙江大搜车软件技术有限公司 Policy testing method and device, computer equipment and storage medium
CN113268421A (en) * 2021-05-21 2021-08-17 中国联合网络通信集团有限公司 Service call processing method, device, server and storage medium
CN113220584A (en) * 2021-05-26 2021-08-06 京东科技控股股份有限公司 Page testing method and device, computer equipment and readable storage medium
CN114297084A (en) * 2021-12-31 2022-04-08 北京航天驭星科技有限公司 Method and device for testing satellite test, operation and control data interface, electronic equipment and medium

Similar Documents

Publication Publication Date Title
CN110609792A (en) Interface testing method and device, computer equipment and storage medium
CN110647438B (en) Event monitoring method and device, computer equipment and storage medium
CN109460527B (en) Product data configuration method, device, computer equipment and storage medium
CN108573371B (en) Data approval method, device, computer equipment and storage medium
CN109766256B (en) Method and device for testing H5 page performance in application program and computer equipment
CN110765001B (en) Modularized automatic test method and device for application system
CN110633160A (en) Interface calling method and device, computer equipment and storage medium
CN109726134B (en) Interface test method and system
CN110083384B (en) Application programming interface creating method and device
CN110659938A (en) Method and device for determining promotion channel, computer equipment and storage medium
CN108966159B (en) Short message withdrawing method, system, computer equipment and storage medium
CN111343630A (en) Network connection state detection method, computer device, and storage medium
CN110598452A (en) Evidence information processing method and device based on block chain, storage medium and equipment
CN112699034B (en) Virtual login user construction method, device, equipment and storage medium
CN111159025B (en) Application program interface testing method and device, computer equipment and storage medium
CN112788545A (en) Binding method, computer device and storage medium
CN110597782A (en) Database dynamic switching method and device, computer equipment and storage medium
CN112486824B (en) Case code generation method, device, computer equipment and storage medium
CN110704218B (en) Data processing method, data processing device, computer equipment and storage medium
CN112583890B (en) Message pushing method and device based on enterprise office system and computer equipment
WO2021248310A1 (en) Method and apparatus for acquiring service calling information, and vulnerability test method for service
CN111090583B (en) Method and device for generating code coverage rate report and computer equipment
CN107566211B (en) Method, device and system for accessing test equipment
CN112783866A (en) Data reading method and device, computer equipment and storage medium
CN111814145A (en) Request verification method and device based on log acquisition and computer equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20191224

RJ01 Rejection of invention patent application after publication