CN117112413A - Method for automatically generating interface test case - Google Patents
Method for automatically generating interface test case Download PDFInfo
- Publication number
- CN117112413A CN117112413A CN202311045108.8A CN202311045108A CN117112413A CN 117112413 A CN117112413 A CN 117112413A CN 202311045108 A CN202311045108 A CN 202311045108A CN 117112413 A CN117112413 A CN 117112413A
- Authority
- CN
- China
- Prior art keywords
- list
- change
- acquiring
- names
- commit
- 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
- 238000000034 method Methods 0.000 title claims abstract description 170
- 238000012360 testing method Methods 0.000 title claims abstract description 63
- 238000012986 modification Methods 0.000 claims abstract description 7
- 230000004048 modification Effects 0.000 claims abstract description 7
- 238000004806 packaging method and process Methods 0.000 claims description 7
- 238000012216 screening Methods 0.000 claims description 7
- 238000001914 filtration Methods 0.000 claims description 3
- 238000012545 processing Methods 0.000 claims description 3
- 230000007547 defect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000012856 packing Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
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/3684—Test management for test design, e.g. generating new test cases
-
- 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/3692—Test management for test results analysis
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)
- Stored Programmes (AREA)
Abstract
The invention provides a method for automatically generating interface test cases, which comprises the following steps: s1: saving the method call relation list in a database; s2: acquiring a method change list; s3: acquiring an interface URL path corresponding to the changing method; s4: executing the test case; according to the method for automatically generating the interface test case, after the back-end code is modified, the interface which is influenced in the calling link is finally positioned, the corresponding interface URL path, the request mode, the request parameter and the method annotation are obtained, the interface URL path, the request mode, the request parameter and the method annotation are stored in the database as one test case, the modification range of the code is not required to be informed manually, the problem of missing an important test range or scene is avoided, the test is more accurate and more quantifiable, and the test quality is improved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method for automatically generating interface test cases.
Background
The number of updating iterations of the software project is small, more times are hundreds of times, and the number of test cases needing regression is huge every time the back end modifies a point code; at present, after the back-end code is modified, a software project module corresponding to the code is responsible for manually informing the influence range of the code, and the informing mode comprises oral informing or simple document informing; executing the corresponding test case by the tester according to the code influence range;
the prior art has the following defects:
1. the code influence range is manually informed, when a plurality of codes are modified, the problem of missing an important test range or a scene possibly exists, and the test quality is low;
2. the statistical management of the influence range of each modified code is complicated, so that the time cost is increased and the efficiency is reduced;
for items with more iteration times and more complexity, how to accurately and quantitatively determine the test influence range and determine the corresponding interface test cases after the back-end code is modified is an urgent problem to be solved.
Disclosure of Invention
The invention aims to solve the defects in the prior art and provides a method for automatically generating interface test cases.
In order to achieve the above purpose, the invention adopts the following technical scheme:
a method for automatically generating interface test cases comprises the following steps:
s1: saving the method call relation list in a database;
the method comprises the following substeps:
s11: acquiring project source codes;
acquiring corresponding item source codes from a Git warehouse through a JGit component according to specific test requirements;
the Git warehouse comprises item source codes corresponding to all the items of the enterprise;
s12: packaging project source codes;
packaging the project source codes into Jar files through a Maven component;
s13: generating a method call relation list and storing the method call relation list;
generating a method call relation list of the Jar file through a callgraph component, and storing the generated method call relation list into a database;
the database also comprises method calling links corresponding to the methods;
s2: acquiring a method change list;
acquiring a Commit method change list of an implementation project code file from a Git warehouse through a log component;
the method comprises the following substeps:
s21: opening the existing Git warehouse;
opening a Git warehouse through a static method of the Git class;
s22: acquiring a Commit list;
the Commit list comprises a modified content description submitted by each modification of the project source code, and the modified content description comprises a modified method name, a modified method content, a class name of a class where the method is located and the like in the project source code;
acquiring a Commit list of the project source code through a log component;
s23: obtaining a method change list;
traversing the Commit list to obtain the change difference of each Commit;
obtaining a method change list according to the change difference of each Commit;
the method change list comprises method names of various change methods, class names of classes where the methods are located and change contents;
s3: acquiring an interface URL path corresponding to the changing method;
the method comprises the following substeps:
s31: inquiring a method call link;
traversing the change method list, and inquiring a method call link corresponding to the change method from the database through a select component according to the method call relation list, the method names of each change method in the method change list and the class names of the classes of the methods;
s32: calling a link screening method according to the method;
filtering a method call link of a controller path from the queried method call links, and screening class names and method names contained in the controller path;
s33: generating a test case;
the method comprises the following substeps:
s331: matching the screened classes and methods with the project source codes;
matching the class names and the method names contained in the screened controller path with the project source codes to obtain the specific implementation codes of the class names and the method names in the project source codes;
s332: judging a specific implementation code;
judging the corresponding specific implementation codes in the matched project source codes, wherein the specific judging method comprises the following steps of:
judging whether each specific implementation code contains a RequestMapping annotation, and if the method implementation code does not contain the RequestMapping annotation, not processing the method implementation code;
if the method implementation code contains the RequestMappling annotation, acquiring an interface URL path, a request mode, a method annotation and a request parameter contained in the annotation;
saving the interface URL path, the request mode, the method annotation and the request parameter as a test case into a database;
s4: executing the test case;
executing the generated test case;
further, an automatic execution test case or a manual execution test case may be selected.
Compared with the prior art, the invention has the beneficial effects that:
according to the method for automatically generating the interface test case, after the back-end code is modified, the interface which is influenced in the calling link is finally positioned, the corresponding interface URL path, the request mode, the request parameter and the method annotation are obtained, the interface URL path, the request mode, the request parameter and the method annotation are stored in the database as one test case, the modification range of the code is not required to be informed manually, the problem of missing an important test range or scene is avoided, the test is more accurate and more quantifiable, and the test quality is improved;
the statistical management of the influence range of each modified code is not needed, so that the time cost is reduced and the efficiency is improved;
drawings
FIG. 1 is a flow chart of steps of a method for automatically generating interface test cases according to the present invention;
description of the embodiments
For a further understanding of the objects, construction, features, and functions of the invention, reference should be made to the following detailed description of the preferred embodiments.
A method for automatically generating interface test cases comprises the following steps:
s1: saving the method call relation list in a database;
the method comprises the following substeps:
s11: acquiring project source codes;
acquiring corresponding item source codes from a Git warehouse through a JGit component according to specific test requirements;
the Git warehouse comprises item source codes corresponding to all the items of the enterprise;
s12: packaging project source codes;
packaging the project source codes into Jar files through a Maven component;
packing the project source codes into Jar files to prepare for generating a method call relation by using a callgraph component;
s13: generating a method call relation list and storing the method call relation list;
generating a method call relation list of the Jar file through a callgraph component, and storing the generated method call relation list into a database;
the database also comprises method calling links corresponding to the methods;
s2: acquiring a Commit method change list;
acquiring a Commit method change list of an implementation project code file from a Git warehouse through a log component;
the method comprises the following substeps:
s21: opening the existing Git warehouse;
opening the Git warehouse through a clooneRepositorial component of the Git class;
s22: acquiring a Commit list;
the Commit list comprises a modified content description submitted by each modification of the project source code, and the modified content description comprises a modified method name, a modified method content, a class name of a class where the method is located and the like in the project source code;
acquiring a Commit list of the project source code through a log component;
s23: obtaining a method change list;
traversing the Commit list to obtain the change difference of each Commit;
obtaining a method change list according to the change difference of each Commit;
the method change list comprises method names of various change methods, class names of classes where the methods are located and change contents;
s3: acquiring an interface URL path corresponding to the changing method;
the method comprises the following substeps:
s31: inquiring a method call link;
traversing the change method list, and inquiring a method call link corresponding to the change method from the database through a select component according to the method call relation list, the method names of each change method in the method change list and the class names of the classes of the methods;
s32: calling a link screening method according to the method;
filtering a method call link of a controller path from the queried method call links, and screening class names and method names contained in the controller path;
preparing for matching with the project source code in the next step by screening class names and method names contained in the controller path;
s33: generating a test case;
the method comprises the following substeps:
s331: matching the screened classes and methods with the project source codes;
matching the class names and the method names contained in the screened controller path with the project source codes to obtain the specific implementation codes of the class names and the method names in the project source codes;
s332: judging a specific implementation code;
judging the corresponding specific implementation codes in the matched project source codes, wherein the specific judging method comprises the following steps of:
judging whether each specific implementation code contains a RequestMapping annotation, and if the method implementation code does not contain the RequestMapping annotation, not processing the method implementation code;
if the method implementation code contains the RequestMappling annotation, acquiring an interface URL path, a request mode, a method annotation and a request parameter contained in the annotation;
further, dynamically assigning values to the request parameters according to the types of the request parameters;
the types of the request parameters include string, object and the like;
saving the interface URL path, the request mode, the method annotation and the request parameter as a test case into a request library of python;
s4: executing the test case;
further, an automatic execution test case or a manual execution test case can be selected;
the automatic execution test realizes the automatic execution of the test cases by sending a request to the test cases based on a request library of python, reading the request from an openpyrl library of pyhton and writing the test cases into excel;
the excel also contains expected results corresponding to the test cases, and the test cases contained in the excel are not unique;
after the test cases are executed, returning the actual execution results of the test cases, comparing the actual execution results with the expected results of the corresponding test cases in excel, and if the expected results are consistent, passing the test cases; if the test cases are inconsistent, the test cases do not pass;
the invention has been described with respect to the above-described embodiments, however, the above-described embodiments are merely examples of practicing the invention. It should be noted that the disclosed embodiments do not limit the scope of the invention. On the contrary, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the invention.
Claims (6)
1. A method for automatically generating interface test cases is characterized in that: the method comprises the following steps:
s1: saving the method call relation list in a database;
acquiring corresponding item source codes, packaging the item source codes into Jar files, acquiring a method call relation list of the Jar files, and storing the method call relation list into a database;
the database also comprises method calling links corresponding to the methods;
s2: acquiring a method change list;
acquiring a Commit list of an implementation project code file from a Git warehouse;
the Commit list comprises a modified content description submitted by each modification of the project source code, and the modified content description comprises a modified method name, a modified method content and a class name of a class where the method is located in the project source code;
traversing the Commit list to obtain the change difference of each Commit and obtaining a method change list;
s3: acquiring an interface URL path corresponding to the changing method;
the method comprises the following substeps:
s31: inquiring a method call link;
traversing the change method list, and inquiring a method call link corresponding to the change method from the database through a select component according to the method call relation list, the method names of each change method in the method change list and the class names of the classes of the methods;
s32: calling a link screening method according to the method;
filtering a method call link of a controller path from the queried method call links, and screening class names and method names contained in the controller path;
s33: generating a test case;
s4: executing the test case;
executing the generated test case.
2. The method for automatically generating interface test cases according to claim 1, wherein:
step S1 comprises the following sub-steps:
s11: acquiring project source codes;
acquiring corresponding item source codes from a Git warehouse through a JGit component according to specific test requirements;
the Git warehouse comprises item source codes corresponding to all the items of the enterprise;
s12: packaging project source codes;
packaging the project source codes into Jar files through a Maven component;
s13: generating a method call relation list and storing the method call relation list;
and generating a method call relation list of the Jar file through the callgraph component, and storing the generated method call relation list into a database.
3. The method for automatically generating interface test cases according to claim 1, wherein:
step S2 comprises the following sub-steps:
the method comprises the following substeps:
s21: opening the existing Git warehouse;
s22: acquiring a Commit list;
the Commit list comprises a modified content description submitted by each modification of the project source code, and the modified content description comprises a modified method name, a modified method content and a class name of a class where the method is located in the project source code;
s23: obtaining a method change list;
traversing the Commit list to obtain the change difference of each Commit;
obtaining a method change list according to the change difference of each Commit;
the method change list comprises the method names of the change methods, the class names of the classes where the methods are located and the change contents.
4. The method for automatically generating interface test cases according to claim 1, wherein:
step S33 includes the following sub-steps:
s331: matching the screened classes and methods with the project source codes;
matching the class names and the method names contained in the screened controller path with the project source codes to obtain the specific implementation codes of the class names and the method names in the project source codes;
s332: judging a specific implementation code;
judging the corresponding concrete implementation codes in the matched project source codes, and acquiring interface URL paths, request modes, method notes and request parameters contained in the concrete implementation codes of the method after the judgment is successful;
the interface URL path, request mode, method annotation and request parameters are saved as a test case in the database.
5. The method for automatically generating interface test cases according to claim 4, wherein:
in step S332, a specific determination method is as follows:
judging whether each specific implementation code contains a RequestMapping annotation, and if the method implementation code does not contain the RequestMapping annotation, not processing the method implementation code;
if the method implementation code contains the RequestMappling annotation, the interface URL path, the request mode, the method annotation and the request parameter contained in the annotation are acquired.
6. The method for automatically generating interface test cases according to claim 1, wherein:
in step S4, an automatic execution test case or a manual execution test case may be selected.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311045108.8A CN117112413A (en) | 2023-08-18 | 2023-08-18 | Method for automatically generating interface test case |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311045108.8A CN117112413A (en) | 2023-08-18 | 2023-08-18 | Method for automatically generating interface test case |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117112413A true CN117112413A (en) | 2023-11-24 |
Family
ID=88797637
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311045108.8A Pending CN117112413A (en) | 2023-08-18 | 2023-08-18 | Method for automatically generating interface test case |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117112413A (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699488A (en) * | 2013-12-30 | 2014-04-02 | 优视科技有限公司 | Call relation dependence graph based regression testing method and system |
CN106909510A (en) * | 2017-03-02 | 2017-06-30 | 腾讯科技(深圳)有限公司 | A kind of method and server for obtaining test case |
CN113342685A (en) * | 2021-06-29 | 2021-09-03 | 平安资产管理有限责任公司 | Precise test method and device, computer equipment and storage medium |
CN115687161A (en) * | 2022-12-30 | 2023-02-03 | 云筑信息科技(成都)有限公司 | Method for automatically generating interface test case based on scanning maven warehouse |
CN115858393A (en) * | 2022-12-28 | 2023-03-28 | 杭州笨马网络技术有限公司 | Software test range evaluation method and system based on call chain |
CN115905031A (en) * | 2023-03-14 | 2023-04-04 | 云筑信息科技(成都)有限公司 | Test case recommendation method based on accurate quality assurance system |
CN116431520A (en) * | 2023-05-05 | 2023-07-14 | 京东科技控股股份有限公司 | Test scene determination method, device, electronic equipment and storage medium |
CN116521512A (en) * | 2022-09-08 | 2023-08-01 | 北京云思智学科技有限公司 | Accurate test method and device for codes, electronic equipment and computer readable medium |
-
2023
- 2023-08-18 CN CN202311045108.8A patent/CN117112413A/en active Pending
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699488A (en) * | 2013-12-30 | 2014-04-02 | 优视科技有限公司 | Call relation dependence graph based regression testing method and system |
CN106909510A (en) * | 2017-03-02 | 2017-06-30 | 腾讯科技(深圳)有限公司 | A kind of method and server for obtaining test case |
CN113342685A (en) * | 2021-06-29 | 2021-09-03 | 平安资产管理有限责任公司 | Precise test method and device, computer equipment and storage medium |
CN116521512A (en) * | 2022-09-08 | 2023-08-01 | 北京云思智学科技有限公司 | Accurate test method and device for codes, electronic equipment and computer readable medium |
CN115858393A (en) * | 2022-12-28 | 2023-03-28 | 杭州笨马网络技术有限公司 | Software test range evaluation method and system based on call chain |
CN115687161A (en) * | 2022-12-30 | 2023-02-03 | 云筑信息科技(成都)有限公司 | Method for automatically generating interface test case based on scanning maven warehouse |
CN115905031A (en) * | 2023-03-14 | 2023-04-04 | 云筑信息科技(成都)有限公司 | Test case recommendation method based on accurate quality assurance system |
CN116431520A (en) * | 2023-05-05 | 2023-07-14 | 京东科技控股股份有限公司 | Test scene determination method, device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20230065572A1 (en) | System and method for performing automated api tests | |
CN109325865B (en) | Exception handling method, exception handling device, computer equipment and storage medium | |
CN112306855B (en) | Interface automation test method, device, terminal and storage medium | |
CN106708718B (en) | Service framework interface test method and device | |
CN101339532A (en) | Web application system automatized test method and apparatus | |
CN112506807A (en) | Automatic test system for interface serving multiple systems | |
CN111475422A (en) | Dependence checking method based on Jenkins tool | |
CN112306861A (en) | Unittest and Jenkins tool-based interface automatic testing system and method | |
CN108897678B (en) | Static code detection method, static code detection system and storage device | |
CN117112413A (en) | Method for automatically generating interface test case | |
CN116541308B (en) | Regression testing method and system | |
CN116069628A (en) | Intelligent-treatment software automatic regression testing method, system and equipment | |
CN112799697B (en) | Configuration file version migration method based on standard framework | |
CN112328503A (en) | Task acceptance method for software development working platform | |
CN113568662B (en) | Code change influence range analysis method and system based on calling relation | |
CN115033555A (en) | Task dependency relationship repairing method and device, electronic equipment and storage medium | |
CN110058874B (en) | Code patch checking system and method | |
CN107423215A (en) | A kind of WEB page performs the method tested and generate test report automatically | |
CN116661858A (en) | Autonomous architecture-oriented PyPI warehouse system and rapid construction method | |
CN115328896A (en) | Automatic data restoration method, system and medium for policy reporting | |
CN114579174A (en) | Method for automated risk assessment of Java dependent library version upgrading | |
CN113485922A (en) | Test case generation method, test method, tool, device and storage medium | |
CN112711775A (en) | Method, device, equipment and medium for verifying integrity of pollutant data | |
CN115437638A (en) | Interface changing method, device, equipment, medium and program product | |
CN114840589A (en) | Industrial equipment basic parameter management system based on SaaS cloud platform |
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 |