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

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

Info

Publication number
CN114546837A
CN114546837A CN202210099429.5A CN202210099429A CN114546837A CN 114546837 A CN114546837 A CN 114546837A CN 202210099429 A CN202210099429 A CN 202210099429A CN 114546837 A CN114546837 A CN 114546837A
Authority
CN
China
Prior art keywords
interface
test
interface test
script
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210099429.5A
Other languages
Chinese (zh)
Inventor
崔凯龙
陈永琴
刘兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Xishima Data Technology Co ltd
Original Assignee
Shenzhen Xishima Data Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Xishima Data Technology Co ltd filed Critical Shenzhen Xishima Data Technology Co ltd
Priority to CN202210099429.5A priority Critical patent/CN114546837A/en
Publication of CN114546837A publication Critical patent/CN114546837A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Abstract

The embodiment of the application discloses a method, a device, equipment and a storage medium for interface testing. The method comprises the following steps: receiving an interface test request, wherein the interface test request is used for testing a system comprising N interfaces, N is a positive integer greater than 1, and the interface test request comprises an interface identifier and an expected return result; acquiring corresponding interface test case information according to the interface test request, wherein the interface test case information comprises an interface identifier, an access address and path, an incoming parameter, an outgoing parameter, a request mode and a return parameter; generating each interface test script according to each interface test case information; combining the interface test scripts to obtain a target interface test script; and performing interface test according to the target interface test script to obtain an interface test result. By implementing the embodiment of the application, the automatic interface test can be carried out on the system with a plurality of interfaces, and the efficiency of the interface test is favorably improved.

Description

