CN114003451B - Interface testing method, device, system and medium - Google Patents

Interface testing method, device, system and medium Download PDF

Info

Publication number
CN114003451B
CN114003451B CN202111257281.5A CN202111257281A CN114003451B CN 114003451 B CN114003451 B CN 114003451B CN 202111257281 A CN202111257281 A CN 202111257281A CN 114003451 B CN114003451 B CN 114003451B
Authority
CN
China
Prior art keywords
interface
service
flow
test
tested
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
CN202111257281.5A
Other languages
Chinese (zh)
Other versions
CN114003451A (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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202111257281.5A priority Critical patent/CN114003451B/en
Publication of CN114003451A publication Critical patent/CN114003451A/en
Application granted granted Critical
Publication of CN114003451B publication Critical patent/CN114003451B/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/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2273Test methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • 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
    • 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

Abstract

The application discloses an interface testing method, device, system and medium, wherein the method comprises the following steps: acquiring user log data generated by a server cluster in the process of responding to user service operation; extracting interface request information of a service interface called by user service operation from user log data; acquiring a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows; performing information configuration and encapsulation on a target service interface in the interface path by using the interface request information to obtain corresponding interface flow to be detected; and respectively playing back the flow of the interface to be tested in the reference environment and the test environment to obtain corresponding interface test results. According to the application, the interface flow to be tested obtained based on the user log data is used as an interface test case source to complete the interface test, so that the interface test efficiency is improved, the labor cost and the time cost are saved, and the risk caused by test case deletion due to manual writing of the test case is avoided.

Description

Interface testing method, device, system and medium
Technical Field
The present application relates to the field of automated interface testing, and in particular, to a method, apparatus, system, and medium for testing an interface.
Background
Currently, in the field of interface automation testing, interface testing is typically accomplished using the following test steps: manual combing test requirements; writing test cases according to requirements; writing an interface test script according to the test case and the interface design; and running an interface test script to test. However, when the test system is complex, such as some large applications, which may include hundreds of core applications and thousands of interfaces, and the implementation of the interfaces is complex, if the test script is written manually by a tester to complete the interface test, huge labor cost and time cost are consumed, and the efficiency is extremely low. Moreover, the test scene written in the mode is monotonous, and the interface test can not be completed completely due to the lack of test cases, so that risks are brought to the system.
In summary, how to perform a complete interface test and improve the efficiency in the test process is a problem to be solved at present.
Disclosure of Invention
Accordingly, the present application is directed to a method, apparatus, system and medium for testing an interface, which can perform a complete interface test and improve the efficiency in the test process. The specific scheme is as follows:
in a first aspect, the present application discloses an interface testing method, including:
acquiring user log data generated by a server cluster in the process of responding to user service operation;
extracting interface request information of a service interface called by the user service operation from the user log data;
acquiring a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows;
configuring and packaging information of a target service interface in the interface path by utilizing the interface request information to obtain corresponding interface flow to be tested;
and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result.
Optionally, the obtaining user log data generated by the server cluster in the process of responding to the user service operation includes:
creating a preset user log acquisition rule according to the time period and/or the service name;
and acquiring user log data generated by the server cluster in the process of responding to the user service operation by utilizing the preset user log acquisition rule.
Optionally, the extracting the interface request information of the service interface invoked by the user service operation from the user log data includes:
and extracting any one or more information of a request method, a request path, a request parameter and request header information of a service interface called by the user service operation from the user log data as interface request information.
Optionally, the generating a corresponding interface path based on the target service interface through which the custom service flows includes:
and generating a corresponding interface path by taking an initial service interface in a preset interface path template as a path starting point and based on a target service interface corresponding to a service node in the custom service flow, wherein when the service interface corresponding to any service node in the custom service flow is a plurality of service interfaces, one service interface is randomly selected from the plurality of service interfaces corresponding to the service node to serve as the target service interface corresponding to the service node.
Optionally, the interface testing method further includes:
and creating an interface path template based on all service interfaces in the server cluster and the calling sequence among different service interfaces to obtain the preset interface path template.
Optionally, the performing flow playback on the to-be-tested interface flow in the reference environment and the test environment to obtain a corresponding interface test result includes:
respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a first test result and a second test result, and carrying out result comparison on the first test result and the second test result;
if the first test result is consistent with the second test result, directly storing the interface flow to be tested in a first local flow library;
if the first test result is inconsistent with the second test result, marking the flow of the interface to be tested as failure, and storing the failure in a second local flow library.
Optionally, after marking the traffic of the interface to be tested as failure and storing the traffic in the second local traffic library, the method further includes:
generating a test report based on the interface traffic to be tested marked as failed;
and if the test report representation failure is caused by the fact that the interface path cannot be found by the interface flow to be tested, eliminating the interface flow to be tested from the second local flow library.
In a second aspect, the present application discloses an interface testing device, comprising:
the data acquisition module is used for acquiring user log data generated by the server cluster in the process of responding to user service operation;
the information extraction module is used for extracting interface request information of a service interface called by the user service operation from the user log data;
the path generation module is used for acquiring the self-defined service flow and generating a corresponding interface path based on a target service interface through which the self-defined service flow flows;
the flow acquisition module is used for carrying out information configuration and encapsulation on the target service interface in the interface path by utilizing the interface request information so as to obtain corresponding interface flow to be detected;
and the flow playback module is used for respectively playing back the flow of the interface to be tested in the reference environment and the test environment so as to obtain a corresponding interface test result.
In a third aspect, the present application discloses a computer device comprising:
a memory for storing a computer program;
and a processor for executing the computer program to implement the steps of the interface test method disclosed above.
In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the steps of the previously disclosed interface testing method.
The application provides an interface test method, which comprises the steps of firstly, obtaining user log data generated by a server cluster in the process of responding to user service operation; extracting interface request information of a service interface called by the user service operation from the user log data; then obtaining a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows; configuring and packaging information of a target service interface in the interface path by utilizing the interface request information to obtain corresponding interface flow to be tested; and finally, respectively playing back the flow of the interface to be tested in a reference environment and a test environment to obtain a corresponding interface test result. Therefore, the application carries out correlation analysis and editing on the acquired user log data to obtain the interface flow to be tested, and carries out flow playback on the interface flow to be tested to obtain the corresponding interface test result. In this way, the application can determine whether the flow of the interface to be tested can be used as the test case to complete the automatic interface test based on the interface test result, and the application adopts the real log data of the online user without manually writing the test case by a tester, thereby improving the automatic test efficiency of the interface, saving the labor cost and the time cost and avoiding the risk problem brought to the system by the test case deletion possibly caused by manually writing the test case.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of an interface testing method disclosed by the application;
FIG. 2 is a flowchart of a specific interface testing method disclosed in the present application;
FIG. 3 is a flowchart of a specific interface testing method disclosed in the present application;
FIG. 4 is a flow chart of an interface test in accordance with one embodiment of the present disclosure;
FIG. 5 is a schematic diagram of an interface testing device according to the present application;
fig. 6 is a block diagram of a computer device according to the present disclosure.
Detailed Description
The following description of the embodiments of the present application 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 application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Currently, in the field of automatic interface testing, interface testing is usually completed by manually writing test scripts by a tester. However, when the test system is complex, if the test script is written manually by the tester to complete the interface test, huge labor cost and time cost are consumed, and the efficiency is extremely low. Moreover, the test scene written in the mode is monotonous, and the interface test can not be completed completely due to the lack of test cases, so that risks are brought to the system. Therefore, the embodiment of the application discloses an interface testing method which can perform complete interface testing and improve efficiency in the testing process.
Referring to fig. 1, an embodiment of the present application discloses an interface testing method, which includes:
step S11: user log data generated by the server cluster in the process of responding to user service operation is obtained.
In this embodiment, the obtaining user log data generated by the server cluster in the process of responding to the user service operation may specifically include: creating a preset user log acquisition rule according to the time period and/or the service name; and acquiring user log data generated by the server cluster in the process of responding to the user service operation by utilizing the preset user log acquisition rule. It can be understood that, in this embodiment, when obtaining the user log data generated by the server cluster in the process of responding to the service operation on the user line, the user log data is mainly obtained according to the time period information and/or the service name information, that is, in this embodiment, not all the user log data generated by the server cluster in the process of responding to the service operation of the user is obtained, but the user log data is obtained according to a preset user log obtaining rule, so as to obtain the user log data meeting the requirement. For example, when a shopping platform has shopping activity in 20:00 to 22:00, user log data of the platform for a period of time can be selected to be pulled, and user log data corresponding to a business operation of purchasing goods by a user can be pulled.
Step S12: and extracting interface request information of a service interface called by the user service operation from the user log data.
In this embodiment, the extracting the interface request information of the service interface invoked by the user service operation from the user log data may specifically include: and extracting any one or more information of a request method, a request path, a request parameter and request header information of a service interface called by the user service operation from the user log data as interface request information. It can be understood that, after the user log data is obtained, the embodiment needs to extract the interface request information of the service interface called by the user service operation from the obtained user log data, and also needs to store the interface request information in the local database according to the format required by the interface test. It should be noted that, in the above extraction process, the user identification data in the user log data may be configured to be uniform values, the user identification data may include, but is not limited to, token, name, and phone, and the interface request information may include, but is not limited to, a request method, a request path, a request parameter, and request header information.
Step S13: and acquiring the custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows.
In this embodiment, it should be noted that, first, a custom service flow is obtained, and a corresponding one or more interface paths are randomly generated based on a target service interface through which the custom service flow flows.
Step S14: and configuring and packaging information of the target service interface in the interface path by utilizing the interface request information to obtain corresponding interface flow to be tested.
In this embodiment, after the interface path is generated, the information configuration and parameter encapsulation are performed on the target service interface in the interface path by using the interface request information obtained in step S12, that is, any one or more of the information of the request method, the request path, the request parameter and the request header information, to obtain the flow of the interface to be tested.
Step S15: and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result.
In this embodiment, the obtained flow of the interface to be tested needs to be tested in an online testing environment, where the online testing environment includes two parts, one is a reference environment of the trunk branch code and the other is a testing environment of the personal branch, where the reference environment can be understood as a very ideal environment, and is a contracted environment for correcting and comparing the testing results in other testing environments, and the testing environment is an environment conforming to the real testing scenario. Therefore, the final interface test result is obtained by respectively playing back the flow of the interface to be tested in the reference environment and the test environment.
It can be seen that, in the embodiment of the present application, first, user log data generated in a process of responding to user service operation by a server cluster is obtained; extracting interface request information of a service interface called by the user service operation from the user log data; then obtaining a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows; configuring and packaging information of a target service interface in the interface path by utilizing the interface request information to obtain corresponding interface flow to be tested; and finally, respectively playing back the flow of the interface to be tested in a reference environment and a test environment to obtain a corresponding interface test result. Therefore, the application carries out correlation analysis and editing on the acquired user log data to obtain the interface flow to be tested, and carries out flow playback on the interface flow to be tested to obtain the corresponding interface test result. In this way, the application can determine whether the flow of the interface to be tested can be used as the test case to complete the automatic interface test based on the interface test result, and the application adopts the real log data of the online user without manually writing the test case by a tester, thereby improving the automatic test efficiency of the interface, saving the labor cost and the time cost and avoiding the risk problem brought to the system by the test case deletion possibly caused by manually writing the test case.
Referring to fig. 2, an embodiment of the present application discloses a specific interface testing method, and compared with the previous embodiment, the present embodiment further describes and optimizes a technical solution. The method specifically comprises the following steps:
step S21: user log data generated by the server cluster in the process of responding to user service operation is obtained.
Step S22: and extracting interface request information of a service interface called by the user service operation from the user log data.
Step S23: and acquiring a custom service flow, taking an initial service interface in a preset interface path template as a path starting point, and generating a corresponding interface path based on a target service interface corresponding to a service node in the custom service flow, wherein when the service interface corresponding to any service node in the custom service flow is a plurality of service interfaces, one service interface is randomly selected from the plurality of service interfaces corresponding to the service node to serve as the target service interface corresponding to the service node.
In this embodiment, the interface testing method further includes: and creating an interface path template based on all service interfaces in the server cluster and the calling sequence among different service interfaces to obtain the preset interface path template. It can be understood that a specified sequence of calls is provided between different service interfaces, so that a tester needs to edit the sequence of calls of all service interfaces in the server cluster and create an interface path template.
After the interface path template is obtained, an initial service interface in the template, namely, a service interface which is called first is taken as a path starting point, and a corresponding interface path is generated based on a target service interface corresponding to a service node in the custom service flow. It should be noted that, the number of service interfaces corresponding to a plurality of service nodes in the custom service flow may be multiple, that is, the node has multiple selectable services, and when this situation is encountered, one service interface is randomly selected from the multiple service interfaces as the target service interface corresponding to the service node. In this way, by means of the mode of randomly selecting the service interfaces, after the flow of the whole self-defined service flow is finished, a plurality of random interface paths are generated, so that the test scenes are covered as much as possible, and the occurrence of missing test problems is reduced.
Step S24: and configuring and packaging information of the target service interface in the interface path by utilizing the interface request information to obtain corresponding interface flow to be tested.
Step S25: and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result.
For more specific processing procedures in steps S21, S22, S24 and S25, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and no further description is given here.
Therefore, the embodiment of the application achieves the aim of covering test service interfaces as much as possible by randomly selecting one service interface when generating the interface path, and enables the generated interface flow to be tested to be the random interface flow to be tested corresponding to the interface path, thereby reducing the missing test problem caused by the limited number of interface test scripts written by a tester, improving the safety of the system, and adopting an automatic mode without a series of work such as manual writing, debugging, maintenance test scripts by the tester.
Referring to fig. 3, an embodiment of the present application discloses a specific interface testing method, and compared with the previous embodiment, the present embodiment further describes and optimizes a technical solution. The method specifically comprises the following steps:
step S31: user log data generated by the server cluster in the process of responding to user service operation is obtained.
Step S32: and extracting interface request information of a service interface called by the user service operation from the user log data.
Step S33: and acquiring the custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows.
Step S34: and configuring and packaging information of the target service interface in the interface path by utilizing the interface request information to obtain corresponding interface flow to be tested.
Step S35: and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a first test result and a second test result, and carrying out result comparison on the first test result and the second test result. And if the first test result is consistent with the second test result, directly storing the interface flow to be tested in a first local flow library.
In this embodiment, the first test result and the second test result obtained by performing flow playback on the interface flow to be tested in the reference environment and the test environment respectively are compared. When the comparison results are consistent, the interface flow to be tested is stored in a first local flow library, namely, the interface flow to be tested at this time accords with the real scene, and then the interface flow to be tested stored in the first local flow library can be directly used as an interface test case for system test at a later stage.
It should be noted that if the first test result and the second test result are inconsistent, the interface flow to be tested is marked as failure and stored in a second local flow library. And after marking the interface traffic to be tested as failure and storing the interface traffic in a second local traffic library, the method further comprises: generating a test report based on the interface traffic to be tested marked as failed; and if the test report representation failure is caused by the fact that the interface path cannot be found by the interface flow to be tested, eliminating the interface flow to be tested from the second local flow library. In this implementation, if the second test result obtained in the test environment is inconsistent with the first test result obtained in the reference environment, it is indicated that the interface traffic to be tested may have a problem in the test environment, so the interface traffic to be tested is marked as failed and is stored in the second local traffic library separately, and the interface traffic to be tested marked as failed is generated into a test report for a tester to analyze and confirm whether the interface traffic to be tested really has a problem, where if the failure cause is that the interface traffic to be tested cannot find a corresponding interface path, the interface traffic to be tested is removed from the second local traffic library. It can be understood that, because the randomization process is used in the generation process of the interface paths, which is equivalent to that the interface traffic to be tested is also randomly generated, some interface traffic to be tested which does not conform to the real scene may occur, that is, the corresponding interface paths cannot be found, so that errors occur in the playback of the traffic in the test environment. And in the case of such cases, eliminating the interface flow to be tested from the second local flow library. It should be noted that, in this embodiment, the interface traffic marked as failed, which is finally stored in the second local traffic library, is most likely caused by a problem occurring in the corresponding function in the test environment. Therefore, the application can conveniently analyze and check the interface flow after storing the interface flow marked as failed to find out the cause of the abnormal function problem and determine the corresponding solution. In addition, after the means is adopted to solve the abnormal function problem, the interface flow can be further executed to verify whether the corresponding abnormal function problem is successfully solved.
For more specific processing procedures in steps S31, S32, S33 and S34, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and no further description is given here.
Therefore, in the embodiment of the application, the first test result and the second test result obtained by respectively carrying out flow playback on the interface flow to be tested in the reference environment and the test environment are compared, and whether the interface flow to be tested can be used as the interface test case for the later system test is determined based on the comparison result. By the method, interface test is not required to be completed by manually writing the test script by a tester, the automatic test efficiency of the interface is improved, the labor cost and the time cost are saved, and meanwhile, the risk problem that the system is caused by test case deletion possibly caused by manually writing the test case is also avoided.
Referring to fig. 4, an embodiment of the present application discloses a specific interface testing flowchart, which includes: firstly, user log data generated in the server cluster response on-line user service operation is acquired and on-line log storage is carried out; pulling time period information and service name information of the online user log data, extracting a request method, a request path, request parameters and request header information of a service interface called during online user service operation from the user log data obtained after pulling, taking the request method, the request path, the request parameters and the request header information as interface request information, and storing the interface request information in a local log; then, the stored log data are intelligently analyzed and edited to generate interface flow to be tested and stored in a local flow library; and finally, respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain respective corresponding test results, eliminating unsuitable flow from a local flow library according to the test results, and solidifying the flow.
Referring to fig. 5, the embodiment of the application also discloses an interface testing device, which comprises:
a data acquisition module 11, configured to acquire user log data generated by the server cluster in a process of responding to a user service operation;
an information extraction module 12, configured to extract, from the user log data, interface request information of a service interface invoked by the user service operation;
the path generating module 13 is configured to obtain a custom service flow, and generate a corresponding interface path based on a target service interface through which the custom service flow flows;
the flow obtaining module 14 is configured to configure and package information of the target service interface in the interface path by using the interface request information, so as to obtain a corresponding interface flow to be tested;
and the flow playback module 15 is used for respectively playing back the flow of the interface to be tested in the reference environment and the test environment so as to obtain a corresponding interface test result.
It can be seen that the present application firstly obtains user log data generated by a server cluster in the process of responding to user service operation; extracting interface request information of a service interface called by the user service operation from the user log data; then obtaining a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows; configuring and packaging information of a target service interface in the interface path by utilizing the interface request information to obtain corresponding interface flow to be tested; and finally, respectively playing back the flow of the interface to be tested in a reference environment and a test environment to obtain a corresponding interface test result. Therefore, the application carries out correlation analysis and editing on the acquired user log data to obtain the interface flow to be tested, and carries out flow playback on the interface flow to be tested to obtain the corresponding interface test result. In this way, the application can determine whether the flow of the interface to be tested can be used as the test case to complete the automatic interface test based on the interface test result, and the application adopts the real log data of the online user without manually writing the test case by a tester, thereby improving the automatic test efficiency of the interface, saving the labor cost and the time cost and avoiding the risk problem brought to the system by the test case deletion possibly caused by manually writing the test case.
In some specific embodiments, the data acquisition module 11 further includes:
the rule creation unit is used for creating a preset user log acquisition rule according to the time period and/or the service name;
the log data acquisition unit is used for acquiring the user log data generated by the server cluster in the process of responding to the user service operation by utilizing the preset user log acquisition rule.
In some embodiments, the information extraction module 12 further includes:
and the request information extraction unit is used for extracting any one or more of a request method, a request path, a request parameter and request header information of a service interface called by the user service operation from the user log data as interface request information.
In some specific embodiments, the path generating module 13 further includes:
and the interface path generating unit is used for generating a corresponding interface path by taking an initial service interface in a preset interface path template as a path starting point and based on a target service interface corresponding to a service node in the custom service flow, wherein when the service interface corresponding to any service node in the custom service flow is a plurality of service interfaces, one service interface is randomly selected from the plurality of service interfaces corresponding to the service node to serve as the target service interface corresponding to the service node.
In some specific embodiments, the interface testing device may further include:
and the template creation unit is used for creating an interface path template based on all service interfaces in the server cluster and the calling sequence among different service interfaces so as to obtain the preset interface path template.
In some embodiments, the flow playback module 15 further includes:
the result comparison unit is used for playing back the flow of the interface to be tested in a reference environment and a test environment respectively to obtain a first test result and a second test result, and comparing the first test result and the second test result;
the first flow saving unit is used for directly saving the interface flow to be tested in a first local flow library if the first test result is consistent with the second test result;
and the second flow saving unit is used for marking the flow of the interface to be tested as failure if the first test result and the second test result are inconsistent, and saving the flow in a second local flow library.
In some embodiments, the second flow holding unit may be followed by;
a report generating unit, configured to generate a test report based on the interface traffic to be tested marked as failed;
and the flow eliminating unit is used for eliminating the interface flow to be tested from the second local flow library if the test report representation failure cause is that the interface flow to be tested cannot find the interface path.
Fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present application. Specifically, the method comprises the following steps: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein the memory 22 is used for storing a computer program, which is loaded and executed by the processor 21 to implement relevant steps in the interface testing method performed by the computer device as disclosed in any of the foregoing embodiments.
In this embodiment, the power supply 23 is used to provide an operating voltage for each hardware device on the computer device 20; the communication interface 24 can create a data transmission channel between the computer device 20 and an external device, and the communication protocol to be followed is any communication protocol applicable to the technical solution of the present application, which is not specifically limited herein; the input/output interface 25 is used for acquiring external input data or outputting external output data, and the specific interface type thereof may be selected according to the specific application requirement, which is not limited herein.
Processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 may be implemented in at least one hardware form of DSP (Digital Signal Processing ), FPGA (Field-Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array ). The processor 21 may also comprise a main processor, which is a processor for processing data in an awake state, also called CPU (Central Processing Unit ); a coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit, image processor) for rendering and drawing of content required to be displayed by the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence ) processor for processing computing operations related to machine learning.
The memory 22 may be a carrier for storing resources, such as a read-only memory, a random access memory, a magnetic disk, or an optical disk, and the resources stored thereon include an operating system 221, a computer program 222, and data 223, and the storage may be temporary storage or permanent storage.
The operating system 221 is used for managing and controlling various hardware devices on the computer device 20 and the computer program 222, so as to implement the operation and processing of the processor 21 on the mass data 223 in the memory 22, which may be Windows, unix, linux. The computer program 222 may further include a computer program capable of performing other specific tasks in addition to the computer program capable of performing the interface testing method performed by the computer device 20 as disclosed in any of the foregoing embodiments. The data 223 may include, in addition to data received by the computer device and transmitted from an external device, data collected by the input/output interface 25 itself, and so on.
Further, the embodiment of the application also discloses a storage medium, wherein the storage medium stores a computer program, and when the computer program is loaded and executed by a processor, the method steps executed in the interface test process disclosed in any embodiment are realized.
Finally, it is further 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.
The above description of the method, the device, the equipment and the storage medium for testing the interface provided by the application applies specific examples to illustrate the principle and the implementation of the application, and the above examples are only used for helping to understand the method and the core idea of the application; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. An interface testing method, comprising:
acquiring user log data generated by a server cluster in the process of responding to user service operation;
extracting interface request information of a service interface called by the user service operation from the user log data;
acquiring a custom service flow, and generating a corresponding interface path based on a target service interface through which the custom service flow flows;
configuring and packaging information of a target service interface in the interface path by utilizing the interface request information to obtain corresponding interface flow to be tested;
and respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a corresponding interface test result.
2. The interface testing method according to claim 1, wherein the obtaining user log data generated by the server cluster in response to the user service operation includes:
creating a preset user log acquisition rule according to the time period and/or the service name;
and acquiring user log data generated by the server cluster in the process of responding to the user service operation by utilizing the preset user log acquisition rule.
3. The interface testing method according to claim 1, wherein the extracting the interface request information of the service interface invoked by the user service operation from the user log data includes:
and extracting any one or more information of a request method, a request path, a request parameter and request header information of a service interface called by the user service operation from the user log data as interface request information.
4. The interface testing method according to claim 1, wherein the generating a corresponding interface path based on the target service interface through which the custom service flow flows includes:
and generating a corresponding interface path by taking an initial service interface in a preset interface path template as a path starting point and based on a target service interface corresponding to a service node in the custom service flow, wherein when the service interface corresponding to any service node in the custom service flow is a plurality of service interfaces, one service interface is randomly selected from the plurality of service interfaces corresponding to the service node to serve as the target service interface corresponding to the service node.
5. The interface testing method of claim 4, further comprising:
and creating an interface path template based on all service interfaces in the server cluster and the calling sequence among different service interfaces to obtain the preset interface path template.
6. The method for testing an interface according to any one of claims 1 to 5, wherein the performing flow playback on the to-be-tested interface flow in the reference environment and the test environment to obtain the corresponding interface test result includes:
respectively carrying out flow playback on the interface flow to be tested in a reference environment and a test environment to obtain a first test result and a second test result, and carrying out result comparison on the first test result and the second test result;
if the first test result is consistent with the second test result, directly storing the interface flow to be tested in a first local flow library;
if the first test result is inconsistent with the second test result, marking the flow of the interface to be tested as failure, and storing the failure in a second local flow library.
7. The method for testing an interface according to claim 6, wherein after marking the interface traffic to be tested as failed and storing the marked interface traffic in the second local traffic pool, further comprising:
generating a test report based on the interface traffic to be tested marked as failed;
and if the test report representation failure is caused by the fact that the interface path cannot be found by the interface flow to be tested, eliminating the interface flow to be tested from the second local flow library.
8. An interface testing apparatus, comprising:
the data acquisition module is used for acquiring user log data generated by the server cluster in the process of responding to user service operation;
the information extraction module is used for extracting interface request information of a service interface called by the user service operation from the user log data;
the path generation module is used for acquiring the self-defined service flow and generating a corresponding interface path based on a target service interface through which the self-defined service flow flows;
the flow acquisition module is used for carrying out information configuration and encapsulation on the target service interface in the interface path by utilizing the interface request information so as to obtain corresponding interface flow to be detected;
and the flow playback module is used for respectively playing back the flow of the interface to be tested in the reference environment and the test environment so as to obtain a corresponding interface test result.
9. A computer device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the interface testing method of any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program; wherein the computer program when executed by a processor implements the steps of the interface testing method of any of claims 1 to 7.
CN202111257281.5A 2021-10-27 2021-10-27 Interface testing method, device, system and medium Active CN114003451B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111257281.5A CN114003451B (en) 2021-10-27 2021-10-27 Interface testing method, device, system and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111257281.5A CN114003451B (en) 2021-10-27 2021-10-27 Interface testing method, device, system and medium

