CN114003484A - Log output method, device and equipment for interface test and storage medium - Google Patents

Log output method, device and equipment for interface test and storage medium Download PDF

Info

Publication number
CN114003484A
CN114003484A CN202010742629.9A CN202010742629A CN114003484A CN 114003484 A CN114003484 A CN 114003484A CN 202010742629 A CN202010742629 A CN 202010742629A CN 114003484 A CN114003484 A CN 114003484A
Authority
CN
China
Prior art keywords
request
test
target
log
initial
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
CN202010742629.9A
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 Sinosun Technology Co ltd
Original Assignee
Shenzhen Sinosun 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 Sinosun Technology Co ltd filed Critical Shenzhen Sinosun Technology Co ltd
Priority to CN202010742629.9A priority Critical patent/CN114003484A/en
Publication of CN114003484A publication Critical patent/CN114003484A/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a log output method, a device, equipment and a storage medium for interface test.A corresponding initial request method of a test request is constructed when the test request is received, the initial request method is packaged, and a log object is introduced into the initial request method to obtain a target request method; constructing request parameters of a test request to obtain a target request object, and generating a test script based on a target request method and the target request object; and executing the test script, and generating and outputting a log record corresponding to the test request. The test script for outputting the log record is generated by the target request method and the target request object, the log record is introduced while the initial request method constructed by the target request method is packaged, and the target request object comprises the request parameter of the test request, so that the log object only needs to be called once when the test script is executed, the log record is prevented from being printed and output for many times, and the log output efficiency of the interface test is improved.

Description

