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

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

Info

Publication number
CN110737575B
CN110737575B CN201810801940.9A CN201810801940A CN110737575B CN 110737575 B CN110737575 B CN 110737575B CN 201810801940 A CN201810801940 A CN 201810801940A CN 110737575 B CN110737575 B CN 110737575B
Authority
CN
China
Prior art keywords
interface
target interface
target
tested
interfaces
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
CN201810801940.9A
Other languages
Chinese (zh)
Other versions
CN110737575A (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.)
Beijing Jinxun Ruibo Network Technology Co Ltd
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Original Assignee
Beijing Jinxun Ruibo Network Technology Co Ltd
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud 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 Beijing Jinxun Ruibo Network Technology Co Ltd, Beijing Kingsoft Cloud Network Technology Co Ltd, Beijing Kingsoft Cloud Technology Co Ltd filed Critical Beijing Jinxun Ruibo Network Technology Co Ltd
Priority to CN201810801940.9A priority Critical patent/CN110737575B/en
Publication of CN110737575A publication Critical patent/CN110737575A/en
Application granted granted Critical
Publication of CN110737575B publication Critical patent/CN110737575B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • 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/3692Test management for test results analysis
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

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 embodiment of the invention provides an interface testing method, an interface testing device, electronic equipment and a storage medium. The method comprises the following steps: determining a first target interface in a plurality of interfaces to be tested; invoking the first target interface to process a first data object; selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information, wherein the second target interface is the next target interface of the first target interface; the interface conversion information describes a calling combination relation among the interfaces to be tested in the plurality of interfaces to be tested; and calling the second target interface to process the first data object. The interface conversion information preset in the embodiment of the invention is applied to determine the calling sequence of a plurality of interfaces to be tested, so that the construction of test cases and the interface test can be automatically completed, and the manpower and the test time can be reduced.

Description

