CN113495829A - Automatic interface testing method and system - Google Patents

Automatic interface testing method and system Download PDF

Info

Publication number
CN113495829A
CN113495829A CN202010203801.3A CN202010203801A CN113495829A CN 113495829 A CN113495829 A CN 113495829A CN 202010203801 A CN202010203801 A CN 202010203801A CN 113495829 A CN113495829 A CN 113495829A
Authority
CN
China
Prior art keywords
interface
test
case
generating
use case
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010203801.3A
Other languages
Chinese (zh)
Inventor
陈双艳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Haizhi Xingtu Technology Co ltd
Original Assignee
Beijing Haizhi Xingtu Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Haizhi Xingtu Technology Co ltd filed Critical Beijing Haizhi Xingtu Technology Co ltd
Priority to CN202010203801.3A priority Critical patent/CN113495829A/en
Publication of CN113495829A publication Critical patent/CN113495829A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

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

Abstract

The invention relates to an automatic interface testing method and system, wherein the method comprises the following steps: configuring a use case template file used for defining interface test parameters and an interface test parent class used for defining a use case calling method; generating a test case according to the case template file and the interface test father class; running the generated test case; and generating a test report according to the running result of the test case. The interface test framework constructed by the invention can ensure that a tester does not need to be familiar with the coding language, and can automatically generate the interface automatic test case only by filling the relevant information of the interface case according to the template.

Description