Publications (2)

Publication Number Publication Date
CN114003451A CN114003451A (en) 2022-02-01
CN114003451B true CN114003451B (en) 2023-08-25

Family

ID=79924396

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111257281.5A Active CN114003451B (en) 2021-10-27 2021-10-27 Interface testing method, device, system and medium

Country Status (1)

Country Link
CN (1) CN114003451B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627851B (en) * 2023-07-24 2023-10-20 恒生电子股份有限公司 Interface testing method and device
CN117555809B (en) * 2024-01-09 2024-03-22 舟谱数据技术南京有限公司 Automatic testing method and related device based on flow replication playback

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111221743A (en) * 2020-03-18 2020-06-02 时时同云科技(成都)有限责任公司 Automatic testing method and system
CN111552633A (en) * 2020-03-27 2020-08-18 深圳壹账通智能科技有限公司 Interface abnormal call testing method and device, computer equipment and storage medium
CN112559361A (en) * 2020-12-22 2021-03-26 京东数字科技控股股份有限公司 Flow playback method, device, equipment and computer readable medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111221743A (en) * 2020-03-18 2020-06-02 时时同云科技(成都)有限责任公司 Automatic testing method and system
CN111552633A (en) * 2020-03-27 2020-08-18 深圳壹账通智能科技有限公司 Interface abnormal call testing method and device, computer equipment and storage medium
CN112559361A (en) * 2020-12-22 2021-03-26 京东数字科技控股股份有限公司 Flow playback method, device, equipment and computer readable medium

