Disclosure of Invention
In order to solve the technical problems described above or at least partially solve the technical problems, the present application provides a testing method, an apparatus, a system, an electronic device, and a storage medium.
In a first aspect, the present application provides a testing method, comprising:
acquiring input parameters and output parameters of a to-be-tested interface on a to-be-tested link, wherein the to-be-tested link comprises the to-be-tested interface;
when the output parameters meet preset conditions, recording the input parameters as a parameter input file;
and obtaining a parameter set corresponding to the link to be tested according to parameter files of all interfaces to be tested of the link to be tested.
Optionally, before the obtaining the input parameters and the output parameters of the interface to be tested on the link to be tested, the method further includes:
acquiring a link set to be tested;
reading annotation information added to the link set to be tested;
and determining the link to be tested from the link set to be tested based on the annotation information.
Optionally, the method further includes:
formatting the original input parameters corresponding to the interface to be tested based on a section-oriented programming method to obtain the input parameters;
the acquiring of the input parameters and the output parameters of the interface to be tested on the link to be tested includes:
storing the input parameters in a designated file;
and reading the specified file to obtain the output parameters.
Optionally, the outputting the parameter according to the preset condition includes:
the storage time of the input parameters is in a preset time period;
or, the output parameter is matched with a preset rule;
the recording of the input parameters into the parameter entry file comprises:
and formatting the specified file to obtain the reference file.
Optionally, the entry file of the interface to be tested further includes an entry file of a previous stage interface to be tested.
Optionally, the obtaining, according to the entry documents of all interfaces to be tested of the link to be tested, the entry set corresponding to the link to be tested includes:
acquiring a reference file of the last interface to be tested in the link to be tested;
and obtaining a parameter set corresponding to the link to be tested according to the parameter file of the last interface to be tested.
In a second aspect, an embodiment of the present application provides a testing apparatus, including:
the system comprises an acquisition module, a test module and a test module, wherein the acquisition module is used for acquiring input parameters and output parameters of a to-be-tested interface on a to-be-tested link, and the to-be-tested link comprises the to-be-tested interface;
the recording module is used for recording the input parameters into the parameter input file when the output parameters meet preset conditions;
and the processing module is used for obtaining a parameter set corresponding to the link to be tested according to the parameter files of all interfaces to be tested of the link to be tested.
In a third aspect, an embodiment of the present application provides a test system, including:
the service unit is used for storing a link set to be tested;
the test unit is used for obtaining input parameters and output parameters of interfaces to be tested on a link to be tested, the link to be tested comprises the interfaces to be tested, when the output parameters meet preset conditions, the input parameters are recorded into a parameter entry file, and a parameter entry set corresponding to the link to be tested is obtained according to the parameter entry files of all the interfaces to be tested of the link to be tested.
In a fourth aspect, the present application provides an electronic device, comprising: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the above method steps when executing the computer program.
In a fifth aspect, the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the above-mentioned method steps.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: and recording the output parameters of each interface to be tested in the test link to obtain a parameter set of the link to be tested. In this way, manual income parameters of testers are not needed, the workload of the testers is reduced, and the testing time is shortened compared with manual parameter input.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The application relates to a test method, a test device, a test system, a storage medium and electronic equipment. The method provided by the embodiment of the invention can be applied to any required electronic equipment, for example, the electronic equipment can be electronic equipment such as a server and a terminal, and the method is not particularly limited herein, and is hereinafter simply referred to as electronic equipment for convenience in description. First, a test method provided by the embodiment of the present invention is described below.
Fig. 1 is a flowchart of a testing method according to an embodiment of the present disclosure. As shown in fig. 1, the method comprises the steps of:
and step S11, acquiring input parameters and output parameters of the interface to be tested on the link to be tested, wherein the link to be tested comprises the interface to be tested.
And step S12, recording the input parameters as the input parameters when the output parameters meet the preset conditions.
And step S13, obtaining a parameter set corresponding to the link to be tested according to parameter files of all interfaces to be tested of the link to be tested.
In this embodiment, the input parameter set of the link to be tested is obtained by recording the output parameter of each interface to be tested in the test link. In this way, the manual parameter input by the tester is not needed, the workload of the tester is reduced, and the test time is shortened compared with the manual parameter input.
In this embodiment, the link to be tested may be obtained by obtaining a service to be tested and a service identifier carried by the service to be tested, and matching a link to be tested corresponding to the service to be tested from a link set to be tested according to the service identifier to be tested, where the link to be tested includes at least two interfaces to be tested.
Optionally, the obtaining of the link to be tested may also be obtained by: and reading annotation information added to the link set to be tested, wherein the annotation information is manually added by a tester, and determining the link to be tested from the link set to be tested based on the annotation information. And formatting the original input parameters corresponding to the interface to be tested based on a section-oriented programming method to obtain the input parameters. The section-oriented programming method is mainly characterized in that section codes are implanted into a link to be tested, original input parameters are intercepted and formatted to obtain the input parameters when joint debugging is carried out on testers through the section codes.
Optionally, obtaining the input parameter and the output parameter of the interface to be tested on the link to be tested includes: and storing the input parameters in an appointed file, and reading the appointed file to obtain the output parameters. The specified file stores defined operation codes which are used for calculating input parameters so as to obtain output parameters. When the output parameter meets the preset condition, the input parameter is recorded as a parameter entry file, and the output parameter meets the preset condition, wherein the storage time of the input parameter is in a preset time period, the mark in the preset time period is +1, and the mark outside the preset time period is-1.
For example: and presetting 24h to update the input parameters once, wherein the storage time of the input parameters is the storage time of the last test, and when the storage time of the last test is more than 24h, determining that the storage time is out of the preset time period, and marking the storage time as-1.
And then recording the input parameters corresponding to the output parameters marked as +1 as the input parameter files. Since the input parameters are stored in the designated file, recording the input parameters as the input parameters file is realized by the following modes: and formatting the specified file to obtain the reference file.
Optionally, the output parameter may meet a preset condition, where the output parameter is matched with a preset rule, and the preset rule may be understood as a predefined matching rule, for example: if the output parameters comprise 'SUCCESS', the output parameters are considered to accord with preset rules; alternatively, the output parameter includes a value of a preset field in the input parameter, for example: the preset field may be "orderId" and the time difference between the output parameter and the input parameter is > 500ms, the output parameter is considered not to conform to the predefined parameter-out rule.
When the output parameter is matched with the predefined parameter-out rule, the output parameter is marked as +1, and when the output parameter is not matched with the predefined parameter-out rule, the output parameter is marked as-1. And recording the input parameters corresponding to the output parameters marked as +1 as the input parameter files. Since the input parameters are stored in the designated file, recording the input parameters as the input parameters file is realized by the following modes: and formatting the specified file to obtain the reference file, wherein the specified file is formatted to obtain the reference file with a preset format, so that uniform calling during subsequent regression testing is facilitated.
The entry files of the interfaces to be tested also comprise the entry files of the previous level interfaces to be tested. Optionally, obtaining a parameter entry set corresponding to the link to be tested according to parameter entry files of all interfaces to be tested of the link to be tested, where the parameter entry set includes: and acquiring a parameter input file of the last interface to be tested in the link to be tested, and acquiring a parameter input set corresponding to the link to be tested according to the parameter input file of the last interface to be tested.
For example: for the business of ordering in the shopping mall, the corresponding link to be tested comprises: a shopping cart interface, a payment interface, an order issuing interface, etc. The manner of obtaining the entry set of the link to be tested is as follows: the method comprises the steps of obtaining input parameters of a shopping cart interface, storing the input parameters of the shopping cart interface in a first designated file, reading the designated file to obtain output parameters of the shopping cart interface, judging whether the output parameters of the shopping cart interface meet preset conditions or not, and formatting the designated file to obtain a first input parameter file of the shopping cart interface when the output parameters of the shopping cart interface meet the preset conditions.
And then acquiring input parameters of the payment interface, storing the input parameters of the payment interface in a second designated file, reading the second designated file to obtain output parameters of the payment interface, judging whether the output parameters of the payment interface meet preset conditions, and taking the formatted second designated file and the first input parameter file as a second input parameter file when the output parameters of the payment interface meet the preset conditions.
And repeating the steps until the input parameter of the last test interface in the link to be tested is obtained, storing the input parameter of the last test interface in a third designated file, reading the third designated file to obtain the output parameter of the last test interface, and taking the formatted third designated file and a second parameter input file (the second designated file comprises the first designated file) as the third designated file when the input parameter of the last test interface meets the preset condition, wherein the third designated file comprises the input parameter set in the whole link to be tested.
By the mode, the tester does not need to input parameters manually in the testing process, only needs to record the input parameters to obtain the reference file of the link to be tested, and performs regression testing according to the reference file, so that the workload of the tester is reduced.
Fig. 2 is a block diagram of a testing apparatus provided in an embodiment of the present application, which may be implemented as part or all of an electronic device through software, hardware, or a combination of the two. As shown in fig. 3, the test apparatus includes:
the acquisition module 21 is configured to acquire an input parameter and an output parameter of a to-be-tested interface on a to-be-tested link, where the to-be-tested link includes the to-be-tested interface;
the recording module 22 is used for recording the input parameters into the parameter input file when the output parameters meet the preset conditions;
and the processing module 23 is configured to obtain a parameter entry set corresponding to the link to be tested according to parameter entry files of all interfaces to be tested of the link to be tested.
Fig. 3 is a schematic diagram of a test system according to an embodiment of the present application, and as shown in fig. 3, the test system according to the embodiment of the present application includes:
the service unit 31 is configured to store a link set to be tested;
the testing unit 32 is configured to obtain input parameters and output parameters of the interfaces to be tested on the link to be tested, where the link to be tested includes the interfaces to be tested, record the input parameters as the entry files when the output parameters meet preset conditions, and obtain entry sets corresponding to the link to be tested according to the entry files of all the interfaces to be tested of the link to be tested.
An embodiment of the present application further provides an electronic device, as shown in fig. 4, the electronic device may include: the system comprises a processor 1501, a communication interface 1502, a memory 1503 and a communication bus 1504, wherein the processor 1501, the communication interface 1502 and the memory 1503 complete communication with each other through the communication bus 1504.
A memory 1503 for storing a computer program;
the processor 1501 is configured to implement the steps of the above embodiments when executing the computer program stored in the memory 1503.
The communication bus mentioned in the electronic device may be a Peripheral component interconnect (pci) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the above-described embodiments.
It should be noted that, for the above-mentioned apparatus, electronic device and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiments.
It is further noted that, herein, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.