Automatic interface testing method and system
Technical Field
The invention relates to the field of internet science and technology, in particular to an automatic interface testing method and system.
Background
The automatic test is already standard in the software industry, and many functional testers slowly turn to the automatic test, however, the threshold of the automatic test is higher, much learning cost is needed, and people without a language base cannot quickly write a script for performing the interface test.
Disclosure of Invention
In view of the above technical problems, the present invention provides an automatic interface testing method and system.
The technical scheme for solving the technical problems is as follows: an interface automation test method comprises the following steps:
configuring a use case template file used for defining interface test parameters and an interface test parent class used for defining a use case calling method;
generating a test case according to the case template file and the interface test father class;
running the generated test case;
and generating a test report according to the running result of the test case.
The invention has the beneficial effects that: the interface test framework constructed by the invention can ensure that a tester does not need to be familiar with the coding language, and can automatically generate the interface automatic test case only by filling the relevant information of the interface case according to the template.
On the basis of the technical scheme, the invention can be further improved as follows.
Further, the interface test parameters include: use case description, class name, use case method name, use case parameters, interface path, interface parameters, interface request type, and expected return result.
Further, the generating a test case according to the case template file and the interface test parent class specifically includes:
inheriting the interface test parent class;
generating class files, classes and initialization functions according to the class names, generating use case comments according to the use case description, generating a method body according to the use case method names and the use case parameters, generating interface request codes according to the interface paths, the interface parameters and the interface request types, and generating verification codes according to the expected return results.
Further, before generating a test case according to the case template and the interface test parent class, the method further comprises the following steps:
storing the configured use case template file in a use case template directory;
the generating of the test case according to the case template and the interface test parent class specifically includes:
and traversing all the use case template files in the use case template directory, and generating test cases according to all the use case template files and the interface test parent class obtained by traversal.
In order to achieve the above object, the present invention further provides an interface automation test system, including:
the parameter configuration module is used for configuring a case template file for defining interface test parameters and an interface test parent class for defining a case calling method;
the case generating module is used for generating a test case according to the case template file and the interface test father class;
the case operation module is used for operating the generated test cases;
and the report generation module is used for generating a test report according to the running result of the test case.
Further, the interface test parameters include: use case description, class name, use case method name, use case parameters, interface path, interface parameters, interface request type, and expected return result.
Further, the use case generation module specifically includes:
the inheritance unit is used for inheriting the interface test parent class;
the generating unit is used for generating class files, classes and initialization functions according to the class names, generating use case comments according to the use case descriptions, generating method bodies according to the use case method names and the use case parameters, generating interface request codes according to the interface paths, the interface parameters and the interface request types, and generating verification codes according to the expected return results.
Further, still include:
the storage module is used for storing the configured case template file in a case template directory before the case generation module generates a test case according to the case template and the interface test father class;
the use case generation module is specifically configured to:
and traversing all the use case template files in the use case template directory, and generating test cases according to all the use case template files and the interface test parent class obtained by traversal.
Drawings
Fig. 1 is a flowchart of an interface automation test method according to an embodiment of the present invention;
fig. 2 is a software operation flow chart.
Detailed Description
The principles and features of this invention are described below in conjunction with the following drawings, which are set forth by way of illustration only and are not intended to limit the scope of the invention.
Fig. 1 is a flowchart of an interface automation test method according to an embodiment of the present invention, as shown in fig. 1, including:
s1, configuring a case template file for defining interface test parameters and an interface test parent class for defining a case calling method;
specifically, the interface test parameters include: use case description, class name, use case method name, use case parameters, interface path, interface parameters, interface request type, and expected return result. To ensure the structure, the use cases in the same class can be put in a template. The configured use case template file can be stored in a specified use case template directory
The interface test parent class comprises a plurality of general methods which need to be called by use cases, including a request sending method, a common parameter initialization method and the like.
S2, generating a test case according to the case template file and the interface test parent class;
specifically, as shown in fig. 2, the step is completed by a use case generation module and a use case generation runner, where the use case generation module may generate a class file, a class, and an initialization function according to a class name of the template configured in the previous step, generate a use case comment according to a use case description, generate a method body according to a use case method name and a use case parameter, generate an interface request code according to an interface path, an interface parameter, and an interface request type, and generate a verification code according to an expected return result. The case generation module also automatically inherits the interface to test the parent class through the interface.
The use case generation operator receives the command line parameters, namely a use case template directory or a use case template file, and if the command line parameters are the use case template directory or the use case template file, the use case generation operator directly calls the use case generation module to generate a use case to the specified use case directory; and if the case template directory is used, traversing all case template files in the case template directory, and then calling a case generation module to generate the case files.
S3, running the generated test case;
specifically, in this step, an operation frame, such as a self-contained operation frame like Junit, TestNG, etc., may be selected according to the used test frame, and then the operation may be performed using a corresponding command.
And S4, generating a test report according to the operation result of the test case.
Specifically, the test report is used to show whether the case operation is successful.
The interface test framework constructed by the embodiment of the method can ensure that a tester does not need to be familiar with the coding language, and can automatically generate the interface automatic test case only by filling the relevant information of the interface case according to the template.
The embodiment of the invention provides an interface automatic test system, which comprises:
the parameter configuration module is used for configuring a case template file for defining interface test parameters and an interface test parent class for defining a case calling method;
the case generating module is used for generating a test case according to the case template file and the interface test father class;
the case operation module is used for selecting a test case generated by the operation of the command in the test framework;
and the report generation module is used for generating a test report according to the running result of the test case.
Optionally, in this embodiment, the interface test parameters include: use case description, class name, use case method name, use case parameters, interface path, interface parameters, interface request type, and expected return result.
Optionally, in this embodiment, the use case generating module specifically includes:
the inheritance unit is used for inheriting the interface test parent class;
the generating unit is used for generating class files, classes and initialization functions according to the class names, generating use case comments according to the use case descriptions, generating method bodies according to the use case method names and the use case parameters, generating interface request codes according to the interface paths, the interface parameters and the interface request types, and generating verification codes according to the expected return results.
Optionally, in this embodiment, the system further includes:
the storage module is used for storing the configured case template file in a case template directory before the case generation module generates a test case according to the case template and the interface test father class;
the use case generation module is specifically configured to:
and traversing all the use case template files in the use case template directory, and generating test cases according to all the use case template files and the interface test parent class obtained by traversal.
The reader should understand that in the description of this specification, reference to the description of the terms "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the modules and units in the above described system embodiment may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment of the present invention.
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 unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention essentially or partially contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
While the invention has been described with reference to specific embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (8)