Interface testing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of testing, and in particular, to an interface testing method, an apparatus, an electronic device, and a storage medium.
Background
In the distributed storage system, there are multiple interfaces, each interface has a certain function, for example, the uploading interface can upload files, the downloading interface can download files, and the corresponding function of the interface can be realized by calling the interface.
In order to test whether the interface is normal or not, namely whether the interface can be normally called or not, the interface can be used for combining into a test case, and a data object is tested by using the test case;
for the construction of the test case, the traditional method is that a plurality of interfaces are constructed into the test case manually by a tester, and then the test case is utilized for manual test.
However, manual construction of test cases and manual testing requires a lot of labor and testing time.
Disclosure of Invention
The embodiment of the invention aims to provide an interface testing method, an interface testing device, electronic equipment and a storage medium, so as to achieve the purpose of reducing manpower and testing time. The technical proposal is as follows:
in a first aspect, an embodiment of the present invention provides an interface testing method, where the method includes:
determining a first target interface in a plurality of interfaces to be tested; invoking the first target interface to process a first data object; selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information, wherein the second target interface is the next target interface of the first target interface; the interface conversion information describes a calling combination relation among the interfaces to be tested in the plurality of interfaces to be tested; and calling the second target interface to process the first data object.
Optionally, after invoking the first target interface and processing the first data object, the method further includes: generating a state code of the first target interface, wherein the state code of the first target interface is used for determining a test result of the first target interface; after invoking the second target interface to process the first data object, the method further comprises: and generating a state code of the second target interface, wherein the state code of the second target interface is used for determining a test result of the second target interface.
Optionally, before selecting an interface from the plurality of interfaces to be tested as the second target interface based on the preset interface conversion information, the method further includes: judging whether a preset condition is met or not; under the condition that the preset condition is not met, selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information; wherein the preset condition includes at least one of: the selected first target interface is a preset ending interface, and the number of times of calling the target interface is greater than or equal to the preset number of times.
Optionally, after determining whether the preset condition is met, the method further includes: and under the condition that the preset condition is met, determining a test result of the first target interface based on the state code of the first target interface.
Optionally, the status code includes a function status code and/or a verification status code, where the function status code is used to indicate whether a process of executing a function implementation function of a target interface corresponding to the function status code is successful; the verification status code is used for verifying whether the function operation result corresponding to the function implementation function of the target interface corresponding to the verification status code is accurate.
Optionally, in a case where the status code includes a verification status code, the generating the status code of the first target interface includes: invoking an attribute verification function of the first target interface, and executing the attribute verification function on a second data object, wherein the second data object is a data object obtained by executing the function implementation function on the first data object; obtaining verification information of the second data object; comparing the verification information with attribute information to obtain a comparison result, wherein the attribute information is: attribute information of the first data object; and generating the verification status code based on the comparison result.
Optionally, based on the preset interface conversion information, selecting an interface from the plurality of interfaces to be tested as the second target interface includes: acquiring first auxiliary information; and determining an interface matched with the first auxiliary information as the second target interface in the interfaces to be tested based on the interface conversion information.
Optionally, the first auxiliary information includes: a random number, wherein the value of the random number is between 0 and 1; the interface conversion information includes: and the interface conversion probability table is recorded with the probability of converting each interface to be tested to each interface to be tested.
Optionally, the determining, based on the interface conversion information, an interface matching the first auxiliary information among the plurality of interfaces to be tested as the second target interface includes: acquiring an interface conversion probability sequence corresponding to the first target interface based on the interface conversion probability table, wherein the interface conversion probability sequence contains the probability of converting the first target interface to each interface to be tested; executing accumulation processing on probabilities in the interface conversion probability sequence, and detecting whether the current accumulation result is larger than the random number in real time in the accumulation process; and when the current accumulation result is detected to be larger than the random number, taking an interface corresponding to the last probability accumulated in the accumulation process as the second target interface.
Optionally, the determining, based on the status code of the first target interface, a test result of the first target interface includes: carrying out statistical analysis on the generated state codes of the first target interface to obtain an analysis result, wherein the analysis result comprises the distribution probability of different state codes of the first target interface; and determining a test result of the first target interface based on the analysis result.
In a second aspect, an embodiment of the present invention provides an interface testing apparatus, including: the determining module is used for determining a first target interface in a plurality of interfaces to be tested; the first processing module is used for calling the first target interface and processing the first data object; the selecting module is used for selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information, wherein the second target interface is the next target interface of the first target interface; the interface conversion information describes a calling combination relation among the interfaces to be tested in the plurality of interfaces to be tested; and the second processing module is used for calling the second target interface and processing the first data object.
Optionally, the apparatus further includes: the first generation module is used for generating a state code of the first target interface after calling the first target interface to process a data object, wherein the state code of the first target interface is used for determining a test result of the first target interface; and the second generating module is used for generating a state code of the second target interface after the second target interface is called to process the data object, wherein the state code of the second target interface is used for determining a test result of the second target interface.
Optionally, the apparatus further includes: the judging module is used for judging whether a preset condition is met or not before one interface is selected from the interfaces to be tested to serve as a second target interface based on preset interface conversion information; under the condition that the preset condition is not met, the selection module executes the step of selecting an interface from the interfaces to be tested as a second target interface based on the preset interface conversion information; wherein the preset end condition includes at least one of: the selected first target interface is a preset ending interface, and the number of times of calling the target interface is greater than or equal to the preset number of times.
Optionally, the apparatus further includes: the result determining module is used for determining a test result of the first target interface based on the state code of the first target interface under the condition that the preset condition is met after judging whether the preset condition is met.
Optionally, the status code includes a function status code and/or a verification status code, where the function status code is used to indicate whether a process of executing a function implementation function of a target interface corresponding to the function status code is successful; the verification status code is used for verifying whether the function operation result corresponding to the function implementation function of the target interface corresponding to the verification status code is accurate.
Optionally, the first generating module is configured to call an attribute verification function of the first target interface when the status code includes a verification status code, and execute the attribute verification function on a second data object, where the second data object is a data object obtained by executing the function implementation function on the first data object; obtaining verification information of the second data object; comparing the verification information with attribute information to obtain a comparison result, wherein the attribute information is: attribute information of the first data object; and generating the verification status code based on the comparison result.
Optionally, the selecting module includes: the acquisition sub-module is used for acquiring the first auxiliary information; and the determining submodule is used for determining an interface matched with the first auxiliary information from the interfaces to be tested as the second target interface based on the interface conversion information.
Optionally, the first auxiliary information includes: a random number, wherein the value of the random number is between 0 and 1; the interface conversion information includes: and the interface conversion probability table is recorded with the probability of converting each interface to be tested to each interface to be tested.
Optionally, the determining submodule is configured to: acquiring an interface conversion probability sequence corresponding to the first target interface based on the interface conversion probability table, wherein the interface conversion probability sequence contains the probability of converting the first target interface to each interface to be tested; executing accumulation processing on probabilities in the interface conversion probability sequence, and detecting whether the current accumulation result is larger than the random number in real time in the accumulation process; and when the current accumulation result is detected to be larger than the random number, taking an interface corresponding to the last probability accumulated in the accumulation process as the second target interface.
Optionally, the result determining module is configured to: carrying out statistical analysis on the generated state codes of the first target interface to obtain an analysis result, wherein the analysis result comprises the distribution probability of different state codes of the first target interface; and determining a test result of the first target interface based on the analysis result.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, where the memory is configured to store a computer program; the processor is configured to implement the steps of the interface testing method provided by the embodiment of the present invention when executing the program stored in the memory.
In a fourth aspect, embodiments of the present invention provide a computer readable storage medium having a computer program stored therein, which when executed by a processor implements the steps of the interface testing method provided by the embodiments of the present invention.
In the scheme provided by the embodiment of the invention, the interface conversion information is preset, and describes the calling combination relation among the interfaces to be tested in the interfaces to be tested, so that the calling sequence of the interfaces to be tested can be determined by utilizing the interface conversion information, the interfaces to be tested are sequentially called to process the data object, and the establishment of the test case and the interface test are automatically completed. Therefore, compared with the prior art that a plurality of interfaces are manually constructed into test cases and manual testing is performed, the embodiment of the invention can effectively reduce manpower and testing time.
Of course, it is not necessary for any one product or method of practicing the invention to achieve all of the advantages set forth above at the same time.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of an interface testing method according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of an interface testing method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a status code analysis result;
FIG. 4 is another diagram showing the result of status code analysis;
fig. 5 is a schematic structural diagram of an interface testing device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In order to facilitate understanding of the solution, a scenario in which the embodiments of the present invention are applied will be briefly described here:
the distributed storage system is provided with a plurality of interfaces, each interface has a certain function, for example, an uploading interface can upload files, a downloading interface can download files, and the corresponding function of the interface can be realized by calling the interfaces. In practical use, the interfaces are sequentially invoked during execution of an operation task, such as an operation task: uploading the file, downloading the file and deleting the file, and then the uploading interface, the downloading interface and the deleting interface are sequentially called in the process of executing the operation task.
It is obvious that various operation tasks exist in practical application, for example, the operation tasks can be: downloading the file, uploading the file, deleting the file, or downloading the file, copying the file, and the like. It will be appreciated that different operational tasks call for different combinations and orders of interfaces.
Since the call of the interface is implemented during the execution of the operation task, it is usually performed in a manner of executing the operation task to verify whether the interface is normal, i.e., whether the interface can be normally called. The implementation process can be as follows: and combining a plurality of interfaces into a test case, for example, a test case is used for downloading a file, uploading the file, deleting the file, and testing a data object by using the test case. It can be seen that the process of building test cases and performing the test can be considered as a process of performing operational tasks.
Based on the above thought, the conventional testing method is to manually construct a plurality of interfaces into test cases by a tester, and then manually test the interfaces by using the test cases. However, the conventional test method requires a lot of manpower and test time.
In order to reduce manpower and test time, the embodiment of the invention provides an interface test method, an interface test device, electronic equipment and a storage medium.
It should be noted that, the execution body of the interface testing method provided by the embodiment of the present invention may be an interface testing device, and the interface testing device may be operated in an electronic apparatus. The electronic device may be a management server in a distributed storage system, but is not limited thereto.
Next, an interface testing method provided by the embodiment of the present invention is first described.
As shown in fig. 1, the method for testing an interface provided by the embodiment of the present invention may include the following steps:
s101, determining a first target interface in a plurality of interfaces to be tested.
In a distributed storage system, there are a plurality of interfaces, such as an upload interface, a download interface, a copy interface, and a delete interface.
In the embodiment of the present invention, first, the interface testing device may determine all interfaces in the distributed storage system as the interfaces to be tested, or, of course, may determine that part of the interfaces are the interfaces to be tested according to the test requirements, for example, the selected part of the interfaces may be the interfaces in a certain position range, the interfaces with high calling rate, or the interfaces with high recent failure rate, etc.
Then, a first target interface can be determined from the determined interfaces to be tested, and the first target interface is used as an interface to be called.
In the embodiment of the invention, it is reasonable that the interface testing device can randomly determine one interface as the first target interface or determine a preset interface as the first target interface among a plurality of interfaces to be tested. The manner in which the first target interface is determined among the plurality of interfaces to be tested in the embodiment of the present invention is not limited herein.
It should be noted that the test case may be built by a plurality of target interfaces, and thus the first target interface may be the first target node in the test case, that is, the node that starts the test, or may be an intermediate target node in the test case, but is not limited thereto.
S102, calling the first target interface to process the first data object.
In the embodiment of the present invention, the first data object is a data object to be processed, and the data object may be a file or the like.
It may be understood that, the first target interface is called to process the first data object, and the operation corresponding to the function is executed on the first data object by using the function of the first target interface. For example, the first target interface is an uploading interface, and then, the process of calling the first target interface to process the first data object may be: and uploading the first data object, and the like.
Through the step, the test of the first target interface can be realized through calling the first target interface.
S103, selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information.
In the embodiment of the invention, after the first target interface is called, a second target interface to be called needs to be determined. Wherein the second target interface is a next target interface of the first target interface.
In the embodiment of the present invention, the interface testing device may select an interface from the plurality of interfaces to be tested as the second target interface based on preset interface conversion information. The interface conversion information describes a calling combination relation among the interfaces to be tested in the plurality of interfaces to be tested.
It should be noted that, in the embodiment of the present invention, the preset interface conversion information may be a preset interface calling sequence, etc. The interface testing device can find the next interface of the first target interface in the interface calling sequence, and then uses the found next interface of the first target interface as a second target interface. Of course, in the embodiment of the present invention, the number of preset interface call sequences may be multiple, it may be understood that the interface test device may cooperate with other auxiliary information to determine one interface call sequence among the multiple interface call sequences, then determine the second target interface among the determined interface call sequences, which is reasonable.
S104, calling the second target interface to process the first data object.
This step is similar to S102 and will not be described here.
Through the step, the second target interface can be tested through calling the second target interface.
It can be understood that, in the embodiment of the present invention, through S101-S104, the interface testing device sequentially calls the first target interface, the second target interface, and the like based on the preset interface conversion information, processes the first data object, and forms an execution chain of an operation task, which can be considered as building a test case, and completes the test of the test case.
It should be emphasized that there may be a plurality of interfaces invoked by embodiments of the present invention, and the first target interface and the second target interface are merely examples, and should not be construed as limiting the interfaces invoked by embodiments of the present invention.
In the scheme provided by the embodiment of the invention, the interface conversion information is preset, and describes the calling combination relation among the interfaces to be tested in the interfaces to be tested, so that the calling sequence of the interfaces to be tested can be determined by utilizing the interface conversion information, the interfaces to be tested are sequentially called to process the data object, and the establishment of the test case and the interface test are automatically completed. Therefore, compared with the prior art that a plurality of interfaces are manually constructed into test cases and manual testing is performed, the embodiment of the invention can effectively reduce manpower and testing time.
As another embodiment, referring to fig. 2, fig. 2 is another flow chart of an interface testing method according to an embodiment of the present invention, which may include the following steps:
s201, determining a first target interface in a plurality of interfaces to be tested.
S202, calling the first target interface to process the first data object.
S201 is the same as S101, S202 is the same as S102, and will not be described here.
S203, generating a state code of the first target interface.
In the embodiment of the invention, the state code of the first target interface is used for determining the test result of the first target interface.
Wherein the status code comprises a functional status code and/or a verification status code. The function status code is used for indicating whether the process of executing the function realizing function of the target interface corresponding to the function status code is successful or not; the verification status code is used for verifying whether the function operation result corresponding to the function implementation function of the target interface corresponding to the verification status code is accurate.
In the embodiment of the invention, the state code of the first target interface is generated based on the operation information in the process of calling the first target interface.
The running information may be information used and generated in the process of executing the function and the code corresponding to the first target interface, and information related to the attribute of the first data object and the like acquired and generated in the process of calling the first target interface. Based on the operation information, the interface test device can generate a status code of the first target interface, where the status code is used to indicate whether the function operation of the first target interface is successful or whether the result of the function operation is accurate, for example, the status code of the uploading interface is 0, which indicates that the uploading function operation of the uploading interface is successful, and so on.
The operation of the function implementation function described above may be used to implement a function operation corresponding to the function implementation function, but is not limited thereto.
For layout clarity and solution understanding, the process of generating the status code of the first target interface is described later.
S204, judging whether a preset condition is met, and executing S205 when the preset condition is not met; in the case where the preset condition is satisfied, S209 is performed.
In the embodiment of the present invention, before selecting the next interface to be invoked, whether a preset condition is satisfied may be detected, and when it is detected that the preset condition is not satisfied, the step of S205 of acquiring the first auxiliary information is performed; and when the satisfaction of the preset condition is detected, executing S209 to determine the test result of the target interface based on the generated state code of the target interface.
Wherein the preset condition includes at least one of: the selected first target interface is a preset ending interface, and the number of times of calling the target interface is greater than or equal to the preset number of times. Of course, the preset conditions are not limited to the two kinds.
S205, acquiring first auxiliary information.
In the embodiment of the present invention, the first auxiliary information may be an interface name, or a value representing the interface name, etc.
Optionally, in an embodiment of the present invention, the first auxiliary information may be a random number, where a value of the random number is between 0 and 1. It should be noted that, there are various ways to obtain the random number, for example, to obtain the random number automatically generated by other devices, or to obtain the random number input by the tester, which is not limited to this.
S206, determining an interface matched with the first auxiliary information as a second target interface in the interfaces to be tested based on the interface conversion information.
It should be noted that the preset interface conversion information includes a plurality of interfaces and attribute information corresponding to each interface, for example, the preset interface conversion information may include a name of each interface and a name of a next interface corresponding to each interface; the preset interface conversion information may further include: each interface and the corresponding value of each interface, each interface and the corresponding value of each interface.
It should be noted that, the value corresponding to an interface may be the probability that the interface goes to the corresponding interface, or the probability that the corresponding interface goes to the interface, but is not limited thereto.
Thus, the present step process may be: the interface testing device compares the acquired first auxiliary information with attribute information corresponding to each interface in preset interface conversion information to determine an interface matched with the first auxiliary information as a second target interface. For example, if the first auxiliary information is an interface name B, the interface B is found in the preset interface conversion information, then the next interface C corresponding to the interface B is obtained, and the interface C is determined to be the second target interface.
Notably, during actual use, the probability of a user invoking each interface of the distributed storage system is found to follow the Markov attribute, i.e., the next interface to invoke, in relation to the currently invoked interface. For example, the user currently calls the upload interface and the probability of next calling the download interface is extremely high. The probability of transitioning from the upload interface to the download interface is independent of the operation prior to invoking the upload interface.
Therefore, in one embodiment of the present invention, the preset interface conversion information may be an interface conversion probability table, where the interface conversion probability table records the probability of each interface to be tested converting to each interface to be tested, where each probability in the interface conversion probability table is obtained based on the results of statistical analysis of big data of the call relationships of multiple interfaces.
In an embodiment of the present invention, determining, based on the interface conversion information, an interface matching the first auxiliary information among the plurality of interfaces to be tested as the second target interface may include the following steps:
a1, acquiring an interface conversion probability sequence corresponding to the first target interface based on the interface conversion probability table.
The interface conversion probability sequence contains the probability of converting the first target interface to each interface to be tested.
A2, executing accumulation processing on the probabilities in the interface transition probability sequence, and detecting whether the current accumulation result is larger than the random number in real time in the accumulation process.
A3, when the current accumulation result is detected to be larger than the random number, taking an interface corresponding to the last probability accumulated in the accumulation process as a second target interface.
S207, calling the second target interface to process the first data object.
S207 is the same as S104, and will not be described here.
S208, generating a state code of the second target interface.
The state code of the second target interface is used for determining a test result of the second target interface.
S208 is similar to S203 and will not be described again here.
S209, determining a test result of the target interface based on the state code of the target interface.
It can be understood that, when the target interface is the first target interface, S209 is: determining a test result of the first target interface based on the state code of the first target interface; when the target interface is the second target interface, S209 is: and determining a test result and the like of the second target interface based on the state code of the second target interface.
In the embodiment of the invention, for each target interface, the test result of the target interface can be determined based on the status code of the target interface, for example, the test result of the target interface is determined to be normal according to the status code of the target interface being 0.
Taking a first target interface as an example, the determining, based on the status code of the first target interface, the test result of the first target interface may include the following steps B1 and B2. It should be noted that the process of determining the test results of other target interfaces is similar to the following process.
And B1, carrying out statistical analysis on the generated state codes of the first target interface to obtain an analysis result, wherein the analysis result comprises the distribution probability of different state codes of the first target interface.
Assuming that the first target interface is an uploading interface, the analysis result includes distribution probabilities of different state codes of the first target interface. For example, the analysis result may include: the probability of the uploading interface state code being 0 is 98%, the probability of the state code being 600 is 2%, and the like, which means that the probability of success of the uploading operation is 98% and the probability of failure of the uploading operation is 2% in the process of calling the uploading interface in a certain time period.
And B2, determining a test result of the first target interface based on the analysis result.
After the analysis result of the state code of the first target interface is obtained, the embodiment of the invention can determine the test result of the first target interface based on the analysis result, thereby obtaining the result of whether the first target interface is normal or not. For example, as illustrated in the above example, based on the analysis result that the probability of the status code of the uploading interface is 98% and the probability of the status code is 600 is 2%, it can be determined that the test result of the uploading interface is normal.
It should be noted that, in the embodiment of the present invention, when determining the test result of the first target interface based on the analysis result, the interface test device may set a judgment threshold for the distribution probability of the status code in the analysis result, for example, when the distribution probability of the status code is 0 is greater than 95%, it is determined that the test result of the first target interface is normal, and so on.
Optionally, after the status codes of all the target interfaces are generated, the embodiment of the invention performs statistical analysis on the generated status codes of all the target interfaces uniformly to obtain an overall analysis result, wherein the overall analysis result comprises the distribution probability of different status codes of all the target interfaces; it is then reasonable to determine the test results for each target interface based on the overall analysis results.
In the scheme provided by the embodiment of the invention, the calling sequence of a plurality of interfaces to be tested is determined by utilizing the preset interface conversion information, the construction of test cases and the interface calling are automatically completed, the distribution probability of each state code generated in the interface calling process is counted, and the like, so that the test result of the interfaces to be tested is determined. Therefore, compared with the prior art that a plurality of interfaces are manually constructed into test cases and manual testing is performed, the embodiment of the invention can effectively reduce manpower and testing time.
The status code will be described below by taking the example that the status code includes a functional status code. The remaining steps are not repeated, and only the procedure of steps S202 to S203 in fig. 2 will be described, and steps S202 to S203 may include steps C1 and C2:
And C1, calling a function realization function of the first target interface, and executing the function realization function on the first data object.
This step corresponds to S202.
It may be understood that the function implementation function of the first target interface is a function for implementing the function of the first target interface, and the function of the function implementation function of the uploading interface is an function for implementing the function of uploading, and the function implementation function of the uploading interface is implemented on the first data object, for example, the function implementation function is implemented on the file a, so that the file a can be uploaded.
And C2, after the function implementation function is executed, generating a function state code of the first target interface.
This step corresponds to S203.
After the function implementation function is executed, a function status code of the first target interface can be generated based on the operation information in the calling process of the function implementation function. The function status code is used to indicate whether the process of executing the function implementation function of the first target interface is successful, and may indicate whether the function operation of the first target interface is successful, for example, a function status code of 0 indicates that the process of executing the function implementation function of the first target interface is successful, and a function status code of 600 or other non-0 values may indicate that the process of executing the function implementation function of the first target interface is unsuccessful.
It should be noted that, in the actual testing process, a status code alarm threshold may be preset, for example, 500, and when the functional status code is greater than or equal to 500, the interface testing device may generate alarm information to prompt a tester to perform fault detection.
Accordingly, the process of steps S207-S208 is similar to that described above.
It should be noted that, when the status code includes a functional status code, the embodiment of the present invention may process a scenario of a data object for multiple threads at the same time, and for interface test of the scenario, the interface test device may determine, according to different conditions of each target interface, a test result of each target interface according to an analysis result, where some target interfaces may be: when the probability of the state code being 0 is greater than a preset judgment threshold, for example, 90%, it is determined that the test result of the target interface is normal, and some target interfaces may be: as long as the status code does not generate statistical mutation and no specific error code occurs, the test result of the target interface is determined to be normal, and so on. Of course, after the analysis result is obtained, other linear consistency checking tools and the like can be introduced for further analysis of each status code, and the obtained further analysis result is utilized to determine the test result of each target interface, which is reasonable.
It can be understood that in practice, a plurality of target interfaces may be determined, and the test of each target interface is sequentially implemented, which is illustrated as a procedure in the embodiment of the present invention below:
table 1 below is a table of interface transition probabilities, the first row and first column of table 1 representing the names of interfaces, the values in table 1 being the probabilities of each interface transition to each interface, e.g., 0.7 in the first column: 0.7 to the probability of interface init_mul in the column where 0.7 is located.
In table 1, there are: the functions of the interfaces, such as initiating, uploading, copying, deleting, downloading, ending, and some interfaces implementing other functions, such as interface INIT_MUL, interface UPLOADPART, interface UPLOADPART_COPY, interface LIST_PARTS, interface COMPLETE_MUL, and interface ABORT_MUL, are illustrated, for example, calling interface INIT_MUL may initiate an upload operation of a large file, calling interface UPLOADPART may upload a portion of the content of a large file, calling interface UPLOADPART_COPY may COPY a portion of the content from an existing file, calling interface LIST_PARTS may view the uploaded file block, etc.
TABLE 1
It should be noted that, in table 1, the interface START is a preset START interface, the interface END is a preset END interface, and each execution chain STARTs from the interface START and ENDs with the interface END.
The procedure of the examples of the present invention is described below in conjunction with table 1:
in the embodiment of the present invention, the plurality of interfaces to be tested are all or part of the interfaces in table 1, and when the test STARTs, it is determined that the first target interface is the interface START in the first column. For the interface START, the operation of calling the interface is not performed, and a corresponding state code is not generated, but the corresponding second target interface is directly determined, which can be considered as follows: the function implementation function of the interface START may be some functions for logic processing and verification, or the like, may not have an actual operation function, or may not have a function implementation function for the interface START, or the like.
At this time, for the interface START, a random number, for example, 0.75, the line where the interface START is located in table 1 obtains an interface transition probability sequence of 0.7,0.1,0.1,0.1, and performs accumulation processing on the interface transition probability sequence, and in the accumulation process, detects whether the current accumulation result is greater than the random number 0.75 in real time, and obviously, when the accumulation is up to 0.7+0.1, the accumulation result 0.8 is greater than the random number 0.75, and at this time, the interface PUT corresponding to the last probability 0.1 accumulated in the accumulation process is taken as the second target interface.
Then, the interface PUT may be used as a first target interface to process the first data object, for example, for the file a, the function implementation function of the interface PUT is called to upload the file a, and after the function implementation function is executed, a function status code of the interface PUT is generated.
After the interface PUT is called, a random number, for example 0.3, is obtained in the first column in table 1, and an interface conversion probability sequence of 0.5 and 0.5 is obtained in the line where the interface PUT is located, then the interface conversion probability sequence is accumulated, and in the accumulating process, whether the current accumulating result is greater than the random number of 0.3 is detected in real time, and obviously, in the accumulating process, the first 0.5, that is, greater than 0.3, the interface DELETE corresponding to the 0.5 in the interface conversion probability sequence is taken as a second target interface.
Then, the DELETE process may be performed on the file a using the interface DELETE as the first target interface, similar to the process of uploading the file a described above, in which the function status code of the interface DELETE is generated.
After the interface DELETE is called, a random number, for example, 0.5, is obtained, the interface DELETE is found in the first column in table 1, and the interface transition probability sequence is obtained in the row where the interface DELETE is located as 1, and then the interface END corresponding to 1 is the second target interface. For the interface END, like the interface START, the operation of calling the interface is not performed, and the corresponding status code is not generated.
Thereafter, the interface END may be regarded as the first target interface. At this time, the detection that the preset end condition is satisfied is: and if the first target interface is a preset ending interface, stopping the interface calling process, performing statistical analysis on each generated state code to obtain an analysis result, and determining the test result of each target interface based on the analysis result.
Referring to fig. 3, fig. 3 is a schematic diagram of a status code analysis result, and fig. 3 is a partial example of the status code analysis result, where several interfaces, namely, a start interface, an upload interface, and an end interface, are used to illustrate the status code analysis result, and the remaining interfaces are not shown.
The circles in fig. 3 represent an interface calling step, the arrow between the circles represents the transition from one step to another, the number on the upper side of the arrow indicates how many execution chains have undergone the transition process between the two steps where the arrow is located, the number on the upper side of the circle indicates the number of times the step is called, and the number on the lower side of the circle indicates the distribution probability of the different state codes corresponding to the step. As in fig. 3, the circle upload interface represents steps executed by a function implementation function of the upload interface; the number 128 on the upper side of the arrow between the circle initiation interface and the upload interface indicates that 128 execution chains are totally converted to the upload interface through the initiation interface; 587 on the upper side of the uploading interface indicates that the function implementation function of the uploading interface is called 587 times; uploading the numbers on the lower side of the interface: 0 (0.73), 404 (0.05), 601 (0.22), wherein the distribution probability of the function status code of the uploading interface being 0 is 0.73, the distribution probability of the function status code being 404 is 0.05, and the distribution probability of the function status code being 601 is 0.22.
In the embodiment of the invention, the interface testing device can preset all interfaces or part of interfaces to generate alarm information when the status code is greater than or equal to the status code alarm threshold value according to different conditions of each interface, for example, the status code alarm threshold value is 500. Thus, in connection with fig. 3, it may be understood that, in the status code analysis results including all the interfaces to be tested, the distribution probability of the functional status code of each target interface except the start interface and the end interface may be obtained, and the test results of the respective target interfaces may be determined based on the distribution probability of the status codes of the respective target interfaces.
In the scheme provided by the embodiment of the invention, the calling sequence of a plurality of interfaces to be tested is determined by utilizing the preset interface conversion information, the construction of test cases and the interface calling are automatically completed, the distribution probability of each functional state code generated in the interface calling process is counted, and the like, so that the test result of the interfaces to be tested is determined. Therefore, compared with the prior art that a plurality of interfaces are manually constructed into test cases and manual testing is performed, the embodiment of the invention can effectively reduce manpower and testing time.
The following description will take the example that the status code includes a function status code and a verification status code. The remaining steps are not repeated, and only the procedure of steps S202 to S203 in fig. 2 will be described, and steps S202 to S203 may include steps D1 to D7:
D1, calling a function realization function of a first target interface, and executing the function realization function on a first data object;
d1 is the same as C1 in the above embodiment, and will not be described here again.
And D2, obtaining attribute information of the first data object in the function implementation function execution process.
In the embodiment of the invention, in the process of calling the function implementation function of the first target interface, the interface testing device can obtain the attribute information of the first data object, such as the name and content information of the first data object. Of course, when the interface testing device obtains the attribute information of the first data object, the attribute information may be recorded, for example, recorded as a file, and stored. Here, the record carrier and the storage location of the attribute information of the first data object in the embodiment of the present invention are not limited, but for convenience of description later, alternatively, in the embodiment of the present invention, after obtaining the attribute information of the first data object, an execution context may be generated, where the execution context is a file in which the attribute information of the first data object is recorded.
In the execution context, the name of the first data object and the MD5 code of the feature code may be recorded, where the MD5 code is a value calculated based on the content of the first data object, and the MD5 code is capable of characterizing the content of the first data object, where the feature code is typically a 32-byte value.
And D3, after the function implementation function is executed, generating a function state code of the first target interface.
D3 is the same as C2 in the above embodiment, and will not be described here.
And D4, calling an attribute verification function of the first target interface, and executing the attribute verification function on the second data object.
In the embodiment of the present invention, the second data object is a data object obtained by executing the function implementation function on the first data object.
It will be appreciated by those skilled in the art that, for the testing process, the function implementation function of the execution interface is implemented only by implementing the functional operation of the interface, and it is not known whether the result of the functional operation is accurate, for example, the uploading operation of the uploading interface is completed by calling the uploading interface, and the execution context and the functional status code are generated, at this time, only the uploaded functional operation is completed, and it is not known whether the uploaded file a is accurate, so it is understood that further verification of the result of the uploading file a is required.
In the embodiment of the invention, after the function implementation function is executed and the execution context and the function status code are generated, the attribute verification function of the first target interface can be immediately called for verification. The above uploading interface is exemplified by the uploading interface, in the process of D1 to D3, the interface testing device calls the function implementation function of the uploading interface, in this process, the MD5 code of the file a is calculated first, the uploading operation is performed on the file a, and the name of the file a and the corresponding MD5 code are recorded in the execution context, so for this step D4, the attribute verification function of the uploading interface may be the function implementation function corresponding to the downloading operation, the file a that has just been uploaded may be verified by using the downloading operation, the process may be that the name of the file a is obtained from the execution context, the attribute verification function of the uploading interface is called, the file a is downloaded, and then it is verified whether the content of the downloaded a is consistent with the content of the uploaded a.
And D5, obtaining verification information of the second data object.
Continuing with the above example, the attribute verification function of the uploading interface is called, for example, after the downloading operation is performed to download the file a, the MD5 code of the downloaded file a may be recalculated, and the recalculated MD5 code of the file a is used as verification information.
It should be noted that in the embodiment of the present invention, the calculation of the MD5 code of the file may be accomplished by using the prior art.
And D6, comparing the verification information with the attribute information to obtain a comparison result.
Wherein, the attribute information is: attribute information of the first data object.
In the embodiment of the invention, whether the result of the functional operation of the interface is correct is judged by utilizing the comparison of the verification information and the attribute information.
Continuing with the above example, the MD5 code in the authentication information may be compared with the MD5 code in the attribute information to obtain a comparison result.
And D7, generating the verification status code based on the comparison result.
The verification status code is used for verifying whether the function operation result corresponding to the function realization function is accurate. For example, if the comparison result is that the MD5 code in the verification information is the same as the MD5 code in the attribute information, a verification status code of 0 may be generated to indicate that the function operation result corresponding to the function implementation function is accurate, or if the comparison result is that the two MD5 codes are not the same, a verification status code of 600 may be generated to indicate that the function operation result corresponding to the function implementation function is inaccurate.
It should be noted that, in the embodiment of the present invention, the function status code is 0, which indicates that the process of executing the function implementation function of the interface is successful, which may indicate that the function operation of the interface is successful, and the function status code is other numerical values, which may indicate that the above process is unsuccessful; the verification status code is 0, which indicates that the function operation result corresponding to the function implementation function is accurate, and the verification status code is other numerical values, which can indicate that the function operation result corresponding to the function implementation function is inaccurate. The function status code and other values of the verification status code may be any value other than 0, such as 400, 600, etc. In the actual test process, a status code alarm threshold value, such as 500, can be preset, and when the functional status code or the verification status code is greater than or equal to 500, the interface test device can generate alarm information to prompt a tester to conduct fault investigation.
It should be noted that, when the status code includes a function status code and a verification status code, the embodiment of the invention can process a scenario of a data object for a single thread, and for interface test of the scenario, the interface test device can immediately check whether a function operation result corresponding to the function implementation function is accurate after the function implementation function of each target interface is executed, and determine a test result of each target interface according to analysis results of the function status code and the verification status code.
For example, in the analysis result of the status code, when the probability of the functional status code of the uploading interface being 0 is greater than a preset judgment threshold, for example, 90%, etc., the uploading operation of the uploading function of the uploading interface can be considered successful, and when the probability of the verification status code of the uploading interface being 0 is greater than the preset judgment threshold, for example, 90%, etc., the uploading operation result of the uploading interface can be considered accurate. In the embodiment of the invention, the test result of the uploading interface can be determined based on the analysis results of the functional status code and the verification status code, for example, when the probability of the status code being 0 is greater than the preset judgment threshold value in the analysis results of the functional status code and the verification status code, the test result of the uploading interface is determined to be normal, and the like. Of course, different judging thresholds and the like can be preset for the function status code and the verification status code, which is reasonable.
The process of the embodiments of the present invention is described in conjunction with the examples set forth in Table 1 above:
in the embodiment of the present invention, when a test STARTs, it is determined that a first target interface is an interface START, at this time, for the first target START, a random number, for example, 0.75, is directly obtained, and based on table 1, it is determined that a second target interface corresponding to the interface START is an interface PUT, where a process of determining the second target interface by using the random number and table 1 is not repeated.
Next, the interface PUT is used as a first target interface to process a first data object, for example, for a file a, a function implementation function of the interface PUT is called to upload the file a, in the process, the name a and MD5 code of the file a are recorded as attribute information into an execution context, after the function implementation function is executed, a function state code of the interface PUT is generated, an attribute verification function of the interface PUT is called again, the name of the file a is obtained from the execution context, the file a is downloaded, the MD5 code of the file a is recalculated as verification information, the MD5 code in the verification information is compared with the MD5 code in the execution context, a comparison result is obtained, and a verification state code is generated based on the comparison result.
After the interface PUT is called, a random number, for example, 0.3, is obtained, and based on table 1, it is determined that the second target interface corresponding to the interface PUT is the interface DELETE, wherein the process of determining the second target interface by using the random number and table 1 is not described again.
Then, the interface DELETE is used as the first target interface to DELETE the file a, and the processing procedure is similar to the procedure of uploading the file a, and the functional status code and the verification status code of the interface DELETE are generated in the processing procedure.
After completing the call of the interface DELETE, a random number, for example, 0.5, is obtained, and based on table 1, it is determined that the second target interface corresponding to the interface PUT is the interface END.
Thereafter, the interface END may be regarded as the first target interface. At this time, the detection that the preset end condition is satisfied is: and if the first target interface is a preset ending interface, stopping the interface calling process, performing statistical analysis on each generated state code to obtain an analysis result, and determining the test result of each target interface based on the analysis result.
Referring to fig. 4, fig. 4 is another schematic diagram of a status code analysis result, and fig. 4 is a partial example of the status code analysis result, in which several interfaces including a start interface, an upload interface, and an end interface are used to illustrate the status code analysis result, and the remaining interfaces are not shown.
In fig. 4, a circle represents an interface calling step, and it can be understood that in a status code analysis result including all interfaces to be tested, two executing steps exist in other interfaces except for a start interface and an end interface, which represent a step of executing a function implementation function of the interface and an executing step of an attribute verification function respectively; arrows between circles represent transitions from one step to another; the numbers on the top of the arrow indicate how many execution chains in total have undergone a transition between the two steps in which the arrow is located; and the number on the upper side of the circle indicates the number of times the step is invoked; the numbers below the circles represent the probability of the distribution of the state codes corresponding to this step.
As shown in fig. 4, the circle upload interface 1 represents a step executed by a function implementation function of the upload interface, and the circle upload interface 2 represents a step executed by an attribute verification function of the upload interface; a number 101 at the upper side of an arrow between the circle starting interface and the uploading interface 1 indicates that 101 execution chains are totally used for uploading the interface 1 through the starting interface; 101 on the upper side of the uploading interface 1 indicates that the function implementation function of the uploading interface is called 101 times; the number 0 (1.00) at the lower side of the uploading interface 1 indicates that the distribution probability of the function status code of the uploading interface being 0 is 1.00, and indicates that the process of calling the function implementation function of the uploading interface is 100% successful. Therefore, as can be understood from fig. 4, in the status code analysis results including all the interfaces to be tested, the distribution probability of the functional status code and the attribute verification code of each interface to be tested except the start interface and the end interface can be obtained, and based on the distribution probability of the status codes of the target interfaces, the test results of each target interface can be determined, for example, the status codes of each target interface are all 0, and the distribution probability is all 1.00, and then the test results of each target interface are all normal.
In the scheme provided by the embodiment of the invention, the calling sequence of a plurality of interfaces to be tested is determined by utilizing the preset interface conversion information, the construction of test cases and the interface calling are automatically completed, and the distribution probability of each functional status code and verification status code generated in the interface calling process is counted, so that the test result of the interfaces to be tested is determined. Therefore, compared with the prior art that a plurality of interfaces are manually constructed into test cases and manual testing is performed, the embodiment of the invention can effectively reduce manpower and testing time.
The above is an explanation of an interface testing method provided by the embodiment of the present invention, and the following analysis and explanation are made on the other beneficial effects brought by the embodiment of the present invention:
it will be appreciated by those skilled in the art that in the process of testing an interface, a tester is usually required to combine multiple interfaces differently to construct different test cases, so as to implement different operation tasks corresponding to actual services, so as to verify the calling condition of the interface in the different operation tasks. It will be appreciated that there are a very large number of combinations for a plurality of interfaces, and in principle, it is not possible for a tester to manually construct test cases of different interface combinations for covering all interface combinations within a certain test time.
In the embodiment of the invention, if all probabilities in the interface conversion probability table are non-0 values, all interfaces are covered under a certain sufficient time by using random numbers. It can be considered that, in principle, by using the interface testing method provided by the embodiment of the present invention, test cases covering all interface combinations can be constructed, and testing of these test cases can be completed.
In addition, in the embodiment of the invention, the interface test process can be changed into other test processes such as pressure test and performance test by using different setting modes of probabilities in the interface conversion probability table. For example, a stress test is required to confirm the stress level of the file upload operation that the distributed storage system can withstand, then the interface transition probability table may be set to: the probability of the interface PUT being converted to the interface PUT is 1.0, and it can be considered that after the operation of uploading the file is completed, the next step is always to upload the file, and then when the interface is tested by using the interface conversion probability table, the interface testing device will always perform the operation of uploading the file, and the interface testing process can be changed into a pressure testing process by controlling the number of threads executing the task of the operation.
In addition, in the embodiment of the invention, once the testers finish defining each interface in advance, namely setting the function realization function and the attribute verification function of each interface, then the interface testing device can automatically combine a plurality of interfaces into a test case by utilizing a preset interface conversion probability table to finish the test, and when part of interfaces are changed, the testers only need to modify the function realization function, the attribute verification function and the like of the changed interfaces, or when the interfaces are newly added, only need to define the function realization function and the attribute verification function of the newly added interfaces, and the time is not required to modify the existing cases. Therefore, all test cases using the change interface are prevented from being modified manually like the conventional test method.
Corresponding to the above method embodiment, the embodiment of the present invention further provides an interface testing device, as shown in fig. 5, where the interface testing device includes:
a determining module 501, configured to determine a first target interface among a plurality of interfaces to be tested;
the first processing module 502 is connected with the determining module 501 and is used for calling the first target interface and processing the first data object;
A selecting module 503, coupled to the first processing module 502, configured to select an interface from the plurality of interfaces to be tested as a second target interface based on preset interface conversion information, where the second target interface is a next target interface of the first target interface; the interface conversion information describes a calling combination relation among the interfaces to be tested in the plurality of interfaces to be tested;
and the second processing module 504 is connected to the selecting module 503, and is configured to invoke the second target interface to process the first data object.
Optionally, in an embodiment of the present invention, the apparatus further includes:
the first generating module is connected with the first processing module 502 and is used for generating a state code of the first target interface after calling the first target interface to process a data object, wherein the state code of the first target interface is used for determining a test result of the first target interface;
and the second generating module is connected with the second processing module 504 and is used for generating a state code of the second target interface after the second target interface is called to process the data object, wherein the state code of the second target interface is used for determining a test result of the second target interface.
Optionally, in an embodiment of the present invention, the apparatus further includes:
the judging module is connected with the first processing module 502 and is used for judging whether a preset condition is met before selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information; wherein, when the preset condition is not satisfied, the selecting module 503 performs the step of selecting an interface from the plurality of interfaces to be tested as a second target interface based on the preset interface conversion information; wherein the preset end condition includes at least one of: the selected first target interface is a preset ending interface, and the number of times of calling the target interface is greater than or equal to the preset number of times.
Optionally, in an embodiment of the present invention, the apparatus further includes:
the result determining module is fast, is connected with the judging module and is used for determining the test result of the first target interface based on the state code of the first target interface under the condition that the preset condition is met after judging whether the preset condition is met.
Optionally, in an embodiment of the present invention, the status code includes a function status code and/or a verification status code,
The function status code is used for indicating whether the process of executing the function realizing function of the target interface corresponding to the function status code is successful or not; the verification status code is used for verifying whether the function operation result corresponding to the function implementation function of the target interface corresponding to the verification status code is accurate.
Optionally, in an embodiment of the present invention, the first generating module is configured to call an attribute verification function of the first target interface when the status code includes a verification status code, and execute the attribute verification function on a second data object, where the second data object is a data object obtained by executing the function implementation function on the first data object; obtaining verification information of the second data object; comparing the verification information with attribute information to obtain a comparison result, wherein the attribute information is: attribute information of the first data object; and generating the verification status code based on the comparison result.
Optionally, in an embodiment of the present invention, the selecting module 503 includes: the acquisition sub-module is used for acquiring the first auxiliary information; and the determining submodule is connected with the acquiring submodule and is used for determining an interface matched with the first auxiliary information from the interfaces to be tested as the second target interface based on the interface conversion information.
Alternatively, in an embodiment of the present invention,
the first auxiliary information may include: a random number, wherein the value of the random number is between 0 and 1;
the interface conversion information may include: and the interface conversion probability table is recorded with the probability of converting each interface to be tested to each interface to be tested.
Optionally, in an embodiment of the present invention, the determining submodule is configured to: acquiring an interface conversion probability sequence corresponding to the first target interface based on the interface conversion probability table, wherein the interface conversion probability sequence contains the probability of converting the first target interface to each interface to be tested; executing accumulation processing on probabilities in the interface conversion probability sequence, and detecting whether the current accumulation result is larger than the random number in real time in the accumulation process;
and when the current accumulation result is detected to be larger than the random number, taking an interface corresponding to the last probability accumulated in the accumulation process as the second target interface.
Optionally, in an embodiment of the present invention, the result determining module is configured to: carrying out statistical analysis on the generated state codes of the first target interface to obtain an analysis result, wherein the analysis result comprises the distribution probability of different state codes of the first target interface; and determining a test result of the first target interface based on the analysis result.
In the scheme provided by the embodiment of the invention, the interface conversion information is preset, and describes the calling combination relation among the interfaces to be tested in the interfaces to be tested, so that the calling sequence of the interfaces to be tested can be determined by utilizing the interface conversion information, the interfaces to be tested are sequentially called to process the data object, and the establishment of the test case and the interface test are automatically completed. Therefore, compared with the prior art that a plurality of interfaces are manually constructed into test cases and manual testing is performed, the embodiment of the invention can effectively reduce manpower and testing time.
It should be noted that the interface testing device may be located in an electronic device (such as a server), or alternatively, may be located in a management server in a distributed storage system, but is not limited thereto.
Corresponding to the above-described method embodiments, the present invention also provides an electronic device, optionally, but not limited to a server, as shown in fig. 6, which may include a processor 601 and a memory 602, where,
the memory 602 is used for storing a computer program;
The processor 601 is configured to implement the steps of the interface testing method provided by the embodiment of the present invention when executing the program stored in the memory 602.
The Memory 602 may include RAM (Random Access Memory ) or NVM (Non-Volatile Memory), such as at least one magnetic disk Memory. Alternatively, the memory 602 may be at least one memory device located remotely from the processor.
The processor 601 may be a general-purpose processor including a CPU (Central Processing Unit ), NP (Network Processor, network processor), and the like; but also DSP (Digital Signal Processor ), ASIC (Application Specific Integrated Circuit, application specific integrated circuit), FPGA (Field-Programmable Gate Array, field programmable gate array) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components.
Through the electronic equipment, the following steps can be realized: the interface conversion information describing the calling combination relation among the interfaces to be tested in the interfaces to be tested is preset, so that the calling sequence of the interfaces to be tested can be determined by utilizing the interface conversion information, the interfaces to be tested are sequentially called to process the data object, and the construction of the test case and the interface test are automatically completed. Therefore, compared with the prior art that a plurality of interfaces are manually constructed into test cases and manual testing is performed, the embodiment of the invention can effectively reduce manpower and testing time.
In addition, corresponding to the interface test method provided in the above embodiment, the embodiment of the present invention provides a computer readable storage medium, in which a computer program is stored, and the computer program when executed by a processor implements the steps of the interface test method provided in the embodiment of the present invention.
The computer readable storage medium stores an application program for executing the interface test method provided by the embodiment of the present invention at the time of operation, so that it is possible to realize: the interface conversion information describing the calling combination relation among the interfaces to be tested in the interfaces to be tested is preset, so that the calling sequence of the interfaces to be tested can be determined by utilizing the interface conversion information, the interfaces to be tested are sequentially called to process the data object, and the construction of the test case and the interface test are automatically completed. Therefore, compared with the prior art that a plurality of interfaces are manually constructed into test cases and manual testing is performed, the embodiment of the invention can effectively reduce manpower and testing time.
For the electronic device and the computer-readable storage medium embodiments, since the method content involved is substantially similar to the method embodiments described above, the description is relatively simple, and references to the relevant portions of the description of the method embodiments are only needed.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (10)