Also Published As

Publication number Publication date
CN114003451A (en) 2022-02-01

Similar Documents

Publication Publication Date Title
CN111159049B (en) Automatic interface testing method and system
CN114003451B (en) Interface testing method, device, system and medium
CN107608874A (en) Method of testing and device
CN106933729A (en) A kind of method of testing and system based on cloud platform
CN109448100A (en) Threedimensional model format conversion method, system, computer equipment and storage medium
CN107729228A (en) Interface test method, device, storage medium and processor
CN102999419B (en) A kind of Android test incident record back method and device
CN111813686A (en) Game testing method and device, testing terminal and storage medium
CN105760300B (en) A kind of automated testing method and test macro of STK/UTK business
CN112732237B (en) Method and system for constructing code-free development technology model
CN114201346A (en) HIL (hardware-in-the-loop) testing method and device of CAN (controller area network) communication interface and electronic equipment
CN106990974A (en) A kind of APP applications update method, device and electronic equipment
CN112988267A (en) Loading method and device, storage medium and electronic equipment
CN111708712A (en) User behavior test case generation method, flow playback method and electronic equipment
CN116383061A (en) Method and related device for testing basic platform interface of substation control system
CN113220561A (en) Test case management method, device, equipment and medium
CN111324480A (en) Large host transaction fault positioning system and method
CN115168840A (en) Fault injection method and device and computer readable storage medium
CN110221952B (en) Service data processing method and device and service data processing system
CN114066398A (en) Business model management method and device, storage medium and terminal equipment
CN110738384B (en) Event sequence checking method and system
CN112199229A (en) Data processing method, device, equipment and storage medium
CN112559377A (en) Method and device for generating first test case
CN110321276A (en) The generation method and device of test case
CN112527662A (en) Test script generation method and device

Legal Events

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