CN109344063A - A kind of automated testing method of api interface - Google Patents
A kind of automated testing method of api interface Download PDFInfo
- Publication number
- CN109344063A CN109344063A CN201811125639.7A CN201811125639A CN109344063A CN 109344063 A CN109344063 A CN 109344063A CN 201811125639 A CN201811125639 A CN 201811125639A CN 109344063 A CN109344063 A CN 109344063A
- Authority
- CN
- China
- Prior art keywords
- api interface
- interface
- api
- unit testing
- code
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test 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 present invention relates to a kind of automated testing methods of api interface, the automated testing method process of the api interface is to prepare api interface to describe file, api interface unit testing Code Template is generated, api interface unit testing code generator is write, writes unit testing scheduler program.The cost of api interface unit test is reduced, the test of api interface automation cell is easy to implement without being api interface maintenance interface unit testing code using the method for the present invention.
Description
Technical field
The present invention relates to a kind of word automated testing methods, more specifically to a kind of automatic test of api interface
Method.
Background technique
When carrying out software development, carrying out unit testing to software is an important job, and unit testing can be with
Help ensure that the quality of software.Traditional software development, often using class or function as boundary demarcation unit, unit testing is
It is to test class or function.In current software design procedure, often by the way of module loose coupling, module it
Between interacted by api interface, using single api interface as a unit carry out test be reasonable.Software development frame
Frame can provide a kind of document for being known as api interface and describing the json format of file, generally provide on-line manner.It can basis
Api interface describes the page of file development unit testing or api interface unit testing program to carry out unit survey to api interface
Examination.The technical solution of existing api interface unit testing connects first is that developing the api interface unit testing page and carrying out API to interface
Mouth unit testing, describing file according to api interface, api interface develops test page, or one general test of exploitation one by one
The page is used for the test of all api interfaces.Making in this way, api interface unit testing needs to rely on artificial progress, and
When api interface changes, it may be necessary to artificial to safeguard api interface test page.It is general all comprising big in software
The interface of amount, the method for relying on manual testing and manual maintenance can bring huge workload.Meanwhile this mode can not be automatic
Test report is provided, therefore test report is also required to manually to safeguard.Existing api interface unit testing technical solution second is that people
Work writes api interface unit testing code, these codes realize the calling and result inspection to api interface, realizes to api interface
Carry out the purpose of unit testing.There are multiple unit testing frames that can assist writing for api interface unit testing code.This side
Formula may be implemented once to write, and be run multiple times, while can help to the generation api interface Unit Test Report of automation.It is this
Mode api interface unit testing code and api interface are that correspondingly, new api interface needs to write the survey of api interface unit again
Frame is tried, existing api interface is in case of change, it is also desirable to which synchronous vacations api interface unit testing code, this brings certain
Maintenance workload safeguards that the workload of api interface unit testing code is also more if api interface quantity is more.
Summary of the invention
The technical problem to be solved in the present invention is that for the defects in the prior art, a kind of the automatic of api interface is provided
Change test method, solves api interface unit testing code and need api interface unit testing cost caused by manual maintenance excessively high
Problem.
The technical solution adopted by the present invention to solve the technical problems is: constructing a kind of automatic test side of api interface
Method is carried out the description of api interface using api interface description standard first, then generates api interface unit testing based on mould plate technique
The method of code.
In the automated testing method of api interface of the present invention, the automated testing method process of the api interface are as follows:
S1 prepares api interface and describes file, and S11 formulates a set of api interface description standard, and S12 is generated independently of api interface
Program realizes api interface description, and the api interface is described as JSON format;
S2 generates api interface unit testing Code Template, and the Code Template includes replaceable content and immobilized substance.
The replaceable content representation is list and interpolation, and the list and the subsequent information according to api interface description of interpolation are replaced
At actual content;
S3 writes api interface unit testing code generator, and described program reads interface description file, and using wherein
The information for including replaces the replaceable content of the Code Template, generates api interface unit testing code;Described program is to each
Api interface generates a unit testing code;The api interface unit testing code generator need to only write once, and only
Api interface is needed to describe to rerun when file changes once;
S4 writes unit testing scheduler program, and the scheduler program is according to specified rule, the automatic or manual operation of timing,
Each run can execute any number of interface unit test code and generate test report.
In the automated testing method of api interface of the present invention, the Standard Interface of the api interface description standard
Description element include interface message, interface parameters, interface return value, interface assert, Ploymerized Interface mode.
The automated testing method for implementing a kind of api interface of the invention, has the advantages that API of the invention
Interface unit test code generator need to only write once, and only need to describe to rerun when file changes in api interface
The unit testing code of primary i.e. renewable total interface is reduced without being api interface maintenance interface unit testing code
The implementation cost of api interface unit test is easy to implement the test of api interface automation cell.It can be significant using the method for the present invention
Reduction unit testing code maintenance workload, shorten software development cycle, and then reduce the cost of entire software development process.
Detailed description of the invention
Present invention will be further explained below with reference to the attached drawings and examples, in attached drawing:
Fig. 1 is the automated testing method flow chart of api interface of the invention
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
As shown in Figure 1, the automated testing method process of the api interface are as follows:
S1 prepares api interface and describes file, and S11 formulates a set of api interface description standard, and S12 is generated independently of api interface
Program realizes api interface description, and the api interface is described as JSON format;
S2 generates api interface unit testing Code Template, and the Code Template includes replaceable content and immobilized substance.
The replaceable content representation is list and interpolation, and the list and the subsequent information according to api interface description of interpolation are replaced
At actual content;
S3 writes api interface unit testing code generator, and described program reads interface description file, and using wherein
The information for including replaces the replaceable content of the Code Template, generates api interface unit testing code;Described program is to each
Api interface generates a unit testing code;The api interface unit testing code generator need to only write once, and only
Api interface is needed to describe to rerun when file changes once;
S4 writes unit testing scheduler program, and the scheduler program is according to specified rule, the automatic or manual operation of timing,
Each run can execute any number of interface unit test code and generate test report.
Further, the Standard Interface of the api interface description standard describe element include interface message, interface parameters,
Interface return value, interface asserts, Ploymerized Interface mode.
For the embodiment of the present invention is with " api interface of a transmission short message, parameter are cell-phone number and short message content ".
When developing this api interface, developer writes the description of api interface according to api interface description standard.Below
Quote major part:
It is ready for the template of the unit testing code of api interface, api interface is write first and writes out unit testing generation
Code, is then rewritten part related with api interface in code using replaceable content, and such as following codes are splicing api interfaces
Required parameter code:
parameters.put("mobileNo","13333333333");
parameters.put("content","hello");
It is rewritten into using replaceable content as follows:
<#list parameters as param>
parameters.put("${param.name}","${param.default}");
</#list>
Now, the description of api interface is read using api interface unit test code generator, it is raw using above-mentioned template
At unit testing code.These unit testing codes finally are executed using unit testing scheduler program and check test as needed
Report, can be completed the unit testing of api interface.
Although being disclosed by above embodiments to the present invention, scope of protection of the present invention is not limited thereto,
Under conditions of without departing from present inventive concept, deformation, the replacement etc. done to above each component will fall into right of the invention
In claimed range.
Claims (2)
1. a kind of automated testing method of api interface, which is characterized in that the automated testing method process of the api interface
Are as follows:
S1 prepares api interface and describes file, and S11 formulates a set of api interface description standard, and S12 is generated independently of api interface program
Realize api interface description, the api interface is described as JSON format;
S2 generates api interface unit testing Code Template, and the Code Template includes replaceable content and immobilized substance.It is described
Replaceable content representation is list and interpolation, and the list and the subsequent information according to api interface description of interpolation are replaced by reality
Border content;
S3 writes api interface unit testing code generator, and described program reads interface description file, and uses and wherein include
Information replace the replaceable content of the Code Template, generate api interface unit testing code;Described program is to each API
Interface generates a unit testing code;The api interface unit testing code generator need to only write once, and only need
Api interface describes to rerun when file changes primary;
S4 writes unit testing scheduler program, and the scheduler program is according to specified rule, the automatic or manual operation of timing, every time
Operation can execute any number of interface unit test code and generate test report.
2. the automated testing method of api interface according to claim 1, which is characterized in that the api interface description mark
Quasi- Standard Interface describe element include interface message, interface parameters, interface return value, interface assert, Ploymerized Interface mode.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811125639.7A CN109344063A (en) | 2018-09-26 | 2018-09-26 | A kind of automated testing method of api interface |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811125639.7A CN109344063A (en) | 2018-09-26 | 2018-09-26 | A kind of automated testing method of api interface |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109344063A true CN109344063A (en) | 2019-02-15 |
Family
ID=65306725
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811125639.7A Pending CN109344063A (en) | 2018-09-26 | 2018-09-26 | A kind of automated testing method of api interface |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109344063A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109977020A (en) * | 2019-04-01 | 2019-07-05 | 山东威尔数据股份有限公司 | A kind of automated testing method |
CN111240967A (en) * | 2020-01-03 | 2020-06-05 | 北京字节跳动网络技术有限公司 | Code generation method and device |
CN111930635A (en) * | 2020-09-17 | 2020-11-13 | 深圳微品致远信息科技有限公司 | Swagger-based rapid automatic testing method and system |
CN112612452A (en) * | 2020-12-18 | 2021-04-06 | 华人运通(上海)云计算科技有限公司 | API platform implementation method, device, equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080256517A1 (en) * | 2006-10-18 | 2008-10-16 | International Business Machines Corporation | Method and System for Automatically Generating Unit Test Cases Which Can Reproduce Runtime Problems |
CN106339312A (en) * | 2015-07-17 | 2017-01-18 | 腾讯科技(深圳)有限公司 | API (application programming interface) testing method and system |
-
2018
- 2018-09-26 CN CN201811125639.7A patent/CN109344063A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080256517A1 (en) * | 2006-10-18 | 2008-10-16 | International Business Machines Corporation | Method and System for Automatically Generating Unit Test Cases Which Can Reproduce Runtime Problems |
CN106339312A (en) * | 2015-07-17 | 2017-01-18 | 腾讯科技(深圳)有限公司 | API (application programming interface) testing method and system |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109977020A (en) * | 2019-04-01 | 2019-07-05 | 山东威尔数据股份有限公司 | A kind of automated testing method |
CN109977020B (en) * | 2019-04-01 | 2022-02-22 | 山东威尔数据股份有限公司 | Automatic testing method |
CN111240967A (en) * | 2020-01-03 | 2020-06-05 | 北京字节跳动网络技术有限公司 | Code generation method and device |
CN111240967B (en) * | 2020-01-03 | 2023-09-15 | 北京字节跳动网络技术有限公司 | Code generation method and device |
CN111930635A (en) * | 2020-09-17 | 2020-11-13 | 深圳微品致远信息科技有限公司 | Swagger-based rapid automatic testing method and system |
CN111930635B (en) * | 2020-09-17 | 2021-06-29 | 深圳微品致远信息科技有限公司 | Swagger-based rapid automatic testing method and system |
CN112612452A (en) * | 2020-12-18 | 2021-04-06 | 华人运通(上海)云计算科技有限公司 | API platform implementation method, device, equipment and storage medium |
CN112612452B (en) * | 2020-12-18 | 2023-11-14 | 华人运通(上海)云计算科技有限公司 | API platform realization method, device, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109344063A (en) | A kind of automated testing method of api interface | |
CN107608889B (en) | Method and system for automatically generating test script | |
WO2021088909A1 (en) | Method and system for assisting operator development | |
CN101882107A (en) | Method and device for automatically testing WEB (World Wide Web) application | |
CN108388515A (en) | Test data generating method, device, equipment and computer readable storage medium | |
CN106649014A (en) | Automatic testing method of calculating type server which supports multiple GPUs | |
CN114186697B (en) | Method and device for generating and applying deep learning model based on deep learning framework | |
CN105279092A (en) | Software testing method and apparatus | |
CN109445771A (en) | A kind of off line network layers block code Auto-Generation Tool of CS framework and method | |
CN110209584A (en) | A kind of automatic generation of test data and relevant apparatus | |
CN106371868A (en) | Automatic test method, system and test device | |
CN103903312A (en) | Method and device for executing automatic inspection | |
CN108491323A (en) | A kind of embedded software automatization test system and method based on Lua scripts | |
CN101634965B (en) | Method for testing Linux kernel-grade unit | |
CN106383734A (en) | Method for extracting detailed design from codes | |
CN111176971A (en) | Code quality testing system and method based on UI automation | |
KR100642906B1 (en) | Programming device | |
CN107656869A (en) | A kind of method that exclusive automatic test report is built based on JAVA | |
CN108536429B (en) | Method and device for developing software, storage medium and electronic equipment | |
CN111966665B (en) | Data migration testing method and device | |
CN102353925A (en) | Parallel meter calibrating method of electric energy meters | |
CN105867894A (en) | Automatic creating method and system of development environment | |
CN112819621B (en) | Intelligent contract resource loss testing method and system | |
CN108958727A (en) | A kind of generation method and system of API client code | |
Kurniawan et al. | Implementation of Making Monitoring Control System (MOS) Applications to Know Cylinder Repair Codes in Paper Production Areas |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190215 |
|
RJ01 | Rejection of invention patent application after publication |