CN117056222A - Interface test file generation method and device, electronic equipment and storage medium - Google Patents

Interface test file generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117056222A
CN117056222A CN202311034509.3A CN202311034509A CN117056222A CN 117056222 A CN117056222 A CN 117056222A CN 202311034509 A CN202311034509 A CN 202311034509A CN 117056222 A CN117056222 A CN 117056222A
Authority
CN
China
Prior art keywords
interface
file
url
data file
target
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
CN202311034509.3A
Other languages
Chinese (zh)
Inventor
单晓光
刘明莉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Jiufangyun Intelligent Technology Co ltd
Original Assignee
Shanghai Jiufangyun 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 Shanghai Jiufangyun Intelligent Technology Co ltd filed Critical Shanghai Jiufangyun Intelligent Technology Co ltd
Priority to CN202311034509.3A priority Critical patent/CN117056222A/en
Publication of CN117056222A publication Critical patent/CN117056222A/en
Pending legal-status Critical Current

Links

Classifications

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

Landscapes

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

Abstract

The invention discloses an interface test file generation method, an interface test file generation device, electronic equipment and a storage medium. The method comprises the following steps: acquiring interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted; analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name; generating a target data file based on the interface name and the parameters to be transmitted by the interface; inputting the interface URL to a script file generation template to obtain a target script file; and generating an interface test file based on the target data file and the target script file. According to the technical scheme, the automatic generation of the interface test file is realized, and the generation efficiency of the interface test file is improved.

Description