1. An automated interface testing method, comprising:
configuring a use case template file used for defining interface test parameters and an interface test parent class used for defining a use case calling method;
generating a test case according to the case template file and the interface test father class;
running the generated test case;
and generating a test report according to the running result of the test case.
2. The method according to claim 1, wherein the interface test parameters include: use case description, class name, use case method name, use case parameters, interface path, interface parameters, interface request type, and expected return result.
3. The method according to claim 2, wherein the generating of the test case according to the case template file and the interface test parent class specifically includes:
inheriting the interface test parent class;
generating class files, classes and initialization functions according to the class names, generating use case comments according to the use case description, generating a method body according to the use case method names and the use case parameters, generating interface request codes according to the interface paths, the interface parameters and the interface request types, and generating verification codes according to the expected return results.
4. The method according to any one of claims 1 to 3, wherein before generating the test case according to the case template and the interface test parent class, the method further comprises:
storing the configured use case template file in a use case template directory;
the generating of the test case according to the case template and the interface test parent class specifically includes:
and traversing all the use case template files in the use case template directory, and generating test cases according to all the use case template files and the interface test parent class obtained by traversal.
5. An interface automated test system, comprising:
the parameter configuration module is used for configuring a case template file for defining interface test parameters and an interface test parent class for defining a case calling method;
the case generating module is used for generating a test case according to the case template file and the interface test father class;
the case operation module is used for operating the generated test cases;
and the report generation module is used for generating a test report according to the running result of the test case.
6. The interface automation test system of claim 5, wherein the interface test parameters comprise: use case description, class name, use case method name, use case parameters, interface path, interface parameters, interface request type, and expected return result.
7. The interface automation test system according to claim 6, wherein the use case generation module specifically includes:
the inheritance unit is used for inheriting the interface test parent class;
the generating unit is used for generating class files, classes and initialization functions according to the class names, generating use case comments according to the use case descriptions, generating method bodies according to the use case method names and the use case parameters, generating interface request codes according to the interface paths, the interface parameters and the interface request types, and generating verification codes according to the expected return results.
8. An interface automation test system according to any one of claims 5 to 7 further including:
the storage module is used for storing the configured case template file in a case template directory before the case generation module generates a test case according to the case template and the interface test father class;
the use case generation module is specifically configured to:
and traversing all the use case template files in the use case template directory, and generating test cases according to all the use case template files and the interface test parent class obtained by traversal.
CN202010203801.3A 2020-03-20 2020-03-20 Automatic interface testing method and system Pending CN113495829A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010203801.3A CN113495829A (en) 2020-03-20 2020-03-20 Automatic interface testing method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010203801.3A CN113495829A (en) 2020-03-20 2020-03-20 Automatic interface testing method and system

Publications (1)

Publication Number Publication Date
CN113495829A true CN113495829A (en) 2021-10-12

Family

ID=77994110

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010203801.3A Pending CN113495829A (en) 2020-03-20 2020-03-20 Automatic interface testing method and system

Country Status (1)