1. An interface testing method, comprising:
determining a first target interface in a plurality of interfaces to be tested;
invoking the first target interface to process a first data object;
selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information, wherein the second target interface is the next target interface of the first target interface; the interface conversion information describes a calling combination relation among the interfaces to be tested in the plurality of interfaces to be tested;
invoking the second target interface to process the first data object;
based on the preset interface conversion information, selecting an interface from the interfaces to be tested as a second target interface, including:
acquiring first auxiliary information; the first auxiliary information includes: a random number, wherein the value of the random number is between 0 and 1;
Based on an interface conversion probability table, obtaining an interface conversion probability sequence corresponding to the first target interface, wherein the interface conversion probability table records the probability of each interface to be tested to each interface to be tested, and the interface conversion probability sequence contains the probability of the first target interface to be converted to each interface to be tested;
executing accumulation processing on probabilities in the interface conversion probability sequence, and detecting whether the current accumulation result is larger than the random number in real time in the accumulation process;
and when the current accumulation result is detected to be larger than the random number, taking an interface corresponding to the last probability accumulated in the accumulation process as the second target interface.
2. The method of claim 1, wherein the step of determining the position of the substrate comprises,
after invoking the first target interface to process the first data object, the method further comprises: generating a state code of the first target interface, wherein the state code of the first target interface is used for determining a test result of the first target interface;
after invoking the second target interface to process the first data object, the method further comprises: and generating a state code of the second target interface, wherein the state code of the second target interface is used for determining a test result of the second target interface.
3. The method of claim 2, wherein before selecting an interface among the plurality of interfaces to be tested as the second target interface based on the preset interface conversion information, the method further comprises:
judging whether a preset condition is met or not; under the condition that the preset condition is not met, selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information;
wherein the preset condition includes at least one of: the selected first target interface is a preset ending interface, and the number of times of calling the target interface is greater than or equal to the preset number of times.
4. A method according to claim 3, wherein after determining whether the preset condition is met, the method further comprises:
and under the condition that the preset condition is met, determining a test result of the first target interface based on the state code of the first target interface.
5. The method according to claim 2, wherein the status code comprises a functional status code and/or a verification status code,
the function status code is used for indicating whether the process of executing the function realizing function of the target interface corresponding to the function status code is successful or not; the verification status code is used for verifying whether the function operation result corresponding to the function implementation function of the target interface corresponding to the verification status code is accurate.
6. The method of claim 5, wherein, in the case where the status code comprises a verification status code, the generating the status code of the first target interface comprises:
invoking an attribute verification function of the first target interface, and executing the attribute verification function on a second data object, wherein the second data object is a data object obtained by executing the function implementation function on the first data object;
obtaining verification information of the second data object;
comparing the verification information with attribute information to obtain a comparison result, wherein the attribute information is: attribute information of the first data object;
and generating the verification status code based on the comparison result.
7. The method of claim 4, wherein determining the test result of the first target interface based on the status code of the first target interface comprises:
carrying out statistical analysis on the generated state codes of the first target interface to obtain an analysis result, wherein the analysis result comprises the distribution probability of different state codes of the first target interface;
and determining a test result of the first target interface based on the analysis result.
8. An interface testing apparatus, comprising:
the determining module is used for determining a first target interface in a plurality of interfaces to be tested;
the first processing module is used for calling the first target interface and processing the first data object;
the selecting module is used for selecting an interface from the interfaces to be tested as a second target interface based on preset interface conversion information, wherein the second target interface is the next target interface of the first target interface; the interface conversion information describes a calling combination relation among the interfaces to be tested in the plurality of interfaces to be tested;
the second processing module is used for calling the second target interface and processing the first data object;
the selecting module comprises: the acquisition sub-module is used for acquiring the first auxiliary information; the first auxiliary information includes: a random number, wherein the value of the random number is between 0 and 1;
the determining submodule is used for acquiring an interface conversion probability sequence corresponding to the first target interface based on an interface conversion probability table, executing accumulation processing on probabilities in the interface conversion probability sequence, and detecting whether a current accumulation result is larger than the random number or not in real time in the accumulation process; when the current accumulation result is detected to be larger than the random number, an interface corresponding to the last probability accumulated in the accumulation process is used as the second target interface, wherein the probability of each interface to be tested to each interface to be tested is recorded in the interface conversion probability table, and the interface conversion probability sequence contains the probability of the first target interface to be converted to each interface to be tested.
9. An electronic device comprising a processor and a memory, wherein,
the memory is used for storing a computer program;
the processor is configured to implement the method steps of any of claims 1-7 when executing a program stored on the memory.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-7.
CN201810801940.9A 2018-07-20 2018-07-20 Interface testing method and device, electronic equipment and storage medium Active CN110737575B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810801940.9A CN110737575B (en) 2018-07-20 2018-07-20 Interface testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810801940.9A CN110737575B (en) 2018-07-20 2018-07-20 Interface testing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110737575A CN110737575A (en) 2020-01-31
CN110737575B true CN110737575B (en) 2023-09-01

