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

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

Info

Publication number
CN108415832B
CN108415832B CN201810121971.XA CN201810121971A CN108415832B CN 108415832 B CN108415832 B CN 108415832B CN 201810121971 A CN201810121971 A CN 201810121971A CN 108415832 B CN108415832 B CN 108415832B
Authority
CN
China
Prior art keywords
test
test case
json
interface
jmeter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810121971.XA
Other languages
Chinese (zh)
Other versions
CN108415832A (en
Inventor
贾江丽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201810121971.XA priority Critical patent/CN108415832B/en
Publication of CN108415832A publication Critical patent/CN108415832A/en
Application granted granted Critical
Publication of CN108415832B publication Critical patent/CN108415832B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; 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; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Abstract

The invention relates to the field of software testing, and provides an automatic interface testing method, device, equipment and storage medium, wherein the method comprises the following steps: acquiring interface documents of different interfaces, and automatically generating Json test samples of the different interfaces according to the interface documents; automatically generating a test case template according to the Json test case, automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case; and generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, triggering the Jmeter test script to test through the integrated test case, and automatically outputting a test result. The interface automatic test method, the device, the equipment and the storage medium provided by the invention can improve the automation degree of interface test and facilitate the maintenance of test cases when the interface is modified.

Description

Interface automation test method, device, equipment and storage medium
Technical Field
The invention belongs to the field of software testing, and particularly relates to an automatic interface testing method, device, equipment and storage medium.
Background
The interface test is a test for testing interfaces among system components, and is mainly used for detecting interaction points between an external system and a system and between each internal subsystem, mainly checking the exchange, transmission and control management processes of data, mutual logic dependency relationship among systems and the like.
In the prior art, when a certain interface or a certain interface in an interface test needs to be added, deleted or modified, the interface needs to be maintained by codes, the interface is run in postman (a tool for automatically testing the interface), or one interface is led into the existing interface test tool to execute result watching, so that the time is long, the automation degree is low, and the efficiency is low.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides an interface automatic test method, device, equipment and storage medium, which can improve the automation degree and the test efficiency.
The invention is realized by the following steps:
the first aspect of the present invention provides an automated interface testing method, including the following steps:
acquiring interface documents of different interfaces, and automatically generating Json test samples of the different interfaces according to the interface documents;
automatically generating a test case template according to the Json test case, automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case;
and generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, triggering the Jmeter test script to test through the integrated test case, and automatically outputting a test result.
The second aspect of the present invention provides an interface automation test apparatus, including:
the sample generation module: the Json test sample generation system is used for acquiring interface documents of different interfaces and automatically generating Json test samples of different interfaces according to the interface documents;
the script generation module: the Json test case template is used for automatically generating a test case template according to the Json test case, automatically generating a Json test case according to the test case template, and then automatically generating a Jmeter test script according to the Json test case;
the interface testing module: the Jmeter test script is used for generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, triggering the Jmeter test script to test through the integrated test case, and automatically outputting a test result.
A third aspect of the present invention provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to the first aspect of the embodiment of the present invention when executing the computer program.
A fourth aspect of the present invention is a computer-readable storage medium storing a computer program, wherein the computer program is configured to, when executed by a processor, implement the steps of the method according to the first aspect of the embodiments of the present invention.
Compared with the prior art, the interface automatic test method, the device, the equipment and the storage medium provided by the invention have the advantages that the test sample, the test sample set, the test sample template, the Json test case, the Jmeter test script and the integrated test case are automatically and sequentially generated through the interface document, the Jmeter test script is called through the test tool for testing, the test result is automatically output, the degree of automation is high, the test efficiency is improved, when the interface is modified, the new test script can be quickly generated for testing, and the interface test process is easy to maintain.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart of an interface automation test method according to an embodiment of the present invention;
FIG. 2 is an exemplary diagram of a request message and a response message of the embodiment shown in FIG. 1;
FIG. 3 is an exemplary diagram of a sample set of tests for the embodiment shown in FIG. 1;
FIG. 4 is an exemplary diagram of a test case template of the embodiment shown in FIG. 1;
FIG. 5 is a flowchart of the substeps of step S103 of the embodiment shown in FIG. 1;
FIG. 6 is a schematic structural diagram of an interface automatic test apparatus according to another embodiment of the present invention;
fig. 7 is a schematic structural diagram of a terminal device according to another embodiment of the present invention.
Detailed Description
In order to make the technical problems, technical solutions and advantageous effects to be solved by the present invention more clearly apparent, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, a flowchart of an interface automation test method according to an embodiment of the present invention is shown.
Interface testing refers to testing an Application Program Interface (API), and includes two types: one is an external interface, i.e. a system-to-system call, such as an interface call between a Taobao ordering system and a payment system; one type is an internal interface, which refers to the call of the upper layer service to the lower layer service or the call between services, for example, the service layer calls the data layer, the service layer is the upper layer service, the data layer is the lower layer service, and for example, the selection of goods and the creation of orders, etc.
The interface test is used for mainly checking whether data exchange, transmission, management processes and the like between the interfaces work normally or not.
As shown in fig. 1, the interface automation test method provided by the embodiment of the present invention includes the following steps:
step S101, obtaining interface documents of different interfaces, and automatically generating Json test samples of different interfaces according to the interface documents.
The interface document refers to interface parameters which are provided by developers of application programs and are related to different interface tests, and the interface document mainly comprises data of a request method, a URI (Uniform resource identifier), a request parameter and a return parameter. The method of requesting generally includes: GET/PUT/POST/DELETE; the URI is a Uniform Resource Identifier (URI), which is a character string for identifying a name of an internet Resource, and is started with a start number, if an interface (such as new addition and modification; user personal information, fund information, and the like) which can be called by logging in is required to be added with u, that is: a/u; the middle part is generally used for placing a table name or a word capable of expressing the interface; request parameters and return parameters typically include: field, description, type, remark, whether padding is necessary, etc.
Specifically, by clicking a Json test sample automatic generation tool, the data of the interface document can be called according to the outer field name in the interface description table of the interface document, and the Json format test sample can be automatically generated. The interface description table refers to a table for generally describing the interface, and includes information such as name, field name, type and format of calling interface document information; the outer field name refers to the field name of the interface at the outermost layer in the interface document, and by taking the authentication service as an example, the information of the person to be authenticated is used as the outer field name, and the information data at the inner layers, such as the name, the sex, the identity number and the like of the person to be authenticated can be called from the interface document according to the information of the person to be authenticated.
For example, taking the verification service system as an example, the names of the outer field names of the interface description documents mainly include: the system code, the service staff code, the effective date, the hierarchy information, the information of the person to be checked, the total number of the person to be checked and the like, and various information data in the inner layer of the interface document can be called through the field names of the outer layer by using a Json test sample generation tool.
In the embodiment of the invention, the Json format is generated for the test sample, mainly because the data between the interfaces is transmitted in the Json format; optionally, the Json test sample automatic generation tool is generated by a VBA script.
Specifically, the test sample in the Json format mainly includes a request message and a response message, please refer to fig. 2, which shows an exemplary diagram of the request message and the response message, as shown in fig. 2(a), the request method in the request message is a method for sending a request to the interface, the name of the request field is an outer field name, and the specific request to the interface is performed by calling data of the interface document according to the outer field name, where "non-empty", "length", and "type" are used to limit the format of the request message; as shown in fig. 2(b), the returned result in the response message is a result returned to the interface, the field name, that is, the outer field name, is returned, and the specific result is returned according to the data of the outer field name call interface document, where "non-empty", "length", and "type" are used to limit the format of the response message. When the actual interface carries out data communication, the interface receives a request message, resources to be requested are searched in a system or a platform according to the request message, and the resources are converted into response messages to be returned after being found.
And S102, automatically generating a test case template according to the Json test sample, automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case.
The interface test comprises testing of a plurality of different interfaces, for example, in the interface test of insurance purchase, the interfaces such as customer identity verification, insurance information verification, mobile phone number change and insurance application need to be tested, so that Json test samples of all the interfaces can be collected to generate a Json test sample set, centralized management and subsequent integrated test of the interface test are facilitated, and the interface test flow is more visual. Referring to fig. 3, which shows an example diagram of a test sample set, as shown in fig. 3, an interface test includes tests of N interfaces, an interface name refers to one flow of a system to be tested, an interface description refers to a flow direction corresponding to the interface name in the system, and data behind the interface description is a request message and a response message corresponding to a Json sample generated for each interface document.
Specifically, Json test samples are automatically generated according to each interface document, and all Json test sample sets are arranged in a table to form a Json test sample set.
Then, clicking a test case template generation tool, the test case templates of all interfaces can be automatically generated at the same time according to the test case template, the test case template mainly comprises a request message and result verification corresponding to the request message, please refer to fig. 4, which shows an example diagram of the test case template, fig. 4 is a Json test case with a request field name of "client authentication", wherein the calling field name is a field name called by a request method parameter with the request field name of "client authentication", and comprises a "client name", "gender", "birth date", "certificate type" and "certificate number", and then result verification is respectively set according to data of each calling field name. The result verification is to test the interface in safety, so that the interface can normally operate in all scenes, and the result verification can be specifically set according to a preset interface test strategy and actual conditions.
After the numerical value of result verification is input, a Json test case generation tool is clicked, a test case in a Json format can be generated according to a test case module of one interface, and then a Jmeter test case generation tool is clicked, a test script in a Jmeter format can be generated according to the test case in the Json format, namely a suffix file in jmx; at the same time of generating the test script, a Jmeter test script named by the interface name is generated in a preset storage path, for example, a Jmeter test script of "customer id verification jmx" is generated in a predetermined storage path (e.g., D-hard disk) according to "customer id verification" this interface. The Jmeter is a Java-based pressure testing tool developed by Apache organization, and can be applied to interface testing.
Optionally, the Json test case generation tool and the meter test case generation tool are also generated by the VBA script.
And S103, generating an integrated test case according to the Jmeter test script, calling the integrated test case through the test tool, triggering the Jmeter test script to test through the integrated test case, and automatically outputting a test result.
The integrated test case is characterized in that all modules are assembled into a subsystem or a system according to design requirements (such as a structure diagram) on the basis of unit test to carry out integrated test; the integration test has the function of verifying whether the connected units and modules can normally operate when being connected to perform global operation on the premise that all the units and modules can normally operate.
Specifically, the test case is written into the integrated test case of the integrated test tool, so that the integrated test can be performed.
Optionally, the integration test tool adopts an Ant integration test tool, and Ant is a tool for automating steps of software compiling, testing, deploying and the like, and is mostly used for software development in a Java environment.
Specifically, referring to fig. 5, in step S103, the following sub-steps are further included:
and step S1031, generating an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script.
Step S1032, the Ant integrated test tool is operated to call the integrated test case, so that the integrated test case triggers the Jmeter test script to test through the storage path of the Jmeter test script.
Step S1033, the response message after the test is automatically compared with the response message, and the test result is output according to the result output path.
Specifically, an integrated test case with the name build.xml is newly created, a test case is generated according to the format of an Ant integration tool, and a storage path of a Jmeter test script and a test result path to be output are input into the build.xml integrated test case.
And (4) operating an integration test tool of Ant, calling an integration test case of BUILD.xml, triggering the Jmeter test case by the integration test case through a storage path of the Jmeter test script to carry out integration test, and outputting a test result according to an input test result path after the test is finished.
The test result is to automatically compare the response message obtained after the operation test with the response message in the Json sample, if the test result is consistent with the expected result, the interface meets the use requirement and can be normally used, and if the test result is inconsistent with the expected result, the interface is indicated to have a problem and needs to be further improved.
Furthermore, because the test case is a script in a Jmeter format, as an implementation manner, a Jmeter test tool can be used to directly call the Jmeter test case to perform interface test, it should be understood that the Jmeter can only perform interface test on one interface, i.e. it cannot perform integrated test, but the performance of the interface test can be better tested by simulating pressure test in a concurrent thread manner by using the Jmeter, and therefore, the interface test can be performed after performing the interface test on a single interface by using the Jmeter, so that the interface test is more complete. Wherein, the test in the aspect of performance mainly comprises: response speed, interface fault tolerance, interface load, and the like.
Further, when the interface is added, deleted or modified, the test code needs to be maintained. In the embodiment of the present invention, the specific maintenance process is as follows: acquiring a modified interface document from a developer, sequentially generating a Json test sample, a Json test case and a Jmeter test case according to the modified interface document, writing the Json test case into an integrated test case, operating a test tool to call the test case for testing, and outputting a test result. In the maintenance process, the interface automatic testing method provided by the embodiment of the invention can ensure that the whole maintenance process is simpler and has higher efficiency.
For example, when an interface is newly added, a newly added interface document is obtained, a Json sample generation tool is clicked to automatically generate a Json sample according to the newly added interface document, then a test case template generation tool is clicked to automatically generate a test case module according to the Json sample, optionally, the Json sample can be placed in a Json sample set, centralized management is facilitated, when the test case template generation tool is clicked, a test case template can be generated only for the Json sample generated by the newly added interface, and other interfaces are unchanged, so that only result verification data of the newly added interface needs to be input into the test case template, and result verification data of other interfaces does not need to be input again; and then clicking a Json test case generation tool to automatically generate a Json test case according to a test case template of the newly added interface, then clicking a Jmeter test case generation tool to automatically generate a Jmeter test case, next, adding a storage path of the newly generated Jmeter test case into the integrated test case of BUILD.xml, operating an Ant integrated test tool, calling the Jmeter test case through the integrated test case to test, and outputting a new test result.
According to the interface automatic test method provided by the embodiment of the invention, the automatic generation tool is used for automatically generating the test cases from the interface document step by step, then the integrated test tool is used for calling the test cases to perform interface test, the test result is automatically output, the performance and the safety of the test result are verified, and the correction and the perfection of the interface are guided; when a modified interface exists, only the part of the modified interface automatically generates the test case again, and the test cases of other interfaces do not need to be regenerated, so that the maintenance process is simple and convenient, and the efficiency is high; in the whole testing process, corresponding transition data are automatically generated by a corresponding automatic generation tool, the requirement on interface testing personnel is reduced, the automation degree is improved, and meanwhile, the interface testing efficiency is improved.
The following are embodiments of the apparatus of the invention, details of which are not described in detail in the embodiments of the apparatus, reference being made to the corresponding method embodiments described above.
Referring to fig. 6, a schematic structural diagram of an interface automation test apparatus according to an embodiment of the invention is shown.
As shown in fig. 6, the interface automation test apparatus 20 includes: a sample generation module 201, a script generation module 202 and an interface test module 203.
The sample generating module 201 is configured to obtain interface documents of different interfaces, and automatically generate Json test samples of different interfaces according to the interface documents.
Specifically, the sample generation module 201 may call data of an interface document according to an outer field name in an interface description table of the interface document by operating a Json test sample automatic generation tool, and automatically generate a test sample in a Json format, where the test sample in the Json format mainly includes a request message and a response message.
Optionally, the Json test sample automatic generation tool is generated by a VBA script.
The script generating module 202 is configured to automatically generate a test case template according to the Json test case, automatically generate a Json test case according to the test case module, and then automatically generate a meter test script according to the Json test case.
Specifically, a sample generation module 201 is used to automatically generate a Json test sample according to each interface document, and then a script generation module 202 combines all Json test sample sets in a table to form a Json test sample set.
Then, the script generating module 202 may automatically generate the test case templates of all the interfaces at the same time according to the test case set by running the test case template generating tool, where the test case templates mainly include request messages and result verifications corresponding to the request messages.
Next, the script generating module 202 obtains a specific value of result verification, and by operating the Json test case generating tool, a test case in the Json format can be generated according to the test case module of one interface, and by operating the Jmeter test case generating tool, a test script in the Json format can be generated according to the test case in the Json format.
Optionally, the Json test case generation tool and the meter test case generation tool are also generated by the VBA script.
The interface test module 203 is configured to generate an integrated test case according to the Jmeter test script, call the integrated test case through the test tool, trigger the Jmeter test script through the integrated test case to perform a test, and output a test result automatically.
Specifically, the interface test module 203 writes a Jmeter test script into an integrated test case of the integrated test tool.
Optionally, the integration test tool adopts an Ant integration test tool, the interface test module 203 creates an integration test case with a name build.
The interface test module 203 calls the integrated test case of build.xml by running an integrated test tool of Ant, so that the integrated test case triggers the meter test case to perform integrated test through a storage path of the meter test script, and outputs a test result according to an input test result path after the test is completed.
Further, since the test case is a script in the format of a Jmeter, as an implementation manner, the interface test module 203 may directly invoke the Jmeter test case to perform the interface test by using a Jmeter test tool, it should be understood that the Jmeter can only perform the interface test on one interface, that is, the interface test cannot be performed, but the pressure test can be simulated by using the Jmeter in a concurrent thread manner, and the performance test of the interface test has a good effect, so the interface test module 203 may perform the interface test on a single interface by using the Jmeter and then perform the integration test, so that the interface test is more complete.
Further, when the interface is added, deleted or modified, the test code needs to be maintained. In the embodiment of the present invention, the specific maintenance process is as follows: the interface automation testing device 20 obtains the modified interface document through the sample generating module 201, generates the modified Json test sample, then the script generating module 202 sequentially generates a test case template, a Json test case and a Jmeter test case according to the Json test sample, finally writes the modified Jmeter test case into the integrated test case through the interface testing module 203, operates the testing tool to call the test case for testing, and outputs the testing result.
According to the interface automatic testing device provided by the embodiment of the invention, the automatic generation tool is used for automatically generating the test cases from the interface document step by step, then the integrated testing tool is used for calling the test cases to perform interface testing, the test result is automatically output, the performance and the safety of the test result are verified, and the correction and the perfection of the interface are guided; when a modified interface exists, only the part of the modified interface automatically generates the test case again, and the test cases of other interfaces do not need to be regenerated, so that the maintenance process is simple and convenient, and the efficiency is high; in the whole testing process, corresponding transition data are automatically generated by a corresponding automatic generation tool, the requirement on interface testing personnel is reduced, the automation degree is improved, and meanwhile, the interface testing efficiency is improved.
Another embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the method for automatically testing an interface in the foregoing embodiments is implemented, and in order to avoid repetition, details are not described here again. Or, when being executed by the processor, the computer program implements the functions of each module/unit in the interface automatic testing apparatus in the above embodiments, and is not described herein again to avoid repetition.
Referring to fig. 7, which shows a schematic diagram of the terminal device of the present embodiment, the terminal device 6 includes a processor 60, a memory 61, and a computer program 62 stored in the memory 61 and operable on the processor 60. The processor 60, when executing the computer program 62, implements the various steps of the interface automation test method in the above-described embodiment, such as steps S101, S102 and S103 shown in fig. 1. Alternatively, the processor 60 implements the functions of the modules/units of the interface automation test device in the above-described embodiment when executing the computer program 62, such as the functions of the sample generation module 201, the script generation module 202, and the interface test module 203 shown in fig. 6.
Illustratively, the computer program 62 may be divided into one or more modules/units, which are stored in the memory 61 and executed by the processor 60 to implement the present invention. One or more of the modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 62 in the terminal device 6. For example, the computer program 62 may be divided into a sample generation module 201, a script generation module 202 and an interface test module 203, and the specific functions of each module are as follows:
the sample generating module 201 is configured to obtain interface documents of different interfaces, and automatically generate Json test samples of different interfaces according to the interface documents.
The script generating module 202 is configured to automatically generate a test case template according to the Json test case, automatically generate a Json test case according to the test case module, and then automatically generate a meter test script according to the Json test case.
The interface test module 203 is configured to generate an integrated test case according to the Jmeter test script, call the integrated test case through the test tool, trigger the Jmeter test script through the integrated test case to perform a test, and output a test result automatically.
Further, the sample generating module 201 is further configured to obtain interface documents of different interfaces, and automatically generate test samples in the Json format of different interfaces according to the outer field names of the interface documents and calling data of the interface documents, where the test samples include a request message and a response message.
The script generation module 202 is further configured to automatically generate a test case template according to the Json test case, input a value of result verification into the test case template, automatically generate the Json test case according to the test case template, and finally automatically generate a meter test script according to the Json test case;
or, the script generating module 202 is further configured to generate a Json test sample set from the Json test sample sets of different interfaces, automatically generate respective test case templates of the interfaces included in the Json test sample set according to the Json test sample set, respectively input the result verification values into the respective test case templates, respectively and automatically generate the Json test cases according to the respective test case templates, and finally, respectively and automatically generate the Jmeter test script according to the respective Json test cases.
The interface test module 203 is further configured to generate an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script, run an Ant integrated test tool to call the integrated test case in the xml format, enable the integrated test case to trigger the Jmeter test script to perform a test through the storage path of the Jmeter test script, automatically compare the response message after the test with the response message, and output a test result according to the result output path.
The terminal device 6 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 60, a memory 61. Those skilled in the art will appreciate that fig. 7 is merely an example of a terminal device 6 and does not constitute a limitation of terminal device 6 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the terminal device may also include input output devices, network access devices, buses, etc.
The Processor 60 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 61 may be an internal storage unit of the terminal device 6, such as a hard disk or a memory of the terminal device 6. The memory 61 may also be an external storage device of the terminal device 6, such as a plug-in hard disk provided on the terminal device 6, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 61 may also include both an internal storage unit of the terminal device 6 and an external storage device. The memory 61 is used for storing computer programs and other programs and data required by the terminal device. The memory 61 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media which may not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (9)

1. An automatic interface testing method is characterized by comprising the following steps:
acquiring interface documents of different interfaces, and automatically generating Json test samples of the different interfaces according to the interface documents;
automatically generating a test case template according to the Json test case, automatically generating a Json test case according to the test case template, and automatically generating a Jmeter test script according to the Json test case;
generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, triggering the Jmeter test script to test through the integrated test case, and automatically outputting a test result;
the acquiring interface documents of different interfaces and automatically generating Json test samples of different interfaces according to the interface documents comprise:
acquiring interface documents of different interfaces, calling data of the interface documents according to outer field names of the interface documents to automatically generate test samples of different interfaces in Json format, wherein the test samples comprise request messages and response messages, the outer field names refer to the field names of the outermost interfaces in the interface documents, receiving the request messages through the interfaces, searching resources to be requested in a system or a platform according to the request messages, and converting the resources into the response messages to return after the resources are found;
automatically generating a test case template according to the Json test case, and automatically generating a Json test case according to the test case template, wherein the method comprises the following steps:
the method comprises the steps that Json test samples are respectively and automatically generated according to each interface document, all Json test samples are collected in a table to form a Json test sample set, test case templates of all interfaces are simultaneously and automatically generated according to the test sample set, and the test case templates mainly comprise request messages and result verification corresponding to the request messages;
the interface automatic testing method further comprises the following steps: when an interface is newly added, acquiring a newly added interface document, automatically generating a Json sample according to the newly added interface document when a Json sample generation tool is clicked, when the test case template generating tool is clicked, automatically generating a test case module according to the Json sample, putting the Json sample into the Json sample set, when the test case template generating tool is clicked, generating a test case template for the Json sample generated by the newly added interface, other interfaces are unchanged, when a Json test case generation tool is clicked, a Json test case is automatically generated according to a test case template of the newly added interface, when the Jmeter test case generation tool is clicked, a Jmeter test case is automatically generated, a storage path of the newly generated Jmeter test case is added into the integrated test case, the Ant integrated test tool is operated, and calling a Jmeter test case for testing through the integrated test case, and outputting a new test result.
2. The automated interface testing method of claim 1, wherein the automatically generating a test case template according to the Json test case, automatically generating a Json test case according to the test case template, and automatically generating a meter test script according to the Json test case comprises:
automatically generating a test case template according to the Json test case, inputting a numerical value of result verification into the test case template, automatically generating a Json test case according to the test case template, and finally automatically generating a Jmeter test script according to the Json test case;
or generating a Json test sample set from the Json test sample sets of different interfaces, automatically generating test case templates of the interfaces included in the Json test sample set according to the Json test sample set, respectively inputting result verification values into the test case templates, respectively and automatically generating Json test cases according to the test case templates, and finally respectively and automatically generating Jmeter test scripts according to the Json test cases.
3. The method for automatically testing the interface according to claim 2, wherein the generating of the integrated test case according to the Jmeter test script, the calling of the integrated test case by the test tool, the triggering of the Jmeter test script by the integrated test case for testing, and the automatic output of the test result comprise:
generating an integrated test case in an xml format according to the storage path and the result output path of the Jmeter test script;
running an Ant integration test tool to call the integration test case in the xml format, so that the integration test case triggers a Jmeter test script to test through a storage path of the Jmeter test script;
and automatically comparing the tested response message with the response message in the Json test sample, and outputting a test result according to the result output path.
4. The method for automatically testing the interface according to claim 3, wherein the generating of the integrated test case according to the Jmeter test script, the calling of the integrated test case by the test tool, the triggering of the Jmeter test script by the integrated test case for testing, and the automatic output of the test result further comprises:
when the interface is modified, obtaining a modified interface document, sequentially generating a Json test sample, a test case template, a Json test case, a Jmeter test case and an integrated test case according to the modified interface document, then operating the test tool to call the integrated test case for testing, and automatically outputting a test result again.
5. An interface automated testing apparatus, the apparatus comprising:
the sample generation module: the Json test sample generation system is used for acquiring interface documents of different interfaces and automatically generating Json test samples of different interfaces according to the interface documents;
the script generation module: the Json test case template is used for automatically generating a test case template according to the Json test case, automatically generating a Json test case according to the test case template, and then automatically generating a Jmeter test script according to the Json test case;
the interface testing module: the Jmeter test script is used for generating an integrated test case according to the Jmeter test script, calling the integrated test case through a test tool, triggering the Jmeter test script to test through the integrated test case, and automatically outputting a test result;
the sample generation module is further used for acquiring interface documents of different interfaces, calling data of the interface documents according to outer field names of the interface documents to automatically generate test samples of Json formats of the different interfaces, wherein the test samples comprise request messages and response messages, the outer field names refer to the field names of the outermost interfaces in the interface documents, the request messages are received through the interfaces, resources to be requested are searched in a system or a platform according to the request messages, and the resources are converted into the response messages to be returned after the resources are found;
the script generation module is further used for respectively and automatically generating Json test samples according to each interface document, then collecting all the Json test samples in a table to form a Json test sample set, and simultaneously and automatically generating test case templates of all the interfaces according to the test sample set, wherein the test case templates mainly comprise request messages and result verifications corresponding to the request messages;
the interface automation test device is also used for: when an interface is newly added, acquiring a newly added interface document, automatically generating a Json sample according to the newly added interface document when a Json sample generation tool is clicked, when the test case template generating tool is clicked, automatically generating a test case module according to the Json sample, putting the Json sample into the Json sample set, when the test case template generating tool is clicked, generating a test case template for the Json sample generated by the newly added interface, other interfaces are unchanged, when a Json test case generation tool is clicked, a Json test case is automatically generated according to a test case template of the newly added interface, when the Jmeter test case generation tool is clicked, a Jmeter test case is automatically generated, a storage path of the newly generated Jmeter test case is added into the integrated test case, the Ant integrated test tool is operated, and calling a Jmeter test case for testing through the integrated test case, and outputting a new test result.
6. The interface automated test apparatus of claim 5,
the script generation module is also used for automatically generating a test case template according to the Json test sample, inputting a numerical value of result verification into the test case template, automatically generating a Json test case according to the test case template, and finally automatically generating a Jmeter test script according to the Json test case; or the script generating module is further configured to generate a Json test sample set from the Json test sample sets of different interfaces, automatically generate test case templates of respective interfaces included in the Json test sample set according to the Json test sample set, input result verification values into the test case templates respectively, automatically generate Json test cases according to the test case templates respectively, and finally automatically generate a Jmeter test script according to the Json test cases respectively.
7. The device as claimed in claim 6, wherein the interface test module is further configured to generate an integrated test case in an xml format according to the storage path and the result output path of the meter test script, run an Ant integrated test tool to call the integrated test case in the xml format, enable the integrated test case to trigger the meter test script to perform testing through the storage path of the meter test script, automatically compare the tested response message with the response message in the Json test sample, and output the test result according to the result output path.
8. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 4 when executing the computer program.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 4.
CN201810121971.XA 2018-02-07 2018-02-07 Interface automation test method, device, equipment and storage medium Active CN108415832B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810121971.XA CN108415832B (en) 2018-02-07 2018-02-07 Interface automation test method, device, equipment and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810121971.XA CN108415832B (en) 2018-02-07 2018-02-07 Interface automation test method, device, equipment and storage medium
PCT/CN2018/081545 WO2019153472A1 (en) 2018-02-07 2018-04-02 Automated interface testing method, device, equipment, and storage medium

Publications (2)

Publication Number Publication Date
CN108415832A CN108415832A (en) 2018-08-17
CN108415832B true CN108415832B (en) 2021-03-02

Family

ID=63128025

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810121971.XA Active CN108415832B (en) 2018-02-07 2018-02-07 Interface automation test method, device, equipment and storage medium

Country Status (2)

Country Link
CN (1) CN108415832B (en)
WO (1) WO2019153472A1 (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109324974A (en) * 2018-10-09 2019-02-12 郑州云海信息技术有限公司 It is a kind of to control the method and device for executing in batches script
CN109522220A (en) * 2018-10-23 2019-03-26 中国银行股份有限公司 A kind of text test method and device
CN109684195A (en) * 2018-10-26 2019-04-26 平安科技(深圳)有限公司 Electronic device, script conversion method and storage medium
CN109685626A (en) * 2018-12-27 2019-04-26 北京顺丰同城科技有限公司 A kind of lower single test method and device
CN109710531A (en) * 2018-12-29 2019-05-03 北京奇安信科技有限公司 Auditing method, device, system, electronic equipment and the storage medium of application program
CN109902002B (en) * 2019-02-14 2020-06-02 浙江口碑网络技术有限公司 Generation method and device of combined test case, storage medium and computer equipment
CN109885498A (en) * 2019-02-26 2019-06-14 北京首汽智行科技有限公司 A kind of test script generation method and system
CN110134584A (en) * 2019-04-12 2019-08-16 深圳壹账通智能科技有限公司 A kind of generation method, device, storage medium and the server of interface testing use-case
CN110059011A (en) * 2019-04-22 2019-07-26 泰康保险集团股份有限公司 Interface test method, device, medium and electronic equipment
CN110532169A (en) * 2019-07-08 2019-12-03 平安科技(深圳)有限公司 Interface testing case generation method, device, computer equipment and storage medium
CN111427765A (en) * 2020-02-17 2020-07-17 叮当快药科技集团有限公司 Method and system for automatically starting interface performance test realized based on jmeter
CN111209218A (en) * 2020-04-01 2020-05-29 中电万维信息技术有限责任公司 Automatic performance testing method based on Jmeter

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101996132A (en) * 2009-08-14 2011-03-30 中兴通讯股份有限公司 Method and device for automatically testing common object request broker architecture (CORBA) interfaces
KR101132560B1 (en) * 2010-06-09 2012-04-03 강원대학교산학협력단 System and method for automatic interface testing based on simulation for robot software components
IN2015DE00812A (en) * 2015-03-24 2015-04-03 Hcl Technologies Ltd
CN106021111A (en) * 2016-05-30 2016-10-12 上海携程商务有限公司 Interface testing method and system
CN106294177B (en) * 2016-08-22 2018-06-22 腾讯科技(深圳)有限公司 The method for testing pressure and test equipment of a kind of interface
CN106708676B (en) * 2016-12-01 2020-12-04 广州酷狗计算机科技有限公司 Interface test method and device
CN107239398B (en) * 2017-05-24 2020-01-31 四川长虹电器股份有限公司 Postman-based automatic interface test case generation system and method
CN107402884A (en) * 2017-07-31 2017-11-28 深圳乐信软件技术有限公司 Generate the method and device of interface testing code
CN107608889B (en) * 2017-09-15 2021-07-06 销冠网络科技有限公司 Method and system for automatically generating test script

Also Published As

Publication number Publication date
CN108415832A (en) 2018-08-17
WO2019153472A1 (en) 2019-08-15

Similar Documents

Publication Publication Date Title
CN108415832B (en) Interface automation test method, device, equipment and storage medium
US10592319B2 (en) API notebook tool
US10705942B1 (en) Simulated testing of API
CN107370786B (en) General information management system based on micro-service architecture
CN108319547B (en) Test case generation method, device and system
US9569288B2 (en) Application pattern discovery
US8745641B1 (en) Automatic verification and anomaly detection in a representational state transfer (REST) application programming interface
US10467316B2 (en) Systems and methods for web analytics testing and web development
WO2019072110A1 (en) Method for generating application program, apparatus, system, device, and medium
WO2021184725A1 (en) User interface test method and apparatus, storage medium, and computer device
US10382313B2 (en) Test building for testing server operation
Bernal et al. Improving cloud architectures using UML profiles and M2T transformation techniques
CN110888794A (en) Interface test method and device
US20210117313A1 (en) Language agnostic automation scripting tool
CN110362294A (en) Development task executes method, apparatus, electronic equipment and storage medium
CN113034111A (en) Data export and import method and device
CN113886216A (en) Interface test and tool configuration method, device, electronic equipment and storage medium
CN114385722A (en) Interface attribute consistency checking method and device, electronic equipment and storage medium
CN112783753A (en) Test method and device for stream data processing system
CN113448822A (en) Test method, test device, computer readable medium and electronic equipment
CN113360365A (en) Flow testing method and flow testing system
CN114138321A (en) Applet auditing method and system
CN111666201A (en) Regression testing method, device, medium and electronic equipment
CN112579428A (en) Interface testing method and device, electronic equipment and storage medium
CN113900958A (en) Test case script generation method, system, medium and electronic device

Legal Events

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