Country Link
CN (1) CN113495829A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113505083A (en) * 2021-09-09 2021-10-15 连连宝(杭州)信息技术有限公司 Interface pressure performance testing method, device, equipment and medium
CN114328060A (en) * 2022-03-14 2022-04-12 江苏清微智能科技有限公司 Reusable test case framework, construction method and electronic equipment

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160070567A1 (en) * 2014-09-04 2016-03-10 Home Box Office, Inc. Generating related templated files
CN106021118A (en) * 2016-06-20 2016-10-12 深圳充电网科技有限公司 Test code generation method and device and test framework code execution method and device
CN106339312A (en) * 2015-07-17 2017-01-18 腾讯科技(深圳)有限公司 API (application programming interface) testing method and system
CN106469064A (en) * 2016-09-04 2017-03-01 深圳市云智易联科技有限公司 Code generating method and code generating unit
CN109408357A (en) * 2017-12-04 2019-03-01 深圳市珍爱网信息技术有限公司 A kind of automatic interface testing method and device
CN109446072A (en) * 2018-09-27 2019-03-08 深圳壹账通智能科技有限公司 The generation method and device of test script
CN109815141A (en) * 2019-01-07 2019-05-28 中国联合网络通信集团有限公司 A kind of test method and device
CN110209569A (en) * 2018-05-10 2019-09-06 腾讯科技(深圳)有限公司 Interface test method, interface test device and storage medium
CN110309071A (en) * 2019-06-27 2019-10-08 杭州数梦工场科技有限公司 Test the generation method and module, test method and system of code
CN110781082A (en) * 2019-10-14 2020-02-11 腾讯科技(深圳)有限公司 Method, device, medium and equipment for generating test case of interface

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160070567A1 (en) * 2014-09-04 2016-03-10 Home Box Office, Inc. Generating related templated files
CN106339312A (en) * 2015-07-17 2017-01-18 腾讯科技(深圳)有限公司 API (application programming interface) testing method and system
CN106021118A (en) * 2016-06-20 2016-10-12 深圳充电网科技有限公司 Test code generation method and device and test framework code execution method and device
CN106469064A (en) * 2016-09-04 2017-03-01 深圳市云智易联科技有限公司 Code generating method and code generating unit
CN109408357A (en) * 2017-12-04 2019-03-01 深圳市珍爱网信息技术有限公司 A kind of automatic interface testing method and device
CN110209569A (en) * 2018-05-10 2019-09-06 腾讯科技(深圳)有限公司 Interface test method, interface test device and storage medium
CN109446072A (en) * 2018-09-27 2019-03-08 深圳壹账通智能科技有限公司 The generation method and device of test script
CN109815141A (en) * 2019-01-07 2019-05-28 中国联合网络通信集团有限公司 A kind of test method and device
CN110309071A (en) * 2019-06-27 2019-10-08 杭州数梦工场科技有限公司 Test the generation method and module, test method and system of code
CN110781082A (en) * 2019-10-14 2020-02-11 腾讯科技(深圳)有限公司 Method, device, medium and equipment for generating test case of interface

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113505083A (en) * 2021-09-09 2021-10-15 连连宝(杭州)信息技术有限公司 Interface pressure performance testing method, device, equipment and medium
CN113505083B (en) * 2021-09-09 2021-12-14 连连宝(杭州)信息技术有限公司 Interface pressure performance testing method, device, equipment and medium
CN114328060A (en) * 2022-03-14 2022-04-12 江苏清微智能科技有限公司 Reusable test case framework, construction method and electronic equipment

Similar Documents

Publication Publication Date Title
US9465718B2 (en) Filter generation for load testing managed environments
CN106339312B (en) API test method and system
CN104035863B (en) A kind of browser testing method and device
CN104794048A (en) Automatic UI testing method and system
CN108614702B (en) Byte code optimization method and device
CN108923997B (en) Cloud service node automatic testing method and device based on python
CN113495829A (en) Automatic interface testing method and system
CN115080398A (en) Automatic interface test system and method
CN110990274A (en) Data processing method, device and system for generating test case
CN111897711B (en) Positioning method and device for bug in code, electronic equipment and readable storage medium
CN111026080A (en) Hardware-in-loop test method and device for controller
CN110968505A (en) Automatic test method and system for API (application program interface)
CN111679982A (en) Automatic testing method for REST API (representational State transfer) interface software
CN117290250A (en) Automatic test framework establishment method, computer equipment and computer storage medium
CN115878475A (en) Abnormal scene testing method, device and system
Tyagi et al. Development of reusable hybrid test automation framework for web based scrum projects
CN114238143A (en) ES data number making method, system and storage medium for interface test
CN115705297A (en) Code call detection method, device, computer equipment and storage medium
CN113392003A (en) Evaluation method and device of programming code
CN113672509A (en) Automatic testing method, device, testing platform and storage medium
CN113535581A (en) Test script generation method, device, equipment and computer readable storage medium
CN109446091B (en) Business entity object testing method and device
CN112328468A (en) Code security scanning method and device
CN112433738B (en) Firmware update test method, system, equipment and medium
CN114448851B (en) Automatic data testing method and system

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