CN113094289A - Method for realizing interface coverage rate statistics through python language - Google Patents
Method for realizing interface coverage rate statistics through python language Download PDFInfo
- Publication number
- CN113094289A CN113094289A CN202110539986.XA CN202110539986A CN113094289A CN 113094289 A CN113094289 A CN 113094289A CN 202110539986 A CN202110539986 A CN 202110539986A CN 113094289 A CN113094289 A CN 113094289A
- Authority
- CN
- China
- Prior art keywords
- library
- interface
- file
- coverage rate
- name
- 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 34
- 230000006870 function Effects 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 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/3676—Test management for coverage analysis
-
- 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
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 the technical field of interface coverage rate statistics, in particular to a realization method for realizing interface coverage rate statistics through a python language, which comprises an os library, a re library and an xlswriter library of a python environment, wherein (1) the python software environment is built on a local computer, and the os library, the re library and the xlswriter library are installed under the software environment; (2) carrying out code coverage rate statistics on software codes to be detected through a jacoco tool, and downloading a statistical result to a local computer; (3) analyzing a file directory through an os library and a re library, and recording an html file path needing to be counted; (4) analyzing the html file through a re library and an os library, and recording the file name, the interface name and the interface coverage condition of the analyzed file; (5) the analysis result is recorded into the xls table through the xlswriter library, and the method can improve the interface coverage rate information and can improve the working efficiency.
Description
Technical Field
The invention relates to the technical field of interface coverage rate statistics, in particular to a realization method for realizing interface coverage rate statistics through a python language.
Background
There are many code coverage statistics tools at present, but there is no tool for interface coverage statistics. In the whole software quality assurance system, the interface automation is always a very reliable method. When the software-implemented process performs regression testing, we can know which code is executed for each module (or each function) by automatically combining code coverage statistics through the interface. The unexecuted code is then analyzed to derive unexecuted functions. When it needs to count which interfaces are not executed, the interfaces need to be found out in the unexecuted codes and then copied into the table. The code amount is very large, and the step of manual counting is time-consuming and labor-consuming and is very inconvenient.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a method for realizing interface coverage rate statistics through a python language.
In order to achieve the purpose, the invention provides the following technical scheme: an implementation method for realizing interface coverage rate statistics through a python language comprises an os library, a re library and an xlswriter library of a python environment,
os library: the system operation library reads the file through the system operation library;
re library: the regular expression library is used for extracting a result to be counted through a regular expression root;
xlswriter library: the xls table operation library records the result of the regular expression into an xls table;
the implementation method of the system comprises the following steps:
(1) building a python software environment on a local computer, and installing an os library, a re library and an xlswriter library in the software environment;
(2) carrying out code coverage rate statistics on software codes to be detected through a jacoco tool, and downloading a statistical result to a local computer;
(3) analyzing a file directory through an os library and a re library, and recording an html file path needing to be counted;
(4) analyzing the html file through a re library and an os library, and recording the file name, the interface name and the interface coverage condition of the analyzed file;
(5) the results of the analysis are entered into the xls table by the xls writer library.
Preferably, the file generated by the statistical result in the step (2) is an html format file.
Preferably, according to the steps (2) and (3), the specific steps are as follows: detecting the software codes through a jacoco tool and generating an html file and a java.html file, enabling html file paths of a class and java.html file paths to exist together, and then enabling all paths to exist in a dictionary.
Preferably, according to the step (4), the specific steps are as follows: and setting a judgment rule as that the method is executed, determining that the interface is executed, analyzing each path in the queue one by one through a re library and an os library, extracting a method name and a coverage condition in an html file, extracting the method name and an interface name in a java.
Preferably, according to the step (5), the specific steps are as follows: and (3) creating a table in the local computer, setting a first column in the table as a storage method name, setting an interface name in a second column and setting a coverage rate in a third column, then separating the interface name and the coverage rate through a re library, and completing the statistics of the whole result in the presence of the interface name in the second column and the coverage rate in the third column respectively.
Compared with the prior art, the invention has the beneficial effects that: and on the basis of combining the interface automation and jacoco code coverage rate statistics, obtaining the interface coverage rate condition of the project by analyzing the coverage rate statistical result. The statistical result can help the test development to know the coverage range of the interface automation and the unexecuted interface, so that the interface automation case can be conveniently supplemented, the coverage rate of the interface automation is further provided, the regression efficiency is improved, and the project quality is improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention provides a technical scheme that: a realization method for realizing interface coverage rate statistics through a python language is characterized by comprising the following steps: including the os library, re library and xlswriter library of the python environment,
os library: the system operation library reads the file through the system operation library;
re library: the regular expression library is used for extracting a result to be counted through a regular expression root;
xlswriter library: the xls table operation library records the result of the regular expression into an xls table;
the implementation method of the system comprises the following steps:
(1) building a python software environment on a local computer, and installing an os library, a re library and an xlswriter library in the software environment;
(2) carrying out code coverage rate statistics on software codes to be detected through a jacoco tool, and downloading a statistical result to a local computer;
(3) analyzing a file directory through an os library and a re library, and recording an html file path needing to be counted;
(4) analyzing the html file through a re library and an os library, and recording the file name, the interface name and the interface coverage condition of the analyzed file;
(5) the results of the analysis are entered into the xls table by the xls writer library.
And (3) the file generated by the statistical result in the step (2) is a html format file.
According to the steps (2) and (3), the concrete steps are as follows: detecting the software codes through a jacoco tool and generating an html file and a java.html file, enabling html file paths of a class and java.html file paths to exist together, and then enabling all paths to exist in a dictionary.
According to the step (4), the concrete steps are as follows: and setting a judgment rule as that the method is executed, determining that the interface is executed, analyzing each path in the queue one by one through a re library and an os library, extracting a method name and a coverage condition in an html file, extracting the method name and an interface name in a java.
According to the step (5), the concrete steps are as follows: and (3) creating a table in the local computer, setting a first column in the table as a storage method name, setting an interface name in a second column and setting a coverage rate in a third column, then separating the interface name and the coverage rate through a re library, and completing the statistics of the whole result in the presence of the interface name in the second column and the coverage rate in the third column respectively.
In the statistical process, opening a py file in a local computer, and carrying out system environment configuration:
if _name_==”_main_”:
# coverage File Path
Dir _ path = 'C: \ \ Users \ \ XXX \ \ Desktop \ \ statistical result upper directory'
# Generation coverage results Path
Coverage _ path =' C: \ \ Users \ \ XXX \ \ Desktop \ \ Coverage @.
dir _ path is the upper directory path of html and java. html in the local computer software running result, and coverage _ path fills in the path that you want to generate the statistical result.
On the basis of code coverage rate statistics, the interface coverage rate is conveniently and quickly counted. The interface coverage rate result can help the user to check missing and fill in the gap, perfect the interface coverage rate information, improve the working efficiency and improve the project quality.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
Claims (5)
1. A realization method for realizing interface coverage rate statistics through a python language is characterized by comprising the following steps: including the os library, re library and xlswriter library of the python environment,
os library: the system operation library reads the file through the system operation library;
re library: the regular expression library is used for extracting a result to be counted through a regular expression root;
xlswriter library: the xls table operation library records the result of the regular expression into an xls table;
the implementation method of the system comprises the following steps:
(1) building a python software environment on a local computer, and installing an os library, a re library and an xlswriter library in the software environment;
(2) carrying out code coverage rate statistics on software codes to be detected through a jacoco tool, and downloading a statistical result to a local computer;
(3) analyzing a file directory through an os library and a re library, and recording an html file path needing to be counted;
(4) analyzing the html file through a re library and an os library, and recording the file name, the interface name and the interface coverage condition of the analyzed file;
(5) the results of the analysis are entered into the xls table by the xls writer library.
2. The method of claim 1, wherein the method comprises the following steps: and (3) the file generated by the statistical result in the step (2) is a html format file.
3. The method of claim 2, wherein the method comprises the following steps: according to the steps (2) and (3), the concrete steps are as follows: detecting the software codes through a jacoco tool and generating an html file and a java.html file, enabling html file paths of a class and java.html file paths to exist together, and then enabling all paths to exist in a dictionary.
4. A method as claimed in claim 3, wherein the method comprises the following steps: according to the step (4), the concrete steps are as follows: and setting a judgment rule as that the method is executed, determining that the interface is executed, analyzing each path in the queue one by one through a re library and an os library, extracting a method name and a coverage condition in an html file, extracting the method name and an interface name in a java.
5. The implementation method of interface coverage statistics via python language as claimed in claim 4, wherein: according to the step (5), the concrete steps are as follows: and (3) creating a table in the local computer, setting a first column in the table as a storage method name, setting an interface name in a second column and setting a coverage rate in a third column, then separating the interface name and the coverage rate through a re library, and completing the statistics of the whole result in the presence of the interface name in the second column and the coverage rate in the third column respectively.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110539986.XA CN113094289A (en) | 2021-05-18 | 2021-05-18 | Method for realizing interface coverage rate statistics through python language |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110539986.XA CN113094289A (en) | 2021-05-18 | 2021-05-18 | Method for realizing interface coverage rate statistics through python language |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113094289A true CN113094289A (en) | 2021-07-09 |
Family
ID=76665727
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110539986.XA Pending CN113094289A (en) | 2021-05-18 | 2021-05-18 | Method for realizing interface coverage rate statistics through python language |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113094289A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105224460A (en) * | 2015-10-23 | 2016-01-06 | 浪潮电子信息产业股份有限公司 | Method for counting test coverage rate based on plug-in technology |
US20160299835A1 (en) * | 2015-04-08 | 2016-10-13 | Opshub, Inc. | Method and system for providing delta code coverage information |
CN110618935A (en) * | 2019-08-27 | 2019-12-27 | 绿漫科技有限公司 | Code change coverage rate statistics realization method for manual test |
CN111831321A (en) * | 2019-04-22 | 2020-10-27 | 北京世纪好未来教育科技有限公司 | Code coverage rate analysis method and device and electronic equipment thereof |
-
2021
- 2021-05-18 CN CN202110539986.XA patent/CN113094289A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160299835A1 (en) * | 2015-04-08 | 2016-10-13 | Opshub, Inc. | Method and system for providing delta code coverage information |
CN105224460A (en) * | 2015-10-23 | 2016-01-06 | 浪潮电子信息产业股份有限公司 | Method for counting test coverage rate based on plug-in technology |
CN111831321A (en) * | 2019-04-22 | 2020-10-27 | 北京世纪好未来教育科技有限公司 | Code coverage rate analysis method and device and electronic equipment thereof |
CN110618935A (en) * | 2019-08-27 | 2019-12-27 | 绿漫科技有限公司 | Code change coverage rate statistics realization method for manual test |
Non-Patent Citations (3)
Title |
---|
RSLAI: "JAVA代码覆盖率工具JaCoCo", 《博客园》, 10 July 2020 (2020-07-10), pages 6 - 9 * |
YOYO_ZYX: "JaCoCo覆盖率计数器介绍", 《简书》, 28 October 2016 (2016-10-28), pages 1 - 2 * |
随兴: "python爬虫—图书馆html文件解析并存入excel", 《CSDN博客》, 18 January 2019 (2019-01-18), pages 1 - 3 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102184138B (en) | Method and system for automatically reproducing and positioning software error | |
CN106776515B (en) | Data processing method and device | |
JP4370525B2 (en) | Application environment check apparatus and method and program thereof | |
CN102750223B (en) | A kind of location of mistake method based on object-oriented program section spectrum | |
CN111108481B (en) | Fault analysis method and related equipment | |
US10241957B2 (en) | Workload patterns for realistic load recreation in performance testing | |
TW201715398A (en) | Method and system for filtering system information in an operating system for enhancing the efficiency in searching for a system log in the operation system | |
Rong et al. | How is logging practice implemented in open source software projects? a preliminary exploration | |
CN110908870A (en) | Resource monitoring method and device for mainframe, storage medium and equipment | |
CN113094289A (en) | Method for realizing interface coverage rate statistics through python language | |
KR20220060429A (en) | System for collecting log data of remote network switches and method for constructing big-data thereof | |
Zhang et al. | Genlog: Accurate log template discovery for stripped x86 binaries | |
CN116383025A (en) | Performance test method, device, equipment and medium based on Jmeter | |
CN110554949A (en) | Cross-platform process data collecting and analyzing tool, method and using method | |
CN115454702A (en) | Log fault analysis method and device, storage medium and electronic equipment | |
CN112181816B (en) | Scene-based interface testing method and device, computer equipment and medium | |
CN114090011A (en) | Software development method convenient for developer to use | |
CN114385656A (en) | Script detection method and device, computer equipment and storage medium | |
WO2021104027A1 (en) | Code performance testing method, apparatus and device, and storage medium | |
CN114171107A (en) | Detection method, device, equipment and storage medium for VPD information of solid state disk | |
CN113051161A (en) | API misuse detection method based on historical code change information | |
Zhang et al. | ExcePy: A Python Benchmark for Bugs with Python Built-in Types | |
CN117033410A (en) | Method and system for managing blood relationship of data | |
CN113918205A (en) | Method for automatically generating software function coupling matrix | |
CN113806199A (en) | Cloud log cutting method based on events |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210709 |