Interface test method, device, equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for interface testing.
Background
The state actively pushes the integration development of the academic calendar and the non-academic calendar, and develops the trial of a 1+ X certificate (1 academic certificate + a plurality of X professional skill grade certificates) system, thereby improving the sustainable employment ability of students and relieving the structural employment contradiction. Therefore, a plurality of 1+ X theory and training systems are available in the market at present to help students pass examinations to obtain 1+ X certificates. In the process of system development, interface testing is an essential link. However, 1+ X theoretical and practical training systems typically involve hundreds of interfaces, are time consuming and labor intensive to implement, and are inefficient if performed manually by a tool and the results are then recorded.
Disclosure of Invention
The embodiment of the application provides an interface testing method, device, equipment and storage medium, which can be used for carrying out automatic interface testing on a system with a plurality of interfaces and are beneficial to improving the efficiency of interface testing.
In a first aspect, an embodiment of the present application provides an interface testing method, including:
receiving an interface test request, wherein the interface test request is used for testing a system comprising N interfaces, N is a positive integer greater than 1, and the interface test request comprises an interface identifier and an expected return result;
acquiring corresponding interface test case information according to the interface test request, wherein the interface test case information comprises an interface identifier, an access address and path, an incoming parameter, an outgoing parameter, a request mode and a return parameter;
generating each interface test script according to each interface test case information;
combining the interface test scripts to obtain a target interface test script;
and performing interface test according to the target interface test script to obtain an interface test result.
In a second aspect, an embodiment of the present application provides an apparatus for interface testing, including:
the system comprises a communication unit, a test unit and a control unit, wherein the communication unit is used for receiving an interface test request, the interface test request is used for testing a system comprising N interfaces, N is a positive integer greater than 1, and the interface test request comprises an interface identifier and an expected return result;
the processing unit is used for acquiring corresponding interface test case information according to the interface test request, wherein the interface test case information comprises an interface identifier, an access address and path, an incoming parameter, an outgoing parameter, a request mode and a return parameter; generating each interface test script according to each interface test case information; combining the interface test scripts to obtain a target interface test script; and performing interface test according to the target interface test script to obtain an interface test result.
In a third aspect, this application provides a computer device comprising a processor, a memory and a communication interface, wherein the memory stores a computer program configured to be executed by the processor, and the computer program comprises instructions for some or all of the steps as described in the first aspect of this application.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program, where the computer program causes a computer to perform some or all of the steps described in the first aspect of the embodiments of the present application.
The embodiment of the application has the following beneficial effects:
by adopting the interface test method, the device, the equipment and the storage medium, after the interface test request of the system comprising a plurality of interfaces is received, the corresponding interface test case information is obtained according to the interface test request. And then generating each interface test script according to each interface test case information, and combining the interface test scripts to obtain a target test script. And finally, performing interface test according to the target interface test script to obtain an interface test result. Therefore, the method and the device can be used for automatically testing the interfaces of a system with a plurality of interfaces, and are beneficial to improving the efficiency of interface testing.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained based on these drawings without creative efforts. Wherein:
fig. 1 is a schematic diagram of a system architecture according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for testing an interface according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of an interface testing apparatus according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and in the accompanying drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
It should also be understood that the term "and/or" herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
In order to better understand the technical solution of the embodiments of the present application, a system architecture that may be involved in the embodiments of the present application is introduced first. Referring to fig. 1, a system architecture provided in the embodiment of the present application may include: an electronic device 101 and a server 102. Wherein a user may use the electronic device 101 to communicate and interact with the server 102 over a network to receive or send messages. Network communications may be based on any wired and wireless network, including but not limited to the Internet, wide area networks, metropolitan area networks, local area networks, Virtual Private Networks (VPNs), wireless communication networks, and the like.
The number of the electronic devices and the number of the servers are not limited in the embodiment of the application, and the servers can provide services for the electronic devices at the same time. In the embodiment of the present application, the electronic device may be various devices having a display screen and supporting web browsing. The electronic device may be a Personal Computer (PC), a notebook computer, or a smart phone, and may also be an all-in-one machine, a palm computer, a tablet computer (pad), a smart tv playing terminal, a vehicle-mounted terminal, or a portable device. The operating system of the PC-side electronic device, such as a kiosk or the like, may include, but is not limited to, operating systems such as Linux system, Unix system, Windows series system (e.g., Windows xp, Windows 7, etc.), Mac OS X system (operating system of apple computer), and the like. The operating system of the electronic device at the mobile end, such as a smart phone, may include, but is not limited to, an operating system such as an android system, an IOS (operating system of an apple mobile phone), a Window system, and the like.
The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like. The server may alternatively be implemented as a server cluster consisting of a plurality of servers.
The state actively pushes the integration development of the academic calendar and the non-academic calendar, and develops the trial of a 1+ X certificate (1 academic certificate + a plurality of X professional skill grade certificates) system, thereby improving the sustainable employment ability of students and relieving the structural employment contradiction. Therefore, a plurality of 1+ X theory and training systems are available in the market at present to help students pass examinations to obtain 1+ X certificates.
In the process of system development, interface testing is an essential link. Interface testing is a test that tests an interface between components of a system. The interface test is mainly used for detecting interaction points between external systems and between internal subsystems. The key point of the test is to check the exchange of data, transfer and control management processes, mutual logic dependency relationship between systems and the like. However, 1+ X theoretical and practical training systems typically involve hundreds of interfaces, are time consuming and labor intensive to implement, and are inefficient if performed manually by a tool and the results are then recorded.
In order to solve the above problem, embodiments of the present application provide a method for testing an interface, where the method may be applied to an electronic device or a server. By implementing the method, the automatic interface test can be carried out on the system with a plurality of interfaces, and the efficiency of the interface test is improved.
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating a method for testing an interface according to an embodiment of the present disclosure. Taking the application of the method to a server as an example for illustration, the method may include the following steps S201 to S205, where:
step S201: an interface test request is received.
In this embodiment of the present application, the interface test request is used to test a system including N interfaces, where N is a positive integer greater than 1, N may be 50, 100, or 150, and the like, and this is not limited in this embodiment of the present application. The system can be a 1+ X theory and training system, or other systems involving multiple interfaces. The interface test request may include information of an interface that the developer needs to test, and the like, may include an interface identifier and an expected return result, and may also include parameters such as a response time. The interface identifier may be used to identify the type of the interface to be tested, and the interface identifier may be information such as an interface name, an interface type, and an interface address. Specifically, after the server receives an interface test request sent by a developer, the server may analyze the interface test request to obtain information of an interface to be tested in the interface test request and test requirements including expected return results, response time, and the like.
Step S202: and acquiring corresponding interface test case information according to the interface test request.
In the embodiment of the present application, an interface test case may refer to a set of test inputs, execution conditions, and expected results that a developer has compiled for a specific purpose, so that the system can verify whether a specific requirement is met. The interface test case information may include an interface identifier, an access address and path, an incoming parameter, an outgoing parameter, a request mode, a return parameter, and the like of the interface to be tested. The request mode may include: upload (post), modify (put), delete (delete), get (get). The interface test cases may be stored in a test case library. Specifically, the server analyzes the interface test request to obtain an interface identifier of the interface to be tested, then queries corresponding interface test case information in a test case library according to the interface identifier, and obtains the interface test case information.
Step S203: and generating each interface test script according to each interface test case information.
An interface test script is a script written for automated testing. Automated testing may be understood as a process that translates human-driven test behavior into machine execution. The interface test script can be program codes written by one or more languages of various shells and the like of Python, Java, C/C + +, perl, php, tcl, guile, ruby or unix systems. And the server converts the information of the test case of each interface into a code to generate a test script of each interface. In this embodiment of the present application, the interface test scripts of each interface may be written in the same language, or may be written in different languages, which is not limited in this embodiment of the present application.
In a possible implementation manner, step S203 may specifically include the following steps:
acquiring a script frame corresponding to each interface from a common frame database according to the test case information of each interface; and generating each interface test script according to each script frame.
In an embodiment of the present application, the common framework database may include one of Pyunit, Pytest, Python, yaml, Allure, Logging, and Request. The scripting framework may be used to implement and control automated testing of the interface. The script Framework may include Python-type script frameworks (e.g., Pythest, UnitTest/Pyunit, etc.), Robot Framework, Behave, and letter, among others. The structure of the script framework may include configuration files (config), test data (testdata), log files (logs), and test reports (reports), among others. A script framework data directory (framework), a test case directory (TestCase), a secondary package (common), and the like may also be included. The test report is used for storing the test result of the interface test case, and the test case directory is used for storing the content of the interface test case. And the server acquires the script frame of each interface from the public frame database according to the test case information of each interface. Here, the corresponding script frame may be selected according to the type and property of the interface. And each script frame converts the test case information of each interface into codes so as to complete the compiling of the test scripts of each interface.
Therefore, the test case information of each interface obtains the script frame corresponding to each interface from the public frame database, and automatically generates the test script of each interface according to each script frame. In the whole process, developers do not need to continuously write the interface test script, so that the work of writing codes by the developers is simplified, and the efficiency of interface test is improved.
Step S204: and combining the interface test scripts to obtain a target interface test script.
The target interface test script can be understood as a script obtained by combining a plurality of interface test scripts. Because the embodiment of the application relates to the testing of a plurality of interfaces, after the interface testing scripts of a single interface are programmed, the interface testing scripts can be merged and connected in series to be executed. Therefore, the execution time can be greatly reduced, and the efficiency of the interface test is improved.
Step S205: and performing interface test according to the target interface test script to obtain an interface test result.
And after the target interface test script is obtained, carrying out interface test according to the target interface test script to generate an interface test interface. The interface test result can be used for feeding back whether a certain interface meets the requirement to pass the test.
In a possible implementation manner, step S205 may specifically include the following steps:
determining an interface to be tested according to the interface identifier; performing interface test on the interface to be tested according to the target interface test script to obtain an interface return result; and comparing the interface return result with the expected return result to obtain an interface test result.
In the embodiment of the present application, the interface return result may be understood as a test result returned when the target interface test is performed. The expected return result is the result expected to be achieved and may be determined by the corresponding standard or by the developer himself. The expected return result is included in the interface test request. When the interface test request is parsed, the expected return result can be obtained. After receiving the interface test request, the server may parse the interface test request to obtain an interface identifier carried in the interface test request, and then determine the interface to be tested according to the interface identifier. And after the interface to be tested is determined, carrying out automatic interface test on the interface to be tested according to the target interface test script. When the target interface test script is executed, the test of the interface is completed, and simultaneously, an interface return result is generated. And finally, comparing the interface return result with the expected return result to obtain an interface test result. Further, the interface test result may be stored in a preset database or fed back to the developer, so that the developer may further analyze the interface test result.
It can be seen that the interface to be tested is subjected to interface test according to the target interface test script, and an interface return result is obtained. And comparing the interface return result with the expected return result to obtain an interface test result. Therefore, the time for generating the interface test result can be reduced by automatically executing the target interface test script, and the efficiency of the interface test is improved.
In a possible implementation manner, the performing, according to the target interface test script, an interface test on the interface to be tested to obtain an interface return result may include the following steps:
sending a Request to the interface to be tested by a Request secondary packaging method, wherein the Request carries a Token value; if the Token value is successfully checked, executing the target interface test script and generating an interface return result, wherein the interface return result is stored in a yaml file; the Token value is obtained based on the following steps: searching a login interface from the interface to be tested; sending a post Request to the login interface through a Request, and taking a user name and a password as incoming parameters to obtain a return value of the post Request; and taking the return value as a Token value.
In the embodiment of the present application, the Token value needs to be obtained first, and all interfaces deployed in the test environment can be normally accessed only by obtaining the Token value. Wherein the Token value may be obtained based on the following steps: firstly, the login interface can be searched from the interface to be tested according to the interface identifier. Then, a Request of post can be sent to the login interface through the Request, and the user name and the password are used as the incoming parameters to obtain the return value of the Request, and the return value is used as the Token value. After obtaining the Token value, the Token value may be passed into subsequent access to other interface parameters as an authentication of the right.
When testing, other interfaces to be tested except the login interface need to obtain a Token value first. And then, sending a Request carrying a Token value to the interface to be tested by a Request secondary packaging method, and verifying the Request according to the Token value. And if the Token value is successfully checked, executing the target interface test script and generating an interface return result. Otherwise, the target interface test script is not executed. In the embodiment of the present application, the interface return result may be stored in a yaml file.
It can be seen that the request is authenticated through the Token value, and the target interface test script and the interface return result are generated only after the verification is passed. Therefore, the safety of the interface test can be improved.
In a possible implementation manner, the comparing the interface returned result with the expected returned result to obtain an interface test result may include the following steps:
comparing the interface return result with the expected return result; if the interface return result is consistent with the expected return result, the test is successful, and an interface test result with the successful test is generated; if the interface return result is inconsistent with the expected return result, the test fails, and an interface test result with the test failure is generated.
In the embodiment of the present application, the interface test result may be divided into a test success result and a test failure result, and the test success or the test failure may be specifically determined according to the interface return result and the expected return result. And comparing the interface return result with the expected return result, and generating a corresponding interface test result according to the comparison result. Specifically, when the interface return result is consistent with the expected return result, the test is successful. At this time, it can be understood that the interface to be tested passes the test standard. When the interface return result is inconsistent with the expected return result, the test fails. At this time, it can be understood that the interface to be tested does not pass the test standard. If the test is successful, an interface test report is automatically generated, and the whole interface test process is completed. If the test fails, the corresponding interface or the interface test script needs to be repaired, and the test is performed again until the test is successful.
It can be seen that whether the test is successful is judged by comparing the interface return result with the expected return result, and a corresponding interface test result is generated according to the test result. Therefore, whether the test is successful or not can be visually judged, and the efficiency of the interface test is improved.
In a possible implementation manner, after step S205 is executed, the following steps may be further included:
if the test is wrong, acquiring repaired interface data; and testing all the interfaces to be tested again according to the repaired interface data.
In the embodiment of the present application, the test failure may refer to that the interfaces to be tested do not all pass the test standard in the first round of test, or the test response time far exceeds the expected corresponding time, and so on. When the test fails, the server can feed back the test failure result to the developer, and after the developer analyzes the reason of the test failure, the developer repairs the interface data and sends the repaired interface data to the server. The repaired interface data may be data obtained by repairing an interface that does not meet the test standard, data obtained by repairing a target interface test script that fails to be executed, or the like, and may be specifically determined according to an actual situation. For example, if the interfaces are repaired, in order to avoid omission, the target interface test script may be run to test all the interfaces to be tested again. Or, in order to improve the testing efficiency, the target interface testing script may be run to test the faulty interface again. If the target interface test script is repaired, all the interfaces to be tested of the repaired target test script can be operated for testing again. If the test fails again, acquiring the repaired interface data; and repeatedly testing all the interfaces to be tested according to the repaired interface data until all the interfaces to be tested pass the test standard.
It can be seen that, if the test fails, the repaired interface data is obtained, and all the interfaces to be tested are tested again according to the repaired interface data. Therefore, the coverage of interface test can be improved, and the problem of interface test omission is avoided.
In a possible implementation manner, after step S205 is executed, the following steps may be further included:
determining a first interface test script and a second interface test script according to the test result; storing the first interface test script into a preset script database for subsequent calling; and analyzing the reason of the test failure according to the test result and the second interface test script.
In the embodiment of the application, the interface test script may be divided into the first interface test script and the second interface test script according to whether the test result is a success or failure in executing the test. The first interface test script is a script which is tested successfully, and the second interface test script is a script which is tested failed. The first interface test script is stored in the preset script database, so that a developer in the later period can conveniently find the interface test script, and the multiplexing of codes is favorably realized. And then, the reason of the test failure can be analyzed according to the test result and the second interface test script, so that a developer can adjust the interface test data or repair the second interface test script according to the reason.
After the first interface test script which is successfully tested and the second interface test script which is failed to be tested are determined according to the test result, the first interface test script which is successfully tested is stored in the preset script database so as to be called later, and then the reason of the test failure is analyzed according to the test result and the second interface test script. Therefore, the method and the device can be favorable for realizing the multiplexing of codes, and meanwhile, developers can repair the second interface test script which fails in the test conveniently.
In the method shown in fig. 2, after an interface test request of a system including a plurality of interfaces is received, corresponding interface test case information is acquired according to the interface test request. And then generating each interface test script according to each interface test case information, and combining the interface test scripts to obtain a target test script. And finally, performing interface test according to the target interface test script to obtain an interface test result. Therefore, the method and the device can be used for automatically testing the interfaces of a system with a plurality of interfaces, and are beneficial to improving the efficiency of interface testing.
The method of the embodiments of the present application is set forth above in detail and the apparatus of the embodiments of the present application is provided below.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an interface testing apparatus according to an embodiment of the present disclosure. The device is applied to the server. As shown in fig. 3, the interface testing apparatus 300 includes a communication unit 301 and a processing unit 302, and the detailed description of each unit is as follows:
a communication unit 301, configured to receive an interface test request, where the interface test request is used to test a system including N interfaces, where N is a positive integer greater than 1, and the interface test request includes an interface identifier and an expected return result; the processing unit 302 is configured to obtain corresponding interface test case information according to the interface test request, where the interface test case information includes an interface identifier, an access address and a path, an incoming parameter, an outgoing parameter, a request mode, and a return parameter; generating each interface test script according to each interface test case information; combining the interface test scripts to obtain a target interface test script; and performing interface test according to the target interface test script to obtain an interface test result.
In a possible implementation manner, the processing unit 302 is specifically configured to obtain, from a common framework database, a script framework corresponding to each interface according to the information of each interface test case; and generating each interface test script according to each script frame, wherein the public frame database comprises one of Punit, Pythest, Python, yaml, Allure, Logging and Request, and the structure of the script frame comprises a configuration file, test data, a log file and a test report.
In a possible implementation manner, the processing unit 302 is specifically configured to determine, according to the interface identifier, an interface to be tested; performing interface test on the interface to be tested according to the target interface test script to obtain an interface return result; and comparing the interface return result with the expected return result to obtain an interface test result.
In a possible implementation manner, the processing unit 302 is specifically configured to send a Request to the interface to be tested by a Request secondary encapsulation method, where the Request carries a Token value; if the Token value is successfully checked, executing the target interface test script and generating an interface return result, wherein the interface return result is stored in a yaml file, and the Token value is obtained based on the following steps: searching a login interface from the interface to be tested; sending a post Request to the login interface through a Request, and taking a user name and a password as input parameters to obtain a return value of the post Request; and taking the return value as a Token value.
In a possible implementation, the processing unit 302 is specifically configured to compare the interface return result with the expected return result; if the interface return result is consistent with the expected return result, the test is successful, and an interface test result with the successful test is generated; if the interface return result is inconsistent with the expected return result, the test fails, and an interface test result with the test failure is generated.
In a possible implementation manner, the processing unit 302 is further configured to obtain repaired interface data if the test fails; and testing all the interfaces to be tested again according to the repaired interface data.
In a possible implementation manner, the processing unit 302 is further configured to determine, according to the test result, a first interface test script and a second interface test script, where the first interface test script is a script that is successfully tested, and the second interface test script is a script that is failed to be tested; storing the first interface test script into a preset script database for subsequent calling; and analyzing the reason of the test failure according to the test result and the second interface test script, and repairing the second interface test script.
It should be noted that the implementation of each unit may also correspond to the corresponding description of the method embodiment shown in fig. 2.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure. As shown in fig. 4, the computer device 400 comprises a processor 401, a memory 402 and a communication interface 403, wherein the memory 402 stores a computer program 404. The processor 401, memory 402, communication interface 403 and computer program 404 may be connected by a bus 405.
When the computer device is a server, the computer program 404 is used for executing the following steps:
receiving an interface test request, wherein the interface test request is used for testing a system comprising N interfaces, N is a positive integer greater than 1, and the interface test request comprises an interface identifier and an expected return result;
acquiring corresponding interface test case information according to the interface test request, wherein the interface test case information comprises an interface identifier, an access address and path, an incoming parameter, an outgoing parameter, a request mode and a return parameter;
generating each interface test script according to each interface test case information;
combining the interface test scripts to obtain a target interface test script;
and performing interface test according to the target interface test script to obtain an interface test result.
In a possible implementation manner, in the aspect of generating each interface test script according to each interface test case information, the computer program 404 is specifically configured to execute the following steps:
acquiring a script frame corresponding to each interface from a common frame database according to the test case information of each interface;
and generating each interface test script according to each script frame, wherein the public frame database comprises one of Punit, Pythest, Python, yaml, Allure, Logging and Request, and the structure of the script frame comprises a configuration file, test data, a log file and a test report.
In a possible implementation manner, in terms of performing an interface test according to the target interface test script to obtain an interface test result, the computer program 404 is specifically configured to execute the following instructions:
determining an interface to be tested according to the interface identifier;
performing interface test on the interface to be tested according to the target interface test script to obtain an interface return result;
and comparing the interface return result with the expected return result to obtain an interface test result.
In a possible implementation manner, in terms of performing an interface test on the interface to be tested according to the target interface test script to obtain an interface return result, the computer program 404 is specifically configured to execute the following instructions:
sending a Request to the interface to be tested by a Request secondary packaging method, wherein the Request carries a Token value;
if the Token value is successfully checked, executing the target interface test script and generating an interface return result, wherein the interface return result is stored in a yaml file, and the Token value is obtained based on the following steps:
searching a login interface from the interface to be tested;
sending a post Request to the login interface through a Request, and taking a user name and a password as incoming parameters to obtain a return value of the post Request;
and taking the return value as a Token value.
In a possible implementation manner, in terms of obtaining an interface test result by comparing the interface return result with the expected return result, the computer program 404 is specifically configured to execute the following steps:
comparing the interface return result with the expected return result;
if the interface return result is consistent with the expected return result, the test is successful, and an interface test result with the successful test is generated;
if the interface return result is inconsistent with the expected return result, the test fails, and an interface test result with the test failure is generated.
In a possible implementation manner, after the interface test is performed according to the target interface test script to obtain an interface test result, the computer program 404 is further configured to execute the following steps:
if the test fails, acquiring repaired interface data;
and testing all the interfaces to be tested again according to the repaired interface data.
In a possible implementation manner, after the interface test is performed according to the target interface test script to obtain an interface test result, the computer program 404 is further configured to execute the following steps:
determining a first interface test script and a second interface test script according to the test result, wherein the first interface test script is a script which is tested successfully, and the second interface test script is a script which is tested failed;
storing the first interface test script into a preset script database for subsequent calling;
and analyzing the reason of the test failure according to the test result and the second interface test script, and repairing the second interface test script.
Those skilled in the art will appreciate that only one memory and processor are shown in fig. 4 for ease of illustration. In an actual terminal or server, there may be multiple processors and memories. The memory 402 may also be referred to as a storage medium or a storage device, and the like, which is not limited in this application.
It should be understood that, in the embodiments of the present application, the processor 401 may be a Central Processing Unit (CPU), and the processor may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like.
It will also be appreciated that the memory 402, referred to in this application embodiment, may be either volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The non-volatile memory may be a read-only memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an electrically Erasable EPROM (EEPROM), or a flash memory. Volatile memory can be Random Access Memory (RAM), which acts as external cache memory. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), double data rate SDRAM, enhanced SDRAM, SLDRAM, Synchronous Link DRAM (SLDRAM), and direct bus RAM (DR RAM).
It should be noted that when the processor 401 is a general purpose processor, a DSP, an ASIC, an FPGA or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, the memory (memory module) is integrated into the processor.
It should be noted that the memory 402 described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
The bus 405 may include a power bus, a control bus, a status signal bus, and the like, in addition to a data bus. But for clarity of illustration the various buses are labeled as buses in the figures.
In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The steps of a method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in a processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor. To avoid repetition, it is not described in detail here.
In the embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Those of ordinary skill in the art will appreciate that the various Illustrative Logical Blocks (ILBs) and steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (e.g., coaxial cable, fiber optic, digital subscriber line) or wirelessly (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk), among others.
In the above-described embodiments, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like. For example, the block chain may store an interface test case library, a preset script database, and the like, which are not limited herein.
The block chain referred to in the embodiment of the present application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, and an encryption algorithm. A block chain (blockchain), which is essentially a decentralized database, is a string of data blocks associated by using cryptography, and each data block contains information of a batch of network transactions, which is used to verify the validity (anti-counterfeiting) of the information and generate the next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Embodiments of the present application also provide a computer storage medium, where the computer storage medium stores a computer program, and the computer program is executed by a processor to implement part or all of the steps of any one of the methods for interface testing as described in the above method embodiments.
Embodiments of the present application further provide a computer program product, the computer program product comprising a non-transitory computer readable storage medium storing a computer program, the computer program being operable to cause a computer to perform some or all of the steps of any one of the methods of interface testing as set forth in the above method embodiments.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method of interface testing, comprising:
receiving an interface test request, wherein the interface test request is used for testing a system comprising N interfaces, N is a positive integer greater than 1, and the interface test request comprises an interface identifier and an expected return result;
acquiring corresponding interface test case information according to the interface test request, wherein the interface test case information comprises an interface identifier, an access address and path, an incoming parameter, an outgoing parameter, a request mode and a return parameter;
generating each interface test script according to each interface test case information;
combining the interface test scripts to obtain a target interface test script;
and performing interface test according to the target interface test script to obtain an interface test result.
2. The method according to claim 1, wherein the generating each interface test script according to each interface test case information comprises:
acquiring a script frame corresponding to each interface from a common frame database according to the test case information of each interface;
and generating each interface test script according to each script frame, wherein the public frame database comprises one of Punit, Pythest, Python, yaml, Allure, Logging and Request, and the structure of the script frame comprises a configuration file, test data, a log file and a test report.
3. The method of claim 1, wherein performing the interface test according to the target interface test script to obtain an interface test result comprises:
determining an interface to be tested according to the interface identifier;
performing interface test on the interface to be tested according to the target interface test script to obtain an interface return result;
and comparing the interface return result with the expected return result to obtain an interface test result.
4. The method according to claim 3, wherein the interface testing the interface to be tested according to the target interface test script to obtain an interface return result, comprising:
sending a Request to the interface to be tested by a Request secondary packaging method, wherein the Request carries a Token value;
if the Token value is successfully checked, executing the target interface test script and generating an interface return result, wherein the interface return result is stored in a yaml file, and the Token value is obtained based on the following steps:
searching a login interface from the interface to be tested;
sending a post Request to the login interface through a Request, and taking a user name and a password as incoming parameters to obtain a return value of the post Request;
and taking the return value as a Token value.
5. The method of claim 3, wherein comparing the interface return result with the expected return result to obtain an interface test result comprises:
comparing the interface return result with the expected return result;
if the interface return result is consistent with the expected return result, the test is successful, and an interface test result with the successful test is generated;
if the interface return result is inconsistent with the expected return result, the test fails, and an interface test result with the test failure is generated.
6. The method according to any one of claims 1-5, wherein after the interface test is performed according to the target interface test script to obtain an interface test result, the method further comprises:
if the test fails, acquiring repaired interface data;
and testing all the interfaces to be tested again according to the repaired interface data.
7. The method according to any one of claims 1-5, wherein after the interface test is performed according to the target interface test script to obtain an interface test result, the method further comprises:
determining a first interface test script and a second interface test script according to the test result, wherein the first interface test script is a script which is tested successfully, and the second interface test script is a script which is tested failed;
storing the first interface test script into a preset script database for subsequent calling;
and analyzing the reason of the test failure according to the test result and the second interface test script.
8. An apparatus for interface testing, comprising:
the system comprises a communication unit, a test unit and a control unit, wherein the communication unit is used for receiving an interface test request, the interface test request is used for testing a system comprising N interfaces, N is a positive integer greater than 1, and the interface test request comprises an interface identifier and an expected return result;
the processing unit is used for acquiring corresponding interface test case information according to the interface test request, wherein the interface test case information comprises an interface identifier, an access address and path, an incoming parameter, an outgoing parameter, a request mode and a return parameter; generating each interface test script according to each interface test case information; combining the interface test scripts to obtain a target interface test script; and performing interface test according to the target interface test script to obtain an interface test result.
9. A computer device, characterized in that it comprises a processor, a memory and a communication interface, wherein the memory stores a computer program configured to be executed by the processor, the computer program comprising instructions for carrying out the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, the computer program causing a computer to execute to implement the method of any one of claims 1-7.
CN202210099429.5A 2022-01-27 2022-01-27 Interface test method, device, equipment and storage medium Pending CN114546837A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210099429.5A CN114546837A (en) 2022-01-27 2022-01-27 Interface test method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210099429.5A CN114546837A (en) 2022-01-27 2022-01-27 Interface test method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114546837A true CN114546837A (en) 2022-05-27