Family

ID=69235579

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810801940.9A Active CN110737575B (en) 2018-07-20 2018-07-20 Interface testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110737575B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860271B (en) * 2021-03-30 2024-03-29 中国工商银行股份有限公司 New and old system switching method, device, equipment and storage medium
CN112948195B (en) * 2021-03-31 2023-04-25 建信金融科技有限责任公司 Interface testing method, device, electronic equipment and storage medium
CN113392026B (en) * 2021-07-07 2023-12-19 北京智慧星光信息技术有限公司 Interface automatic test method, system, electronic equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5708774A (en) * 1996-07-23 1998-01-13 International Business Machines Corporation Automated testing of software application interfaces, object methods and commands
CN106528418A (en) * 2016-10-28 2017-03-22 广东浪潮大数据研究有限公司 Test method and device
CN107391379A (en) * 2017-07-28 2017-11-24 武汉斗鱼网络科技有限公司 Interface automatic test approach and device
CN107957952A (en) * 2017-12-18 2018-04-24 马上消费金融股份有限公司 A kind of interface test method, device and medium
CN107977308A (en) * 2016-10-25 2018-05-01 传化物流集团有限公司 interface test method and device
CN108153670A (en) * 2017-11-30 2018-06-12 北京奇艺世纪科技有限公司 A kind of interface test method, device and electronic equipment
CN108255738A (en) * 2018-04-09 2018-07-06 平安普惠企业管理有限公司 Automated testing method, device, computer equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5708774A (en) * 1996-07-23 1998-01-13 International Business Machines Corporation Automated testing of software application interfaces, object methods and commands
CN107977308A (en) * 2016-10-25 2018-05-01 传化物流集团有限公司 interface test method and device
CN106528418A (en) * 2016-10-28 2017-03-22 广东浪潮大数据研究有限公司 Test method and device
CN107391379A (en) * 2017-07-28 2017-11-24 武汉斗鱼网络科技有限公司 Interface automatic test approach and device
CN108153670A (en) * 2017-11-30 2018-06-12 北京奇艺世纪科技有限公司 A kind of interface test method, device and electronic equipment
CN107957952A (en) * 2017-12-18 2018-04-24 马上消费金融股份有限公司 A kind of interface test method, device and medium
CN108255738A (en) * 2018-04-09 2018-07-06 平安普惠企业管理有限公司 Automated testing method, device, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
叶波 等.软件接口自动化测试技术研究与实现.信息化研究.2010,(04),全文. *