Log output method, device and equipment for interface test and storage medium
Technical Field
The present invention relates to the field of test technologies, and in particular, to a method, an apparatus, a device, and a storage medium for outputting a log of an interface test.
Background
Currently, when an interface automatic test is performed, each interface is packaged in a class, parameters of an interface request are set as class attributes in the class, the request parameters are packaged in a method, a Logger class is introduced from a Logger. The requests library is imported into the test script, and a log record of the requests/responses is generated when the requests are sent.
However, if more than two interfaces need to be called in one use case, a phenomenon occurs in which the log records are repeatedly printed. Therefore, when the interface automatic test is performed, the log record of the request/response is acquired in the above manner, and the log record is repeatedly printed, so that the log output efficiency of the interface test is low.
Disclosure of Invention
The invention mainly aims to provide a method, a device, equipment and a storage medium for outputting a log of an interface test, and aims to solve the technical problem of low log output efficiency of the interface test during the automatic interface test.
In order to achieve the above object, an embodiment of the present invention provides a log output method for an interface test, where the log output method for the interface test includes:
when a test request is received, constructing an initial request method corresponding to the test request, packaging the initial request method, and introducing a log object into the initial request method to obtain a target request method;
constructing request parameters of the test request to obtain a target request object, and generating a test script based on the target request method and the target request object;
and executing the test script, and generating and outputting a log record corresponding to the test request.
Preferably, the step of encapsulating the initial request method and introducing a log object into the initial request method to obtain a target request method includes:
detecting whether a target method matched with the initial request method exists in a preset request library or not;
if a target method matched with the initial request method exists, packaging the initial request method according to the target method;
and introducing the log object constructed in the first preset class into the initial request method to obtain a target request method.
Preferably, the step of constructing an initial request method corresponding to the test request includes:
analyzing the test request to obtain to-be-tested information of the test request;
according to the method information of the information to be tested, searching a request method template corresponding to the method information in a method library;
and constructing an initial request method corresponding to the test request in a second preset class according to the request method template.
Preferably, the step of constructing the request parameters of the test request to obtain the target request object includes:
acquiring a request object template from a request object library, and constructing an initial request object in the second preset class according to the request object template;
and constructing request parameters of the initial request object according to the request object information of the information to be tested to obtain a target request object of the test request.
Preferably, the step of generating a test script based on the target request method and the target request object includes:
importing the target request object into an initial script, and executing the initial script to call the target request method based on the target request object;
transmitting the request parameters in the target request object to the target request method;
and performing parameter assignment on the target request method according to the request parameters to generate a test script.
Preferably, the step of performing parameter assignment on the target request method according to the request parameter and generating a test script includes:
determining a parameter attribute to be assigned corresponding to the parameter attribute in the target request method according to the parameter attribute of the request parameter;
and inserting the parameter value of the request parameter into the parameter value to be assigned corresponding to the parameter attribute to be assigned, assigning the parameter value to be assigned, and generating a test script.
Preferably, the step of executing the test script, and generating and outputting a log record corresponding to the test request includes:
executing the test script, calling test information corresponding to the test request based on the log object, and generating a log record;
and outputting the log records to the corresponding positions of all processors in a preset processor group through the preset processor group.
In order to achieve the above object, the present invention further provides a log output device for an interface test, where the log output device for the interface test includes:
the packaging module is used for constructing an initial request method corresponding to the test request when the test request is received, packaging the initial request method, and introducing a log object into the initial request method to obtain a target request method;
the construction module is used for constructing request parameters of the test request, obtaining a target request object and generating a test script based on the target request method and the target request object;
and the execution module is used for executing the test script and generating and outputting the log record corresponding to the test request.
Further, in order to achieve the above object, the present invention further provides an interface test log output device, where the interface test log output device includes a memory, a processor, and an interface test log output program stored in the memory and executable on the processor, and the interface test log output program implements the above steps of the interface test log output method when executed by the processor.
Further, to achieve the above object, the present invention further provides a storage medium, where the storage medium stores a log output program for an interface test, and the log output program for the interface test implements the steps of the log output method for the interface test when executed by a processor.
The embodiment of the invention provides a log output method, a log output device, equipment and a storage medium for interface test, wherein when a test request is received, an initial request method corresponding to the test request is constructed, the initial request method is packaged, and a log object is introduced into the initial request method to obtain a target request method; constructing request parameters of the test request to obtain a target request object, and generating a test script based on the target request method and the target request object; and executing the test script, and generating and outputting a log record corresponding to the test request. The test script for outputting the log record is generated by the target request method and the target request object, the log record is introduced while the initial request method constructed by the target request method is packaged, and the target request object comprises the request parameter of the test request, so that the log object only needs to be called once when the test script is executed, the log record is prevented from being printed and output for many times, and the log output efficiency of the interface test is improved.
Drawings
FIG. 1 is a schematic structural diagram of a hardware operating environment related to an embodiment of a log output method for interface testing according to the present invention;
FIG. 2 is a flowchart illustrating a log output method for interface testing according to a first embodiment of the present invention;
FIG. 3 is a flowchart illustrating a log output method for interface testing according to a second embodiment of the present invention;
FIG. 4 is a functional block diagram of a log output device for interface test according to a preferred embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the invention provides a log output method, a log output device, equipment and a storage medium for interface test, wherein when a test request is received, an initial request method corresponding to the test request is constructed, the initial request method is packaged, and a log object is introduced into the initial request method to obtain a target request method; constructing request parameters of the test request to obtain a target request object, and generating a test script based on the target request method and the target request object; and executing the test script, and generating and outputting a log record corresponding to the test request. The test script for outputting the log record is generated by the target request method and the target request object, the log record is introduced while the initial request method constructed by the target request method is packaged, and the target request object comprises the request parameter of the test request, so that the log object only needs to be called once when the test script is executed, the log record is prevented from being printed and output for many times, and the log output efficiency of the interface test is improved.
As shown in fig. 1, fig. 1 is a schematic structural diagram of a log output device for interface testing of a hardware operating environment according to an embodiment of the present invention.
In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for facilitating the explanation of the present invention, and have no specific meaning in itself. Thus, "module", "component" or "unit" may be used mixedly.
The log output device of the interface test of the embodiment of the invention can be a PC, and can also be a mobile terminal device such as a tablet computer and a portable computer.
As shown in fig. 1, the log output device of the interface test may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the interface test log output device configuration shown in FIG. 1 does not constitute a limitation of the interface test log output device, and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a storage medium, may include therein an operating system, a network communication module, a user interface module, and a log output program for interface test.
In the device shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 may be configured to call a log output program of the interface test stored in the memory 1005 and perform the following operations:
when a test request is received, constructing an initial request method corresponding to the test request, packaging the initial request method, and introducing a log object into the initial request method to obtain a target request method;
constructing request parameters of the test request to obtain a target request object, and generating a test script based on the target request method and the target request object;
and executing the test script, and generating and outputting a log record corresponding to the test request.
Further, the step of encapsulating the initial request method and introducing a log object into the initial request method to obtain a target request method includes:
detecting whether a target method matched with the initial request method exists in a preset request library or not;
if a target method matched with the initial request method exists, packaging the initial request method according to the target method;
and introducing the log object constructed in the first preset class into the initial request method to obtain a target request method.
Further, the step of constructing an initial request method corresponding to the test request includes:
analyzing the test request to obtain to-be-tested information of the test request;
according to the method information of the information to be tested, searching a request method template corresponding to the method information in a method library;
and constructing an initial request method corresponding to the test request in a second preset class according to the request method template.
Further, the step of constructing the request parameters of the test request and obtaining the target request object includes:
acquiring a request object template from a request object library, and constructing an initial request object in the second preset class according to the request object template;
and constructing request parameters of the initial request object according to the request object information of the information to be tested to obtain a target request object of the test request.
Further, the step of generating a test script based on the target request method and the target request object includes:
importing the target request object into an initial script, and executing the initial script to call the target request method based on the target request object;
transmitting the request parameters in the target request object to the target request method;
and performing parameter assignment on the target request method according to the request parameters to generate a test script.
Further, the step of performing parameter assignment on the target request method according to the request parameters and generating the test script includes:
determining a parameter attribute to be assigned corresponding to the parameter attribute in the target request method according to the parameter attribute of the request parameter;
and inserting the parameter value of the request parameter into the parameter value to be assigned corresponding to the parameter attribute to be assigned, assigning the parameter value to be assigned, and generating a test script.
Further, the step of executing the test script, and generating and outputting a log record corresponding to the test request includes:
executing the test script, calling test information corresponding to the test request based on the log object, and generating a log record;
and outputting the log records to the corresponding positions of all processors in a preset processor group through the preset processor group.
For a better understanding of the above technical solutions, exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to better understand the technical solution, the technical solution will be described in detail with reference to the drawings and the specific embodiments.
Referring to fig. 2, a first embodiment of the present invention provides a flowchart of a log output method for interface testing. In this embodiment, the log output method for the interface test includes the following steps:
step S10, when a test request is received, constructing an initial request method corresponding to the test request, encapsulating the initial request method, and introducing a log object into the initial request method to obtain a target request method;
the log output method of the interface test in this embodiment is applied to a test tool of the interface test, and the test tool is preferably pychar based on pychar in this embodiment, where pychar is a Python IDE created by jetbranches, and IDE (Integrated Development Environment) is used to provide an application program of a program Development Environment, and generally includes tools such as a code editor, a compiler, a debugger, and a graphical user interface, where jetbranches is a family of agility software Development companies, and Python is a cross-platform computer programming language.
Further, when a user has an interface test requirement, setting information to be tested in the test tool PyCharm, and after the information to be tested is completed, initiating a test request, wherein the information to be tested at least comprises method information and request object information, the method information comprises a method to be tested for performing the interface test, and the request object information comprises an object to be tested for performing the interface test. Further, when receiving a test request sent by a user, the test tool constructs a log object in a first preset class, where the first preset class is a Logger class in this embodiment, and the log object is used to call log methods at different levels and log contents that need to be output in the test request. Further, the test tool constructs an initial Request method of the test Request in a second preset class according to the method information in the information to be tested, where the second preset class is a Request class in this embodiment. Further, the test tool searches a target method from a preset request library according to the initial request method, and when the target method is found, the initial request method is packaged according to the target method; the method comprises the steps that when an initial request method is packaged, a system introduces a log object constructed in a first preset class into the initial request method, and after the packaging and the introduction of the log object are completed, a target request method is obtained, wherein a preset request library stores a plurality of request methods, the preset request library is a third-party library requests in the embodiment, and the requests library is a Python HTTP client library.
Further, the step of constructing an initial request method corresponding to the test request includes:
step S11, analyzing the test request to obtain the information to be tested of the test request;
step S12, according to the method information of the information to be tested, searching a request method template corresponding to the method information in a method library;
step S13, constructing an initial request method corresponding to the test request in a second preset class according to the request method template.
Further, the test tool parses the received test request, specifically, the test tool identifies text content included in the test request to obtain to-be-tested information of the test request, where the to-be-tested information at least includes method information and request object information, and in this embodiment, the method information may include one of request methods such as GET, HEAD, and POST. Further, the test tool searches whether a request method template corresponding to the request method of the method information exists in a method library according to one of the plurality of request methods in the method information, wherein the method library is used for storing the plurality of request method templates of the interface test. Further, if a Request method template corresponding to the Request method of the method information exists in the method library, extracting the Request method template corresponding to the Request method into a second preset type Request class, inputting parameter information of the Request method in the method information into the extracted Request method template, and constructing and obtaining an initial Request method corresponding to the test Request.
Step S20, constructing request parameters of the test request to obtain a target request object, and generating a test script based on the target request method and the target request object;
further, after receiving the test Request, the test tool constructs an initial Request object in a second preset class Request class through the Request object template, and constructs a Request parameter corresponding to the test Request in the initial Request object according to the Request object information in the information to be tested, so as to obtain a target Request object. Furthermore, the test tool calls a target request method through the target request object, transmits request parameters for representing actual parameters in the target request object to the target request method, assigns the parameters of the representation form parameters of the target request method, and generates a test script corresponding to the test request after assignment is completed, so as to execute the test script and generate and output a log record of interface test.
Further, the step of constructing the request parameters of the test request in the initial request object to obtain the target request object includes:
step S21, obtaining a request object template from a request object library, and constructing an initial request object in the second preset class according to the request object template;
step S22, constructing request parameters for the initial request object according to the request object information of the information to be tested, so as to obtain a target request object of the test request.
Further, the test tool is further provided with a Request object library, and the Request object library stores a plurality of Request object templates required for performing the interface test, where the Request object templates are used to construct Request objects, and the Request objects in this embodiment are preferably Request objects, and the Request objects are used to send test requests. Further, after receiving the test request, the test tool searches whether a request object template corresponding to the test request exists in the request object library, specifically, the test tool may identify a type of the request object to be tested from the information to be tested of the test request, and search for the request object template having the same type as the request object to be tested from the request object library. Further, if the Request object template with the same type as the Request object to be tested is found, the Request object template is extracted, and in a second preset class Request class, the Request object template constructs an initial Request object. Further, the test tool obtains request object information in the information to be tested, and constructs request parameters for the initial request object, wherein the request parameters at least comprise parameter attributes and parameter values.
And step S30, executing the test script, and generating and outputting a log record corresponding to the test request.
Further, the test tool executes the generated test script, records the test information generated in the test process in a blank log, and generates a test log. Furthermore, the test tool calls a log method and tests log contents through the log object to generate a log record, outputs the generated log record through the preset processor group, and outputs the log record to a position corresponding to each processor of the preset processor group.
Further, the step of executing the test script, and generating and outputting a log record corresponding to the test request includes:
step S31, executing the test script, calling the test information corresponding to the test request based on the log object, and generating a log record;
and step S32, outputting the log record to a position corresponding to each processor in a preset processor group through the preset processor group.
Furthermore, the test tool executes the test script generated by the target request object and the target request method, records the test information such as the test position information, the test function information, the test result information and the like generated in the test process, and stores the recorded test information in a blank log to generate a test log. Furthermore, the test tool calls log methods of different levels and test log contents which need to be output in the test request through the log object to generate log records, transmits the log records to a preset processor group, and outputs the log records through the preset processor group, wherein the preset processor at least comprises a stream processor and a file processor. Specifically, the system transmits the log records to a preset processor group, outputs the log records to a console of the test tool for display through a stream processor contained in the preset processor group, and outputs the log records to a file for storage through a file processor contained in the preset processor group.
The embodiment provides a log output method, a log output device, equipment and a storage medium for interface testing, wherein when a test request is received, an initial request method corresponding to the test request is constructed, the initial request method is packaged, and a log object is introduced into the initial request method to obtain a target request method; constructing request parameters of the test request to obtain a target request object, and generating a test script based on the target request method and the target request object; and executing the test script, and generating and outputting a log record corresponding to the test request. The test script for outputting the log record is generated by the target request method and the target request object, the log record is introduced while the initial request method constructed by the target request method is packaged, and the target request object comprises the request parameter of the test request, so that the log object only needs to be called once when the test script is executed, the log record is prevented from being printed and output for many times, and the log output efficiency of the interface test is improved.
Further, referring to fig. 3, a second embodiment of the log output method for the interface test of the present invention is proposed based on the first embodiment of the log output method for the interface test of the present invention, in the second embodiment, the step of encapsulating the initial request method and introducing a log object into the initial request method to obtain a target request method includes:
step S14, detecting whether a target method matched with the initial request method exists in a preset request library;
step S15, if there is a target method matching the initial request method, packaging the initial request method according to the target method;
step S16, introducing the log object constructed in the first preset class into the initial request method to obtain the target request method.
Further, the test tool detects from the requests library according to the method name of the initial request method, determines whether there is a request method with the same method name as the initial request method, further determines whether the parameter of the request method is the same as the parameter of the initial request method if there is a request method with the same method name as the initial request method, and determines that there is a target method matching the initial request method if the parameter of the request method is the same as the parameter of the initial request method. Furthermore, the test tool calls a target method, and encapsulates the initial request method according to parameters in the target method; and when the initial request method is packaged, the test tool introduces the log object constructed in the Logger class into the initial request method in a calling mode in the initial request method, and after the packaging and the introduction of the log object are completed, the target request method is obtained. The test script is generated by the target request method obtained by encapsulating the initial request method and introducing the log object into the initial request method and the target request object, when the test script is executed, the encapsulated target request method is called by the target request object, the log object is called once, one log record is printed, repeated printing of the log record caused by calling the log object for multiple times is avoided, and the log output efficiency of the interface test is improved.
According to the method and the device, the initial request method is packaged through the target method matched with the initial request method in the preset request library, the log object is introduced into the initial request method to obtain the target request method, and when the test script generated by the target request method and the target request object is executed, one log record is output by calling the log object once, so that repeated printing of the log record is avoided, and the log output efficiency of the interface test is improved.
Further, a third embodiment of the log output method of the interface test of the present invention is proposed based on the first embodiment or the second embodiment of the log output method of the interface test of the present invention, and in the third embodiment, the step of generating a test script based on the target request method and the target request object includes:
step S23, importing the target request object into an initial script, and executing the initial script to call the target request method based on the target request object;
step S24, transferring the request parameters in the target request object to the target request method;
and step S25, performing parameter assignment on the target request method according to the request parameters, and generating a test script.
Furthermore, the test tool calls an initial script used for constructing the test script, and introduces the target request object into the initial script, wherein the initial script comprises general test information required by the interface test. Furthermore, the test tool executes the initial script after the target request object is imported, extracts the constructed request parameters from the target request object, and transmits the request parameters to the target request method in a calling mode. Further, the test tool determines the attribute of the parameter to be assigned corresponding to the parameter attribute in the target request method according to the parameter attribute of the request parameter, inserts the parameter value of the request parameter into the parameter value to be assigned corresponding to the parameter attribute to be assigned, assigns the parameter value to be assigned, and generates the test script.
Further, the step of performing parameter assignment on the target request method according to the request parameters and generating the test script includes:
step S251, determining the parameter attribute to be assigned corresponding to the parameter attribute in the target request method according to the parameter attribute of the request parameter;
step S252, inserting the parameter value of the request parameter into the to-be-assigned parameter value corresponding to the to-be-assigned parameter attribute, assigning the to-be-assigned parameter value, and generating a test script.
Further, the test tool takes the attribute name of the parameter attribute in the request parameter as a keyword, searches whether the parameter attribute to be assigned with the same attribute name as the parameter attribute exists in the target request method, and sets an identifier at the position of the parameter value to be assigned corresponding to the parameter attribute to be assigned if the parameter attribute to be assigned with the same attribute name as the parameter attribute exists. Furthermore, the test tool inserts the parameter value of the request parameter into the position of the identified parameter value to be assigned, assigns the parameter value to be assigned, and generates a test script for interface test after assignment is completed.
In the embodiment, the target request method is assigned through the request parameter of the target request object, and the test script is generated, so that when the test script is executed, the target request method including the log object is called through the target request object, the log object is called only once, and a log record corresponding to the test request is generated and output, thereby avoiding the log record being printed and output for many times, and improving the log output efficiency of the interface test.
Furthermore, the invention also provides a log output device for the interface test.
Referring to fig. 4, fig. 4 is a functional module diagram of a log output device for interface test according to a first embodiment of the present invention.
The log output device for the interface test comprises:
the packaging module 10 is configured to, when a test request is received, construct an initial request method corresponding to the test request, package the initial request method, and introduce a log object into the initial request method to obtain a target request method;
a constructing module 20, configured to construct request parameters of the test request, obtain a target request object, and generate a test script based on the target request method and the target request object;
and the execution module 30 is configured to execute the test script, and generate and output a log record corresponding to the test request.
Further, the package module 10 includes:
the analysis unit is used for analyzing the test request to obtain to-be-tested information of the test request;
the retrieval unit is used for retrieving a request method template corresponding to the method information in a method library according to the method information of the information to be tested;
and the first construction unit is used for constructing an initial request method corresponding to the test request in a second preset class according to the request method template.
Further, the package module 10 further includes:
the detection unit is used for detecting whether a target method matched with the initial request method exists in a preset request library or not;
the packaging unit is used for packaging the initial request method according to the target method if the target method matched with the initial request method exists;
and the introducing unit is used for introducing the log object constructed in the first preset class into the initial request method to obtain the target request method.
Further, the construction module 20 includes:
an obtaining unit, configured to obtain a request object template from a request object library, and construct an initial request object in the second preset class according to the request object template;
and the second construction unit is used for constructing request parameters of the initial request object according to the request object information of the information to be tested to obtain a target request object of the test request.
Further, the construction module 20 further includes:
the import unit is used for importing the target request object into an initial script and executing the initial script so as to call the target request method based on the target request object;
a transfer unit, configured to transfer the request parameter in the target request object to the target request method;
and the assignment unit is used for performing parameter assignment on the target request method according to the request parameters to generate a test script.
Further, the construction module 20 further includes:
a determining unit, configured to determine, according to a parameter attribute of the request parameter, a parameter attribute to be assigned, corresponding to the parameter attribute, in the target request method;
and the inserting unit is used for inserting the parameter value of the request parameter into the parameter value to be assigned corresponding to the parameter attribute to be assigned, assigning the parameter value to be assigned and generating a test script.
Further, the execution module 30 includes:
the execution unit is used for executing the test script, calling test information corresponding to the test request based on the log object and generating a log record;
and the output unit is used for outputting the log records to the positions corresponding to the processors in the preset processor group through the preset processor group.
Furthermore, the present invention also provides a storage medium, preferably a computer-readable storage medium, on which a log output program of an interface test is stored, where the log output program of the interface test is executed by a processor to implement the steps of the above-mentioned log output method of the interface test.
In the embodiments of the log output device and the computer readable medium for interface testing of the present invention, all technical features of the embodiments of the log output method for interface testing are included, and the description and explanation contents are basically the same as those of the embodiments of the log output method for interface testing, and are not described herein again.
It should be noted that, in this document, 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 an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention or a part contributing to the prior art may be embodied in the form of a software product, where the computer software product is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk), and includes a plurality of instructions for enabling a terminal device (which may be a fixed terminal, such as an internet of things smart device including smart homes, such as a smart air conditioner, a smart lamp, a smart power supply, a smart router, etc., or a mobile terminal, including a smart phone, a wearable networked AR/VR device, a smart sound box, an autonomous driving automobile, etc.) to execute the method according to each embodiment of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A log output method for an interface test is characterized by comprising the following steps:
when a test request is received, constructing an initial request method corresponding to the test request, packaging the initial request method, and introducing a log object into the initial request method to obtain a target request method;
constructing request parameters of the test request to obtain a target request object, and generating a test script based on the target request method and the target request object;
and executing the test script, and generating and outputting a log record corresponding to the test request.
2. The log outputting method for interface test as claimed in claim 1, wherein the step of encapsulating the initial request method and introducing a log object in the initial request method to obtain a target request method comprises:
detecting whether a target method matched with the initial request method exists in a preset request library or not;
if a target method matched with the initial request method exists, packaging the initial request method according to the target method;
and introducing the log object constructed in the first preset class into the initial request method to obtain a target request method.
3. The log outputting method for interface test as claimed in claim 1, wherein the step of constructing an initial request method corresponding to the test request comprises:
analyzing the test request to obtain to-be-tested information of the test request;
according to the method information of the information to be tested, searching a request method template corresponding to the method information in a method library;
and constructing an initial request method corresponding to the test request in a second preset class according to the request method template.
4. The log outputting method for interface test as claimed in claim 3, wherein the step of constructing request parameters of the test request to obtain a target request object comprises:
acquiring a request object template from a request object library, and constructing an initial request object in the second preset class according to the request object template;
and constructing request parameters of the initial request object according to the request object information of the information to be tested to obtain a target request object of the test request.
5. The log outputting method of an interface test of claim 1, wherein the generating of the test script based on the target request method and the target request object comprises:
importing the target request object into an initial script, and executing the initial script to call the target request method based on the target request object;
transmitting the request parameters in the target request object to the target request method;
and performing parameter assignment on the target request method according to the request parameters to generate a test script.
6. The log output method of interface test as claimed in claim 5, wherein the step of performing parameter assignment on the target request method according to the request parameter and generating a test script comprises:
determining a parameter attribute to be assigned corresponding to the parameter attribute in the target request method according to the parameter attribute of the request parameter;
and inserting the parameter value of the request parameter into the parameter value to be assigned corresponding to the parameter attribute to be assigned, assigning the parameter value to be assigned, and generating a test script.
7. The method for outputting logs of an interface test according to claim 1, wherein the step of executing the test script, generating and outputting the log record corresponding to the test request comprises:
executing the test script, calling test information corresponding to the test request based on the log object, and generating a log record;
and outputting the log records to the corresponding positions of all processors in a preset processor group through the preset processor group.
8. An interface test log output device, characterized in that the interface test log output device comprises:
the packaging module is used for constructing an initial request method corresponding to the test request when the test request is received, packaging the initial request method, and introducing a log object into the initial request method to obtain a target request method;
the construction module is used for constructing request parameters of the test request, obtaining a target request object and generating a test script based on the target request method and the target request object;
and the execution module is used for executing the test script and generating and outputting the log record corresponding to the test request.
9. An interface test logging output device, characterized in that the interface test logging output device comprises a memory, a processor and an interface test logging output program stored on the memory and executable on the processor, which when executed by the processor implements the steps of the interface test logging output method according to any one of claims 1-7.
10. A storage medium having stored thereon a logging output program of an interface test, the logging output program of the interface test, when executed by a processor, implementing the steps of the logging output method of an interface test according to any one of claims 1-7.
CN202010742629.9A 2020-07-28 2020-07-28 Log output method, device and equipment for interface test and storage medium Pending CN114003484A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010742629.9A CN114003484A (en) 2020-07-28 2020-07-28 Log output method, device and equipment for interface test and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010742629.9A CN114003484A (en) 2020-07-28 2020-07-28 Log output method, device and equipment for interface test and storage medium