Family

ID=81673676

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210099429.5A Pending CN114546837A (en) 2022-01-27 2022-01-27 Interface test method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114546837A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115150104A (en) * 2022-09-01 2022-10-04 梯度云科技(北京)有限公司 Method and device for periodically monitoring target interface
CN115391231A (en) * 2022-10-26 2022-11-25 江苏北弓智能科技有限公司 Automatic interface testing method

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115150104A (en) * 2022-09-01 2022-10-04 梯度云科技(北京)有限公司 Method and device for periodically monitoring target interface
CN115391231A (en) * 2022-10-26 2022-11-25 江苏北弓智能科技有限公司 Automatic interface testing method
CN115391231B (en) * 2022-10-26 2023-02-07 江苏北弓智能科技有限公司 Automatic interface testing method

Similar Documents

Publication Publication Date Title
CN110442524B (en) Method and device for testing web service interface with authentication authorization
CN109299015B (en) Software testing method, device and system
CN114546837A (en) Interface test method, device, equipment and storage medium
CN110442756A (en) Data verification method, device, computer equipment and storage medium
CN108400978B (en) Vulnerability detection method and device, computer equipment and storage medium
CN111475376B (en) Method, apparatus, computer device and storage medium for processing test data
CN110995825B (en) Intelligent contract issuing method, intelligent node equipment and storage medium
CN111290742A (en) Parameter verification method and device, electronic equipment and readable storage medium
CN110851471A (en) Distributed log data processing method, device and system
CN105117340B (en) URL detection methods and device for iOS browser application quality evaluations
CN114936136A (en) Business process monitoring method and device, computer equipment and storage medium
CN110647439B (en) Method and device for confirming block chain system deployment, computer equipment and storage medium
CN112650689A (en) Test method, test device, electronic equipment and storage medium
CN112559352A (en) Interface test method, device, equipment and storage medium
CN112433935A (en) Test method, test device, electronic equipment and storage medium
CN114579473B (en) Application testing method, device, equipment and storage medium
CN108345508B (en) Interface call testing method and device
CN112765038B (en) Distributed cluster software testing method, device, equipment and storage medium
CN112732676B (en) Block chain-based data migration method, device, equipment and storage medium
CN112631908A (en) Browser page testing method and device, computer equipment and storage medium
CN113535578A (en) CTS (clear to send) testing method, device and testing equipment
CN111310141A (en) Authentication management method, device, computer equipment and storage medium
CN113485944B (en) Software testing method and system
CN116823187A (en) Research and development business automatic auditing method and device and electronic equipment
CN113392023A (en) Automatic testing method and device, computer equipment, chip and module equipment

Legal Events

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