Interface test file generation method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and apparatus for generating an interface test file, an electronic device, and a storage medium.
Background
In the software development process, testing is an important link for guaranteeing the quality and reliability of software. As software complexity increases, manual testing becomes increasingly impractical. Automated testing is thus a necessary tool in modern software development processes.
Automated testing typically relies on test scripts that are written and executed according to specific test requirements and scenarios. However, the conventional interface test script writing method generally needs to write an automation script manually according to the interface document of each interface, and has a problem of low writing efficiency of the interface test file.
Disclosure of Invention
The invention provides a method, a device, electronic equipment and a storage medium for generating an interface test file, which are used for solving the problem of low writing efficiency of the interface test file.
According to an aspect of the present invention, there is provided an interface test file generating method, including:
acquiring interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted;
analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name;
generating a target data file based on the interface name and the parameters to be transmitted by the interface;
inputting the interface URL to a script file generation template to obtain a target script file;
and generating an interface test file based on the target data file and the target script file.
According to another aspect of the present invention, there is provided an interface test file generating apparatus including:
the interface information acquisition module is used for acquiring interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted in;
the URL analysis module is used for analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name;
the target data file generation module is used for generating a target data file based on the interface name and the parameters to be transmitted in of the interface;
the target script file generation module is used for inputting the interface URL to a script file generation template to obtain a target script file;
and the interface test file generation module is used for generating an interface test file based on the target data file and the target script file.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor;
and a memory communicatively coupled to the at least one processor;
the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor, so that the at least one processor can execute the interface test file generating method according to any embodiment of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement the interface test file generation method according to any one of the embodiments of the present invention when executed.
According to the technical scheme, interface information of the interface test file to be generated is obtained, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted, the interface URL is further analyzed to obtain an analysis result corresponding to the interface URL, the analysis result corresponding to the interface URL comprises an interface name, a target data file is further generated based on the interface name and the interface parameter to be transmitted, the interface URL is input into a script file generation template to obtain a target script file, the interface test file is further generated based on the target data file and the target script file, automatic generation of the interface test file is achieved, and generation efficiency of the interface test file is improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a block diagram of an automated test equipment provided in accordance with an embodiment of the present invention;
FIG. 2 is a flowchart of a method for generating an interface test file according to a first embodiment of the present invention;
FIG. 3 is a flowchart of a method for generating an interface test file according to a second embodiment of the present invention;
FIG. 4 is a flowchart of a method for generating an interface test file according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of an interface test file generating device according to a fourth embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device implementing the interface test file generation method according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Before describing a specific embodiment, an application scenario of the present invention is described. Fig. 1 is a schematic diagram of an automated testing apparatus provided by the present invention, where the automated testing apparatus includes an interface test file generating apparatus, an interface document platform, a database, and an automated executing apparatus. Specifically, when the interface test file generating device is started, the interface test file generating device calls the interface document platform, acquires interface information from the interface document platform, and stores the acquired interface information in the database. Furthermore, the interface test file generating device can take another asynchronous thread to acquire the interface information of the interface test file to be generated from the database, further automatically generate the interface test file according to the interface information of the interface test file to be generated, and after the interface test files of all interfaces are generated, the automatic executing device operates the interface test files of all interfaces to realize automatic interface test.
Example 1
Fig. 2 is a flowchart of an interface test file generating method according to a first embodiment of the present invention, where the method may be performed by an interface test file generating device, and the interface test file generating device may be implemented in hardware and/or software, and the interface test file generating device may be configured in a terminal and/or a server. As shown in fig. 2, the method includes:
s110, obtaining interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted.
In this embodiment, the interface information of the interface test file to be generated is the interface information for generating the interface test file, which may include, but is not limited to, an interface URL and an interface to-be-transferred parameter. The parameters to be transmitted by the interface refer to parameters to be transmitted by the current interface, and may include a request parameter, a default value, and the like.
For example, the interface information of the interface test file to be generated may include information of one or more interfaces. Specifically, the interface information of the interface test file to be generated may be obtained from the database, and the interface information of the interface test file to be generated may be called from the interface document platform, which is not limited in any way. It should be noted that, compared with the interface information obtained from the interface document platform, the interface information of the interface test file to be generated is obtained from the database, which can reduce the time cost of repeated analysis and realize rapid obtaining of the interface information.
S120, analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name.
The parsing result corresponding to the interface URL may include information such as an interface service name and an interface name.
Illustratively, the interface URL may be parsed according to URL unification rules, thereby identifying the interface service name and the interface name in the interface URL. Specifically, the interface URL can be 'https:// 120.0.1:8080/auto-tools-api/get/list/by/name', and the name of the interface service obtained by analysis is auto-tools-api, and the name of the interface is/get/list/by/name. The URL unification rule is interface service name+interface name, and it can be understood that the interface URL constituent elements and element distribution can be known through the URL unification rule, so that identification of each element in the interface URL is realized.
S130, generating a target data file based on the interface name and the parameters to be input by the interface.
Specifically, parameters to be transmitted into the interface can be arranged in a file based on a preset fixed format, and the interface name is used as a use case name of the interface test, so that a target data file is obtained, and automatic generation of the data file is realized.
S140, inputting the interface URL to a script file generation template to obtain a target script file.
Specifically, the interface URL may be input into the script file generation template, and the URL in the script file generation template is replaced with the input interface URL, so as to obtain the target script file, and realize automatic generation of the script file.
S150, generating an interface test file based on the target data file and the target script file.
Specifically, the target data file and the target script file may be combined to generate the interface test file. It can be understood that the interface test file is composed of a data file and a script file, and the data file and the script file required by the interface test file are automatically generated through the interface URL and the parameters to be input by the interface, so that the time spent by manually assembling the script and the cost caused by errors due to manual assembly are reduced.
Optionally, after generating the interface test file based on the target data file and the target script file, the method further comprises: executing the interface test file to obtain an interface return result; and generating an interface test report based on the interface return result.
Specifically, after the interface test files of all the interfaces are generated, the automatic execution device can execute the interface test files of each interface, and then whether the interface test files are successful or not is judged according to the interface return result, if the code in the interface return result is 1, the marking of the interface return result is successful, if the code in the interface return result is not 1, the marking of the interface return result is failed, and then an interface test report is generated according to the marking in the interface return result, so that the interface test period is greatly shortened, the test labor cost is effectively reduced, and the interface test efficiency is improved.
According to the technical scheme, interface information of the interface test file to be generated is obtained, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted, the interface URL is further analyzed to obtain an analysis result corresponding to the interface URL, the analysis result corresponding to the interface URL comprises an interface name, a target data file is further generated based on the interface name and the interface parameter to be transmitted, the interface URL is input into a script file generation template to obtain a target script file, the interface test file is further generated based on the target data file and the target script file, automatic generation of the interface test file is achieved, and generation efficiency of the interface test file is improved.
Example two
Fig. 3 is a flowchart of a method for generating an interface test file according to a second embodiment of the present invention, where the method of this embodiment may be combined with each of the alternatives in the method for generating an interface test file provided in the foregoing embodiment. The interface test file generation method provided by the embodiment is further optimized. Optionally, the generating the target data file based on the interface name and the parameters to be input into the interface includes: and filling the parameters to be transmitted into the interface into an initial data file, and taking the interface name as a test case name of the data file to obtain a target data file, wherein the initial data file is a data file with information discharged based on a preset format.
As shown in fig. 3, the method includes:
s210, obtaining interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted.
S220, analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name.
S230, filling the parameters to be transmitted into the initial data file by the interface, and taking the interface name as the test case name of the data file to obtain the target data file.
The initial data file refers to a data file with information arranged based on a preset format, in other words, the initial data file contains initial information arranged according to the preset format for filling or replacing parameters to be input by the interface, so that automatic generation of the data file is realized.
Optionally, the interface parameters to be transferred in include an interface request parameter and a default value; correspondingly, filling the parameters to be transmitted into the interface into the initial data file comprises the following steps: generating a variable name of an initial data file and a variable value of the initial data file based on an interface request parameter, and filling the variable name of the initial data file and the variable value of the initial data file into a preset variable position of the initial data file; and filling the default value into a preset default value position of the initial data file.
Wherein the default value refers to a fixed request parameter value.
The interface request parameter may be a pageSize, which may be used as a variable name of the initial data file, and a variable value of the initial data file may be randomly generated according to a pre-configured generation rule, so that the pageSize and the variable value may be filled into a preset variable position of the initial data file; the fixed request parameter is a pageNo, the fixed request parameter value is 1, and then 1 can be filled in a preset default position of the initial data file, so that a target data file is obtained, an automatic file name can be used as the file name of the target data file and stored in a data file directory of a service to which the interface belongs, wherein the automatic file name can be generated according to an interface URL.
S240, inputting the interface URL to a script file generation template to obtain a target script file.
S250, generating an interface test file based on the target data file and the target script file.
According to the technical scheme, the parameters to be transmitted into the interface are filled into the initial data file, and the interface name is used as the test case name of the data file, so that the target data file is obtained, automatic generation of the data file is realized, and further the generation efficiency of the interface test file is improved.
Example III
Fig. 4 is a flowchart of a method for generating an interface test file according to the third embodiment of the present invention, where the method of this embodiment may be combined with each of the alternatives in the method for generating an interface test file provided in the foregoing embodiment. The interface test file generation method provided by the embodiment is further optimized. Optionally, the inputting the interface URL into a script file generation template to obtain a target script file includes: and replacing the placeholder corresponding to the interface URL in the script file generation template with the interface URL to obtain the target script file.
As shown in fig. 4, the method includes:
s310, obtaining interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted.
S320, analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name.
S330, generating a target data file based on the interface name and the parameters to be input by the interface.
S340, replacing the placeholder corresponding to the interface URL in the script file generation template with the interface URL to obtain the target script file.
S350, generating an interface test file based on the target data file and the target script file.
In this embodiment, the placeholder corresponding to the interface URL in the script file generation template is replaced by the acquired interface URL, so that automatic generation of the script file is realized, and thus, the generation efficiency of the interface test file is improved.
Optionally, before inputting the interface URL into the script file generation template to obtain the target script file, the method further includes: acquiring a request mode of a current interface; matching the request mode of the current interface in a script file template library to obtain a script file generation template.
The request mode of the current interface may be a get request mode, a post request mode or a delete request mode.
For example, if the request mode of the current interface is the get request mode, a script file generation template corresponding to the get request mode is matched in a script file template library, and the post request mode or delete request mode is the same, which is not described herein.
Optionally, after obtaining the script file generation template, the method further comprises: replacing placeholders corresponding to the data file paths in the script file generation template with paths corresponding to the target data files; and/or replacing the placeholder corresponding to the interface request mode in the script file generation template with the request mode of the current interface; and/or replacing the placeholder corresponding to the interface request parameter in the script file generation template with the interface request parameter in the interface to-be-transmitted parameters.
The script file is automatically generated by replacing the placeholder corresponding to the interface URL, the placeholder corresponding to the data file path, the placeholder corresponding to the interface request mode and the placeholder corresponding to the interface request parameter in the script file generation template. In addition, after the script file is generated, the automation file name may be used as the file name of the target script file and saved into the script file directory of the service of the interface.
In some embodiments, the storage path of the interface test file may be further identified, and if the storage path of the interface test file does not exist, the storage path of the interface test file may be created according to the interface service name, for example, "-" in the interface service name "auto-units-api" may be changed to "_", that is, "auto-units-api" is used as the file name under the storage path. If the storage path of the interface test file exists, the step is skipped.
According to the technical scheme, the target script file is obtained by replacing the placeholder corresponding to the interface URL in the script file generation template with the interface URL, so that the script file is automatically generated, and the generation efficiency of the interface test file is improved.
Example IV
Fig. 5 is a schematic structural diagram of an interface test file generating device according to a fourth embodiment of the present invention. As shown in fig. 5, the apparatus includes:
the interface information obtaining module 410 is configured to obtain interface information of an interface test file to be generated, where the interface information of the interface test file to be generated includes an interface URL and an interface to-be-transmitted parameter;
the URL parsing module 420 is configured to parse the interface URL to obtain a parsing result corresponding to the interface URL, where the parsing result corresponding to the interface URL includes an interface name;
a target data file generating module 430, configured to generate a target data file based on the interface name and the parameters to be input by the interface;
the target script file generating module 440 is configured to input the interface URL into a script file generating template to obtain a target script file;
an interface test file generating module 450, configured to generate an interface test file based on the target data file and the target script file.
According to the technical scheme, interface information of the interface test file to be generated is obtained, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted, the interface URL is further analyzed to obtain an analysis result corresponding to the interface URL, the analysis result corresponding to the interface URL comprises an interface name, a target data file is further generated based on the interface name and the interface parameter to be transmitted, the interface URL is input into a script file generation template to obtain a target script file, the interface test file is further generated based on the target data file and the target script file, automatic generation of the interface test file is achieved, and generation efficiency of the interface test file is improved.
In some alternative embodiments, the target data file generation module 430 includes:
and the data file assembly unit is used for filling the parameters to be transmitted into the interface into an initial data file, and taking the interface name as a test case name of the data file to obtain a target data file, wherein the initial data file is a data file with information discharged based on a preset format.
In some optional embodiments, the interface pending incoming parameters include an interface request parameter and a default value;
correspondingly, the data file assembling unit is further specifically configured to:
generating a variable name of an initial data file and a variable value of the initial data file based on the interface request parameter, and filling the variable name of the initial data file and the variable value of the initial data file into a preset variable position of the initial data file;
and filling the default value into a preset default value position of the initial data file.
In some alternative embodiments, the target script file generation module 440 is specifically configured to:
and replacing the placeholder corresponding to the interface URL in the script file generation template with the interface URL to obtain the target script file.
In some optional embodiments, the interface test file generating device further includes:
the request mode acquisition module is used for acquiring the request mode of the current interface;
and the script template matching module is used for matching the request mode of the current interface in a script file template library to obtain a script file generation template.
In some optional embodiments, the interface test file generating device further includes:
the file path replacing module is used for replacing the placeholder corresponding to the data file path in the script file generating template with the path corresponding to the target data file;
and/or a request mode replacing module, which is used for replacing the placeholder corresponding to the interface request mode in the script file generating template with the request mode of the current interface;
and/or a request parameter replacing module, configured to replace a placeholder corresponding to the interface request parameter in the script file generating template with an interface request parameter in the interface parameters to be transferred.
In some optional embodiments, the interface test file generating device further includes:
the test file executing module is used for executing the interface test file to obtain an interface return result;
and the interface test report generating module is used for generating an interface test report based on the interface return result.
The interface test file generating device provided by the embodiment of the invention can execute the interface test file generating method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the executing method.
Example five
Fig. 6 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices (e.g., helmets, eyeglasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 6, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An I/O interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as an interface test file generation method, which includes:
acquiring interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted;
analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name;
generating a target data file based on the interface name and the parameters to be transmitted by the interface;
inputting the interface URL to a script file generation template to obtain a target script file;
and generating an interface test file based on the target data file and the target script file.
In some embodiments, the interface test file generation method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the interface test file generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the interface test file generation method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. An interface test file generation method is characterized by comprising the following steps:
acquiring interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted;
analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name;
generating a target data file based on the interface name and the parameters to be transmitted by the interface;
inputting the interface URL to a script file generation template to obtain a target script file;
and generating an interface test file based on the target data file and the target script file.
2. The method of claim 1, wherein the generating a target data file based on the interface name and the interface parameters to be entered comprises:
and filling the parameters to be transmitted into the interface into an initial data file, and taking the interface name as a test case name of the data file to obtain a target data file.
3. The method of claim 2, wherein the interface pending incoming parameters include an interface request parameter and a default value;
correspondingly, filling the parameters to be transmitted into the initial data file by the interface comprises the following steps:
generating a variable name of an initial data file and a variable value of the initial data file based on the interface request parameter, and filling the variable name of the initial data file and the variable value of the initial data file into a preset variable position of the initial data file;
and filling the default value into a preset default value position of the initial data file.
4. The method of claim 1, wherein the inputting the interface URL into a script file generation template to obtain a target script file comprises:
and replacing the placeholder corresponding to the interface URL in the script file generation template with the interface URL to obtain the target script file.
5. The method of claim 1, wherein prior to said entering the interface URL into a script file generation template to obtain a target script file, the method further comprises:
acquiring a request mode of a current interface;
and matching the request mode of the current interface in a script file template library to obtain a script file generation template.
6. The method of claim 5, wherein after the deriving script file generates a template, the method further comprises:
replacing placeholders corresponding to the data file paths in the script file generation template with paths corresponding to the target data files;
and/or replacing the placeholder corresponding to the interface request mode in the script file generation template with the request mode of the current interface;
and/or replacing the placeholder corresponding to the interface request parameter in the script file generation template with the interface request parameter in the interface to-be-transmitted parameters.
7. The method of any of claims 1-6, wherein after the generating an interface test file based on the target data file and the target script file, the method further comprises:
executing the interface test file to obtain an interface return result;
and generating an interface test report based on the interface return result.
8. An interface test file generating device, characterized by comprising:
the interface information acquisition module is used for acquiring interface information of an interface test file to be generated, wherein the interface information of the interface test file to be generated comprises an interface URL and an interface parameter to be transmitted in;
the URL analysis module is used for analyzing the interface URL to obtain an analysis result corresponding to the interface URL, wherein the analysis result corresponding to the interface URL comprises an interface name;
the target data file generation module is used for generating a target data file based on the interface name and the parameters to be transmitted in of the interface;
the target script file generation module is used for inputting the interface URL to a script file generation template to obtain a target script file;
and the interface test file generation module is used for generating an interface test file based on the target data file and the target script file.
9. An electronic device, the electronic device comprising:
at least one processor;
and a memory communicatively coupled to the at least one processor;
wherein the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the interface test file generation method of any one of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the interface test file generation method of any one of claims 1-7 when executed.
CN202311034509.3A 2023-08-16 2023-08-16 Interface test file generation method and device, electronic equipment and storage medium Pending CN117056222A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311034509.3A CN117056222A (en) 2023-08-16 2023-08-16 Interface test file generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311034509.3A CN117056222A (en) 2023-08-16 2023-08-16 Interface test file generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117056222A true CN117056222A (en) 2023-11-14

Family

ID=88656725

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311034509.3A Pending CN117056222A (en) 2023-08-16 2023-08-16 Interface test file generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117056222A (en)

Similar Documents

Publication Publication Date Title
CN108984388B (en) Method and terminal equipment for generating automatic test case
CN116303013A (en) Source code analysis method, device, electronic equipment and storage medium
CN116301997A (en) Upgrading method, device, equipment and medium of controller
CN116126719A (en) Interface testing method and device, electronic equipment and storage medium
CN117056222A (en) Interface test file generation method and device, electronic equipment and storage medium
CN115017047A (en) Test method, system, equipment and medium based on B/S architecture
CN115061921A (en) Automatic test method, device, electronic equipment and readable storage medium
CN114428747A (en) User interface testing method, device, server and storage medium
CN116955504B (en) Data processing method and device, electronic equipment and storage medium
CN117670236A (en) Mobile-terminal-based to-be-handled flow approval method, device, equipment and medium
CN117609064A (en) Unit test method and device, electronic equipment and storage medium
CN116628383A (en) Page jump method, device, electronic equipment and storage medium
CN117251196A (en) Data maintenance method, device, equipment and storage medium
CN117931155A (en) Code generation method, device, equipment and medium
CN115567624A (en) Message processing method and device, electronic equipment and medium
CN116450400A (en) Application program abnormality analysis method and device, electronic equipment and storage medium
CN116862388A (en) Production method, device, software material clearing end, continuous integration end and medium
CN117806604A (en) TLV data analysis method and device based on spring boot frame
CN117632120A (en) Processing system, method, equipment and storage medium for report data
CN117827637A (en) Automatic test method and device and electronic equipment
CN116302944A (en) Service system testing method and device, electronic equipment and storage medium
CN115859300A (en) Vulnerability detection method and device, electronic equipment and storage medium
CN117033234A (en) Interface testing method, device, equipment and medium
CN117251209A (en) Method, device, equipment and medium for generating detailed setting model through code analysis
CN117493203A (en) Method, device, equipment and storage medium for testing server software

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