Publications (1)

Publication Number Publication Date
CN114003484A true CN114003484A (en) 2022-02-01

Family

ID=79920786

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010742629.9A Pending CN114003484A (en) 2020-07-28 2020-07-28 Log output method, device and equipment for interface test and storage medium

Country Status (1)

Country Link
CN (1) CN114003484A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114676067A (en) * 2022-05-26 2022-06-28 武汉迎风聚智科技有限公司 Parameterization processing method and device for test script

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114676067A (en) * 2022-05-26 2022-06-28 武汉迎风聚智科技有限公司 Parameterization processing method and device for test script
CN114676067B (en) * 2022-05-26 2022-08-30 武汉迎风聚智科技有限公司 Parameterization processing method and device for test script

Similar Documents

Publication Publication Date Title
CN107908541B (en) Interface testing method and device, computer equipment and storage medium
CN111045952B (en) Software testing method, flow playback device, terminal equipment and readable storage medium
CN106406844B (en) Method and device for realizing public number menu of communication interaction platform
US11640464B2 (en) Protocol model learning and guided firmware analysis
CN106528393A (en) Method and device for Mock testing of WebService
CN111459495A (en) Unit test code file generation method, electronic device and storage medium
CN111737334A (en) Data reporting method, device, equipment and storage medium
CN112540924A (en) Interface automation test method, device, equipment and storage medium
CN111181805B (en) Micro-service test baffle generation method and system based on test case
CN113268245A (en) Code analysis method, device and storage medium
CN111026670A (en) Test case generation method, test case generation device, and storage medium
CN111209326A (en) Data query method and device, electronic equipment and storage medium
CN114003484A (en) Log output method, device and equipment for interface test and storage medium
CN110543429A (en) Test case debugging method and device and storage medium
CN111026669B (en) Test log management method, test log management device and storage medium
CN113900922A (en) Method, device, equipment and medium for testing application program interface of multi-platform application
CN111061637A (en) Interface test method, interface test device and storage medium
CN111209325A (en) Service system interface identification method, device and storage medium
CN110688315A (en) Interface code detection report generation method, electronic device, and storage medium
CN113032836B (en) Data desensitization method and apparatus
CN114329495A (en) Endogenous security based asset vulnerability static analysis method and device
CN110096281B (en) Code analysis method, analysis server, storage medium and device
CN112181816A (en) Interface testing method and device based on scene, computer equipment and medium
CN109284097B (en) Method, device, system and storage medium for realizing complex data analysis
CN113268420A (en) Development method, device and system of data interface and computer storage medium

Legal Events

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