CN112463586B - Method and medium for automatically generating application program interface test case - Google Patents
Method and medium for automatically generating application program interface test case Download PDFInfo
- Publication number
- CN112463586B CN112463586B CN202011181827.9A CN202011181827A CN112463586B CN 112463586 B CN112463586 B CN 112463586B CN 202011181827 A CN202011181827 A CN 202011181827A CN 112463586 B CN112463586 B CN 112463586B
- Authority
- CN
- China
- Prior art keywords
- application program
- program interface
- value
- parameter value
- prompt
- 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
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 52
- 238000000034 method Methods 0.000 title claims abstract description 33
- 238000004519 manufacturing process Methods 0.000 claims abstract description 11
- 230000006399 behavior Effects 0.000 claims abstract description 4
- 238000004088 simulation Methods 0.000 claims abstract description 4
- 238000007493 shaping process Methods 0.000 claims description 4
- 238000004422 calculation algorithm Methods 0.000 claims description 3
- 230000008569 process Effects 0.000 claims description 3
- 238000012216 screening Methods 0.000 claims description 3
- 238000011161 development Methods 0.000 abstract description 10
- 230000006870 function Effects 0.000 description 11
- 230000010354 integration Effects 0.000 description 3
- 238000013515 script Methods 0.000 description 2
- 238000010998 test method Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000284 extract Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000013522 software testing Methods 0.000 description 1
Images
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
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- 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
- G06F11/3684—Test 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 discloses a method for automatically generating an application program interface test case, which comprises the steps of simulating operation behaviors by a web automation tool, positioning to a page element simulation operation input box, reading a prompt value of the input box, acquiring an interface parameter range type and a data type, reading a data packet by an http proxy tool, determining an interface value, and determining an application program interface parameter value by analyzing the data packet; reading the obtained interface parameter values, parameter names, parameter value types and parameter value ranges to a system production case function, respectively configuring the read interface parameter value types of the application program, compiling cases in a file writing mode, and carrying out automatic testing; by the mode, the development cost is greatly reduced, a large amount of labor input of automatic development is avoided, and meanwhile, due to program generation, timeliness and coverage are improved.
Description
Technical Field
The invention relates to the field of software testing, in particular to a method and a medium for automatically generating an application program interface test case.
Background
With the continuous development of software technology, the complexity of a software system is continuously increased, the cost of the traditional testing method is sharply increased, the testing efficiency is greatly reduced, particularly in agile development, the continuous integration automatic testing ensures the stability of continuous iteration, the automatic continuous integration is relatively easy to realize in the application program interface testing, the automatic testing of the application program interface is realized, the labor cost and time of manual regression testing can be reduced, the testing period is shortened, and the requirement of quick version sending at the rear end is supported.
The automatic testing technology of the application program interface is mainly divided into automatic testing based on postman and automatic testing based on requests library of python and java development languages at present. Under the two tests, a test or a developer is required to compile a large amount of script codes to develop an automatic test case, so that a large workload is generated, and meanwhile, due to the requirement of agile development on automatic integration, the problem of lag often occurs in manual development.
Disclosure of Invention
The invention mainly solves the technical problem of providing a method and a medium for automatically generating an application program interface test case, which can solve the problems of sharply increased cost and low test efficiency of the traditional test method and also solve the problem of the stability of continuous iteration of continuous integrated automatic test.
In order to solve the technical problems, the invention adopts a technical scheme that: a method for automatically generating application program interface test cases comprises the following steps:
the method comprises the steps that a web automation tool simulates operation behaviors of a user, wherein the operation behaviors comprise user login, data setting and click sending, the web automation tool is positioned to a page element simulation operation input box and reads a prompt value of the input box, and the web automation tool reads a parameter value range and a data type corresponding to an application program interface through the prompt value;
the web automation tool reads an http or https data packet to a specified file through an http proxy tool, reads a timestamp of the specified file through program control, screens out post or put messages, determines an interface value, and determines an application program interface parameter value through analyzing the data packet;
reading the obtained application program interface parameter values, parameter names, parameter value types and parameter value ranges to a system production case function, respectively configuring the read application program interface parameter value types by the system production case function, compiling automatic test cases in a file writing mode, and carrying out automatic testing.
Further, if the prompt value does not exist in the input box, the web automation tool inputs a null value, extracts the prompt value through error prompt, and if the prompt value exists, reads a parameter value range and a data type corresponding to an application program interface through the prompt value.
Further, when one application program interface comprises a plurality of parameters, the web automation tool continuously simulates and clicks twice, the two values of the tested application program interface parameters are kept different, other values are fixed, and the application program interface parameters to be tested are determined through two result comparisons.
Further, the web automation tool reads the hint values and processes them through regular matching screening to determine the type and range of hint values.
Further, the system production use case function respectively configures the read application program interface parameter value types and the application program interface parameter value lengths, and when the read application program interface parameter value types are character strings and shaping, the system production use case function respectively generates scripts of corresponding automatic test cases for the two types.
Furthermore, an automatic test case is compiled in a file writing mode, and the automatic test case is automatically generated through program codes according to the corresponding two application program interface parameter value types.
The medium for automatically generating the application program interface test case is used for storing computer software instructions used by the method for automatically generating the application program interface test case, and comprises a program designed by the method for automatically generating the application program interface test case.
The beneficial effects of the invention are: a method and a medium for automatically generating an application program interface test case automatically generate the automatic test case of an application program interface, thereby greatly reducing the development cost and avoiding a large amount of manpower input of automatic development. Meanwhile, due to program generation, timeliness and coverage are improved.
Drawings
FIG. 1 is a flow diagram of a method for automatically generating application program interface test cases in accordance with the present invention;
Detailed Description
The following detailed description of the preferred embodiments of the present invention, taken in conjunction with the accompanying drawings, will make the advantages and features of the invention easier to understand by those skilled in the art, and thus will clearly and clearly define the scope of the invention.
Referring to fig. 1, an embodiment of the present invention includes: a method and medium for automatically generating application program interface test cases specifically comprise the following steps:
s1, front end simulation: simulating to realize user login, data setting, click sending and establishment of regression test inspection software functions and user requirements through a web automation tool library of a python development language, wherein the web automation tool provides a method for positioning page elements, after the page elements are positioned, input box emptying is realized by loading a clear () function method, input box assignment is realized by loading a sendkeys () function method, click determination, submission and other operations are realized by loading a click () function method;
s2, front end data read: when the web automation tool operates on the input box in step S1, the prompt value of the input box is read, if the input box has no prompt value, a null value is input, the prompt value is read by an error prompt, the application program interface parameter value range and the parameter type are read by the prompt value, the prompt value is further processed and filtered by a regular expression according to the extracted prompt value, so as to define the boundary condition and the data type of the prompt value, if the effective prompt value and the data type cannot be extracted, xxxx is input, and the user is requested to judge whether the prompt value passes or not in response to the resp.
S3, message packet reading and analyzing: reading an http or https message packet to a specified file through an http proxy tool, reading the file through program control, screening out post or put messages according to an operation timestamp to determine an application program interface value, and reading a data packet parameter to determine an application program port parameter value;
s4, processing that the same application program interface includes multiple parameters: in step S3, for example, an interface includes a plurality of parameters, the web automation tool continuously simulates and clicks twice by using a processing method, the two values of the tested parameters are kept different, other parameters are fixed, and the parameters to be tested are determined by comparing two messages.
And S5, reading the application program interface value, the parameter name, the parameter value type and the parameter value range value obtained by the web automation tool to a system production use case function. The system production case function built-in algorithm system automatically generates automatic test cases covering different parameters such as normal, abnormal, boundary value and the like in batches according to different application program port parameter types and application program port parameter lengths. The system production case function reads an application program interface parameter value as a character string according to a system built-in algorithm system, if the length of the application program interface parameter is m-n, the types of the application program interface parameter value are respectively set as a shaping type, a null value type, an object type, a special character type, a blank space type, a character string with the length less than m, a character string with the length equal to m and a character string with the length greater than n; reading data with the type of character string, null value, object, special character, space, value smaller than m, value larger than n, value equal to m and value equal to n when the value of the application program interface parameter is shaped and the minimum value and the maximum value of the length of the application program interface parameter are n; and calling the method of the step S6 to generate an automatic test case.
S6, compiling an automatic test case by writing a file, realizing python, writing according to rows, and defining the name of the automatic case by text _ + interface name + parameter name + test type;
such as writing def test _ setSystem _ pwdLength _ string _ input ();
then write test procedure: post (url = "interface name", heads = heads, data = "" "parameter name: parameter value");
write determination test result, alert resp.status _ code | 200 or alert resp.status _ code = = 200.
S7, compiling the logic of the automatic test case according to the step S5 by the method for compiling the automatic test case in the step S6, and generating the automatic test cases in batch.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes performed by the present specification and drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (6)
1. A method for automatically generating application program interface test cases is characterized by comprising the following steps:
the method comprises the steps that a web automation tool simulates operation behaviors of a user, the web automation tool is positioned to a page element simulation operation input box and reads a prompt value of the input box, and the web automation tool reads a parameter value range and a data type corresponding to an application program interface through the prompt value;
the web automation tool reads an http or https data packet to a specified file through an http proxy tool, reads a timestamp of the specified file through program control, screens out post or put messages, determines an interface value, and determines an application program interface parameter value through analyzing the data packet;
reading the obtained application program interface parameter values, parameter names, parameter value types and parameter value ranges to a system production case function, respectively configuring the read application program interface parameter value types by the system production case function, compiling an automatic test case in a file writing mode, and carrying out automatic testing;
the system production case function built-in algorithm system reads that an application program interface parameter value is a character string, the length of the application program interface parameter is m-n, and then the types of the application program interface parameter value and the application program interface parameter value are respectively set as a shaping type, a null value type, an object type, a special character type, a blank space type, a character string with the length less than m, a character string with the length equal to m, and a character string with the length greater than n;
reading the data with the minimum value of the application program interface parameter value of shaping, the minimum value of the application program interface parameter length of m and the maximum value of n, and respectively setting the data with the types of character strings, null values, objects, special characters, blank spaces, values smaller than m, values larger than n, values equal to m and values equal to n.
2. The method of claim 1, wherein the method comprises: if the prompt value does not exist in the input box, the web automation tool inputs a null value, the prompt value is extracted through error prompt, and if the prompt value exists, the parameter value range and the data type corresponding to the application program interface are read through the prompt value.
3. The method of claim 1, wherein the method comprises: when one application program interface comprises a plurality of parameters, the web automation tool continuously simulates clicking twice, keeps the two values of the tested application program interface parameters different, fixes other values, and determines the application program interface parameters to be tested through the comparison of the results of the two times.
4. The method of claim 2, wherein the method comprises: and the web automation tool reads the prompt value and processes the prompt value through regular matching screening to determine the type and the range of the prompt value.
5. The method of claim 1, wherein the method comprises: and compiling the automatic test case by writing in a file, and automatically generating the automatic test case through a program code according to the corresponding two application program interface parameter value types.
6. A medium for automatically generating application program interface test cases is characterized in that: computer software instructions for storing the method for automatically generating application program interface test cases according to any one of claims 1 to 5, comprising a program designed by the method for automatically generating application program interface test cases.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011181827.9A CN112463586B (en) | 2020-10-29 | 2020-10-29 | Method and medium for automatically generating application program interface test case |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011181827.9A CN112463586B (en) | 2020-10-29 | 2020-10-29 | Method and medium for automatically generating application program interface test case |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112463586A CN112463586A (en) | 2021-03-09 |
CN112463586B true CN112463586B (en) | 2022-09-20 |
Family
ID=74834628
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011181827.9A Active CN112463586B (en) | 2020-10-29 | 2020-10-29 | Method and medium for automatically generating application program interface test case |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112463586B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113238965B (en) * | 2021-06-18 | 2023-04-07 | 杭州遥望网络科技有限公司 | Interface test script generation method, system and storage medium |
CN113505068A (en) * | 2021-07-09 | 2021-10-15 | 杭州遥望网络科技有限公司 | Automatic test method, device, equipment and storage medium for HTTP (hyper text transport protocol) interface |
CN114328274A (en) * | 2022-03-07 | 2022-04-12 | 深圳开源互联网安全技术有限公司 | Test template generation method and device, computer equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107203473A (en) * | 2017-05-26 | 2017-09-26 | 四川长虹电器股份有限公司 | The automatization test system and method for automatic expansion interface test case |
CN109992508A (en) * | 2019-03-22 | 2019-07-09 | 恒生电子股份有限公司 | Test exemple automation generation method, device and electronic equipment |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
IN2015DE00812A (en) * | 2015-03-24 | 2015-04-03 | Hcl Technologies Ltd |
-
2020
- 2020-10-29 CN CN202011181827.9A patent/CN112463586B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107203473A (en) * | 2017-05-26 | 2017-09-26 | 四川长虹电器股份有限公司 | The automatization test system and method for automatic expansion interface test case |
CN109992508A (en) * | 2019-03-22 | 2019-07-09 | 恒生电子股份有限公司 | Test exemple automation generation method, device and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN112463586A (en) | 2021-03-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112463586B (en) | Method and medium for automatically generating application program interface test case | |
US7216340B1 (en) | Analysis data validation tool for use in enterprise architecture modeling with result based model updating | |
US7424702B1 (en) | Data integration techniques for use in enterprise architecture modeling | |
US9218269B2 (en) | Testing multiple target platforms | |
US9747190B2 (en) | Analysis system, analysis method, and computer program product | |
US20080276224A1 (en) | Method and Apparatus for Completing Functional Testing | |
CN109189479B (en) | Parallel automatic verification method for processor instruction set | |
US6349393B1 (en) | Method and apparatus for training an automated software test | |
US20070016829A1 (en) | Test case generator | |
Bisht | Robot framework test automation | |
US7895575B2 (en) | Apparatus and method for generating test driver | |
CN108170602B (en) | Test case generation method and device, terminal and computer readable medium | |
US11615018B2 (en) | Automation testing tool framework | |
US10915302B2 (en) | Identification and visualization of associations among code generated from a model and sources that affect code generation | |
JP2016194777A (en) | Software test apparatus, software test method, and software test program | |
CN112540924A (en) | Interface automation test method, device, equipment and storage medium | |
CN107038117B (en) | Web automatic testing method based on definition-reference between event processing functions | |
US9710360B2 (en) | Optimizing error parsing in an integrated development environment | |
Eladawy et al. | A new algorithm for repairing web-locators using optimization techniques | |
CN114297057A (en) | Design and use method of automatic test case | |
CN114356783A (en) | Method and device for automatically generating unit test code, storage medium and equipment | |
Popoola et al. | Evolution of Bad Smells in LabVIEW Graphical Models. | |
US20240202103A1 (en) | System and method for automating testing of an application | |
US20230359546A1 (en) | Reducing computing power for generating test scenario files for decision models | |
CN115587036A (en) | Test system and test case generation method |
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 |