Also Published As

Publication number Publication date
CN110737575A (en) 2020-01-31

Similar Documents

Publication Publication Date Title
CN110737575B (en) Interface testing method and device, electronic equipment and storage medium
CN108959067B (en) Method and device for testing search engine and computer readable storage medium
CN111611172A (en) Project test defect analysis method, device, equipment and storage medium
CN110543427B (en) Test case storage method and device, electronic equipment and storage medium
CN111475401A (en) Test method and related equipment
CN112256318B (en) Construction method and equipment for dependent product
CN112328499A (en) Test data generation method, device, equipment and medium
CN112363937A (en) Method and device for testing differential coverage rate, computer equipment and storage medium
CN116881156A (en) Automatic test method, device, equipment and storage medium
CN115292197A (en) Software testing method and device, electronic equipment and storage medium
CN115563002A (en) Data importing method and device, storage medium and computer equipment
CN111651358B (en) Method for generating test case, software test method, device and server
CN110263223B (en) Data type conversion method, device, equipment and medium
CN109684205B (en) System testing method, device, electronic equipment and storage medium
CN116562227A (en) Chip signal connectivity verification method and device
CN115757172A (en) Test execution method and device, storage medium and computer equipment
CN113360389A (en) Performance test method, device, equipment and storage medium
CN108536599B (en) BIOS default configuration verification method, system, device and computer readable storage medium
CN110795142B (en) Configuration file generation method and device
CN109240906B (en) Database configuration information adaptation method and device, computer equipment and storage medium
CN112862452A (en) Method and device for executing work order equivalence, computer equipment and storage medium
CN109189369B (en) Method and device for compressing codes
CN107885663B (en) Method and device for automatically generating test case, computer equipment and storage medium
CN111274128A (en) Test method, test device, computer equipment and computer readable storage medium
CN111858288A (en) Test case optimization method, device and equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant