CN108829593A - Code coverage calculation and analysis methods, device, equipment and storage medium - Google Patents

Code coverage calculation and analysis methods, device, equipment and storage medium Download PDF

Info

Publication number
CN108829593A
CN108829593A CN201810569232.7A CN201810569232A CN108829593A CN 108829593 A CN108829593 A CN 108829593A CN 201810569232 A CN201810569232 A CN 201810569232A CN 108829593 A CN108829593 A CN 108829593A
Authority
CN
China
Prior art keywords
code
coverage
file
report
test
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.)
Granted
Application number
CN201810569232.7A
Other languages
Chinese (zh)
Other versions
CN108829593B (en
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.)
Ping An E Wallet Electronic Commerce Co Ltd
Original Assignee
Ping An E Wallet Electronic Commerce 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 Ping An E Wallet Electronic Commerce Co Ltd filed Critical Ping An E Wallet Electronic Commerce Co Ltd
Priority to CN201810569232.7A priority Critical patent/CN108829593B/en
Publication of CN108829593A publication Critical patent/CN108829593A/en
Application granted granted Critical
Publication of CN108829593B publication Critical patent/CN108829593B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/3676Test management for coverage analysis
    • 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/3688Test 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 discloses a kind of code coverage calculation and analysis methods, device, equipment and storage mediums, belong to field of computer technology.This approach includes the following steps:The code commit id corresponding with the code of current version is obtained from code library by git order;The code is packaged and is compiled, is saved into the file of the corresponding commit id name of the code;It receives and is saved with the coverage rate file that the commit id of code is named into the file named with the commit id;The test coverage report of current code is generated by code coverage tool;The coverage rate report of full dose is generated by merging algorithm;The coverage rate report of increment is generated by git diff order.After support code of the present invention frequently changes, the merging of coverage rate situation between different code, so as to obtain the accurate coverage rate file of certain version.

Description

Code coverage calculation and analysis methods, device, equipment and storage medium
Technical field
The present invention relates to field of computer technology, it is related to a kind of code coverage calculation and analysis methods, device, equipment and deposits Storage media.
Background technique
Coverage rate is to measure a means of test completeness, is a measurement of test validity.By having executed generation Code expression, the evaluation and test for reliability, stability and performance.
Test coverage is the evaluation and test to test completeness.Test coverage be covering by testing requirement and test case or The covering expression of code is executed.It establishes in the assessment to test result and the change request determined in test process (is lacked Fall into) analysis on the basis of.
Currently, coverage rate tool only in the case where code does not change, could calculate coverage data.But mobile phone System development can change code because of demand change or defect repair in test phase, so that a version has multiple surveys Examination packet;Moreover, it is the same also not can guarantee the test bag installed on each tester's testing mobile phone in the same time, so as to cause The coverage data inaccuracy collected, can not obtain the correct coverage rate of this current version.
Summary of the invention
The technical problem to be solved by the present invention is in order to overcome in the prior art be directed to cell phone system code coverage number According to the problem for calculating inaccuracy, a kind of code coverage calculation and analysis methods, device, equipment and storage medium are proposed, is passed through Calculating is merged to the coverage rate file below all commit id under some version, certain version is obtained and accurately covers Rate file.
The present invention is to solve above-mentioned technical problem by following technical proposals:
A kind of code coverage calculation and analysis methods, include the following steps:
S1, the code for obtaining current version from code library by git order and the corresponding commit id of the code;
S2, the code is packaged to generate corresponding test bag, while after compiling the code to generate compiling File, then test bag is saved with the file after compiling to the file of the code corresponding commit id name In;
S3, the covering that the commit id with code generated after the test bag that test man uploads is tested is named is received Rate file, and the coverage rate file is saved into the file named with the commit id;
S4, the file in the commit id file is calculated to generate and work as former generation by code coverage tool The test coverage report of code;
S5, the test coverage report of current version code and the test of a preceding edition code are covered by merging algorithm The report of lid rate merges, and generates the coverage rate report of full dose;
S6, show that current version code changes the generation of part compared with a preceding edition code by git diff order Code takes out code coverage corresponding with the change code of part from full dose coverage rate report, generates increment Coverage rate report.
Preferably, this method is further comprising the steps of:
S7, the coverage rate report of the increment and the coverage rate report of full dose are sent to and are surveyed to current version code The test man of examination.
Preferably, the code includes applied to the installation procedure on the end IOS and applied to the installation procedure on Android end.
Preferably, when the code is applied to installation procedure on the end IOS, the file after the compiling is gcno text Part, the coverage rate file are gcda file.
Preferably, when the code is applied to installation procedure on Android end, the file after the compiling includes class File and source file, the coverage rate file are ec file.
Preferably, the generating process of the coverage rate report of the full dose is as follows:
S51, show that current version code changes the generation of part compared with a preceding edition code by git diff order Code, to calculate the offset of code;
S52, the offset according to code close the code coverage in the test coverage report of a preceding edition code And into the report of the test coverage of current version code.
Preferably, the coverage rate file is installed after test bag is tested on mobile phone terminal by test man and is given birth to automatically At.
A kind of electronic device is stored with code coverage on the electronic device and calculates analysis system, the code coverage Rate calculates analysis system:
Code obtaining module, the code for obtaining current version from code library by git order are corresponding with the code Commit id;
Be packaged collector, the code is packaged to generate corresponding test bag, at the same compile the code with Then file after generating compiling saves the file after test bag and compiling to the code corresponding commit id name File in;
Coverage rate file reception module, the test bag for receiving test man's upload generate after testing with code The coverage rate file of commit id name, and the coverage rate file is saved to the file named with the commit id In;
Current report generation module, for by code coverage tool to the file in the commit id file into Row is calculated to generate the report of the test coverage of current code;
Full dose report generation module, for by merge algorithm by the report of the test coverage of current version code with it is previous The test coverage report of secondary edition code merges, and generates the coverage rate report of full dose;
Increment report generation module, for obtaining current version code and a preceding edition code by git diff order Compared to the code of change part, code corresponding with the change code of part is taken out from full dose coverage rate report Coverage rate generates the coverage rate report of increment.
A kind of computer equipment, including memory and processor are stored with and can be held by the processor on the memory Capable code coverage calculates analysis system, realizes as described in any one of aforementioned when the system is executed by the processor The step of code coverage calculation and analysis methods.
A kind of computer readable storage medium is stored with code coverage in the computer readable storage medium and calculates point Analysis system, the code coverage calculates analysis system can be performed by least one processor, so that described at least one Manage the step of device executes the code coverage calculation and analysis methods as described in any one of aforementioned.
The positive effect of the present invention is that:In the case where operational trials unaware, coverage rate situation is collected;It supports After code frequently changes, the merging of coverage rate situation between different code, so as to obtain the accurate coverage rate text of certain version Part;The unlapped test point of test phase is automatically analyzed according to current coverage rate report, tester is notified automatically, guarantees to survey The coverage rate of examination.
Detailed description of the invention
Fig. 1 shows the flow chart of code coverage calculation and analysis methods embodiment one of the present invention;
Fig. 2 shows the flow charts of code coverage calculation and analysis methods embodiment two of the present invention;
Fig. 3 shows the program module that code coverage calculates analysis system first embodiment in electronic device of the present invention and shows It is intended to;
Fig. 4 shows the hardware structure schematic diagram of one embodiment of computer equipment of the present invention.
Specific embodiment
The present invention is further illustrated below by the mode of embodiment, but does not therefore limit the present invention to the reality It applies among a range.
Firstly, the present invention proposes a kind of code coverage calculation and analysis methods.
In example 1, as shown in Figure 1, for the installation procedure being applied on the end IOS, the code coverage meter Analysis method is calculated to include the following steps:
S1, the code for obtaining current version from code library by git order and the corresponding commit id of the code.
After usual programmer has write a program, which can all be uploaded to a specific code library (such as sand Box) in, it include corresponding commit id in the program of upload.
Id in the commit id refers to that cryptographic Hash, the cryptographic Hash are passed through according to the data of the content of file The numerical value that logical operation obtains, the cryptographic Hash that different file (even identical filename) obtains also are different, so Cryptographic Hash can be used as the identity card for identifying each file.
When needing to test code, newest code (i.e. current version is just pulled by git order from code library This code) because the installation procedure of same version can all may give birth to by repeatedly modification, each modification in the process of development At a new code, current version described here does not refer to the version number of code, but refers to the cryptographic Hash of code, in the application What alleged current version and previous version were distinguished by cryptographic Hash.
Specifically, Jenkins tool can be used by code being obtained from code library.The Jenkins be one open source, Continuous integrating (CI) tool at friendliness interface is provided, originates from Hudson (Hudson is commercial), is mainly used for holding Continuous, automatic building/test software project, the operation for monitoring external tasks.The concrete operations of Jenkins tool refer to its explanation Book.
S2, the code is packaged to generate corresponding test bag, while after compiling the code to generate compiling Gcno file, then test bag is saved with the gcno file after compiling to the code corresponding commit id name In file.
For the installation procedure being applied on the end IOS, being packaged for test bag can be used by the way of Apple recommendation The archive function of xcode (xcode is the Integrated Development Tool operated on operating system Mac OS X) is packaged (suitable For personal development), by the way of secondly being dragged in using iTunes (iTunes be professional apple equipment management tool), The compiling that a full-automatic compilation script realizes code can also be write.
Wherein first two has used existing tool xcode and iTunes, and specific packing process is shown in its specification.Below for Lower explanation is done by writing full-automatic compilation script progress code compilation:
The first step:New folder is named as " distribute ", distribute.sh script file is created, with reference to such as Lower content (wherein the appName is the title of code, such as some title for the app on IOS):
rm-rf appName
mkdir appName
mkdir appName/Payload
cp-r appName.app appName/Payload/appName.app
cp Icon.png appName/iTunesArtwork
cd appName
zip-r appName.ipa Payload iTunesArtworkexit 0
Above-mentioned code completes following steps:
Delete file appName;
Create a file appName;
A sub-folder payload is created at file appName;
File appName.app is copied in the sub-folder payload under file appName;
Icon Icon.png is copied in the sub-folder iTunesArtwork under file appName;
It is switched to file appName;
Two sub-folders payload and iTunesArtwork under file appName are compressed into a file, And the suffix of compressed file is changed to .ipa;
Normally exit.
Second step:The .app file that will be converted is put under distribute/ file, with reference to as follows:
distribute/distribute.sh
distribute/appName.app
Third step:Run distribute.sh script.Terminal is opened, under cd to distribute file, Distribute.sh drawing is executed into terminal.If prompting permission denied, " chmod is used After 777distribute.sh " order assigns permission, then execute a distribute.sh.
4th step:After running several seconds, appName/ file can be generated under distribute/ file, the inside AppName.ipa is exactly the test bag that we want.
Gcno file after the compiling is by obtaining after carrying out pitching pile to original code, this process is known as program and inserts Stake, described program pitching pile are the methods by by the insertion operation into tested program, to realize test purpose, i.e., in guarantee quilt Some probes (also known as " survey meter ") is inserted on the basis of the original logic integrality of ranging sequence in a program.These probes essence On be exactly the code segment for carrying out information collection, can be assignment statement or acquire coverage information function call.Pass through probe Execute the operation characteristic data of simultaneously output program.Based on the analysis to these characteristics, internal act and the spy of program are disclosed Sign.
S3, the covering that the commit id with code generated after the test bag that test man uploads is tested is named is received Rate gcda file, and the coverage rate gcda file is saved into the file named with the commit id.
The gcda file refers to that suffix is the file of gcda, is obtained by gcov command tools, the gcov order is The tool of the code coverage of a test program.After the code is tested by the tool, a suffix is finally obtained For the coverage rate file of gcda, and the title of this document is named with the commit id of tested code.
After coverage rate gcda file generated, test man also needs to be uploaded in aforementioned specific code library, and saves Into with the file of commit id name.
The coverage rate gcda file is below for generating the basis of coverage rate report.
S4, the file in the commit id file is calculated to generate and work as former generation by code coverage tool The test coverage report of code;
The code coverage tool still can use gcov command tools, will by executing order gcov * .cpp The coverage rate of test is printed on the screen, and generates file " * cpp.gcov " simultaneously, which then can see with vi opening Row is capped, that is, sees which code tester arrives, which, which is not tested, arrives.
S5, the test coverage report of current version code and the test of a preceding edition code are covered by merging algorithm The report of lid rate merges, and generates the coverage rate report of full dose.
The step S5 specifically may include following steps:
S51, show that current version code changes the generation of part compared with a preceding edition code by git diff order Code, to calculate the offset of code;
S52, the offset according to code close the code coverage in the test coverage report of a preceding edition code And into the report of the test coverage of current version code.
Using above-mentioned merging method, can be by the way that test coverage report be gradually merged two-by-two after, ultimately generate The coverage rate of full dose is reported.
S6, show that current version code changes the generation of part compared with a preceding edition code by git diff order Code takes out code coverage corresponding with the change code of part from full dose coverage rate report, generates increment Coverage rate report.
The report of test coverage described in the present embodiment is exactly that the coverage rate file being previously obtained is presented with report form Out.Including but not limited to the following contents:Coverage rate, method coverage rate, sentence covering rate, statement block coverage rate and the branch of class Coverage rate.
In the present embodiment, the test man obtains test bag and can be obtained by way of barcode scanning, as long as completing to test After the packing of packet, increasing the step of automatically generating two dimensional code or bar code etc be can be realized.
In example 2, as shown in Fig. 2, for the installation procedure being applied on the end IOS, the code coverage meter Analysis method is calculated to include the following steps:
S1, the code commit id corresponding with the code for obtaining current version from code library by git order.
Step S1 is as in the first embodiment, details are not described herein again.
S2, the code is packaged to generate corresponding test bag, while after compiling the code to generate compiling Class file and source file, then by test bag and compiling after class file and source file save to this In the file of the corresponding commit id name of code.
The test bag of code applied to Android system refers specifically to be inserted into the peace after the code for generating coverage data Program is filled, after test man installs program operation, automatically generating corresponding code tester rate ec file, (suffix is the text of .ec Part).
The packing of test bag usually completed by writing the included strapping tool of the tool of code, such as Eclipse included Strapping tool Ant, also some, which are write in the tool of code, has specific be packaged to order, and input is specific to be packaged order, and meeting is certainly It is dynamic to generate test bag.
The complete entitled Java class file of the class file, the source file write with java language (code) warp Crossing compiling will become corresponding * .class file.Compiling described here is general all to carry out reality by the compilation facility that developing instrument carries MyEclipse that is existing, such as developing for Java, Java EE and mobile application saves file by the code that it is developed After can be compiled into class file automatically.
Different from the code of IOS system is applied to, the code applied to Android system can also generate one after compiling Source file, this file is for saving source code.
S3, the covering that the commit id with code generated after the test bag that test man uploads is tested is named is received Rate ec file, and the coverage rate ec file is saved into the file named with the commit id;
The ec file refers to that suffix is the file of ec, and this document can be automatically generated by the operation of test bag, this document Title is still with the commit id name of tested code.
The coverage rate ec file is below for generating the basis of coverage rate report.
S4, the file in the commit id file is calculated to generate and work as former generation by code coverage tool The test coverage report of code;
The code coverage tool can use Jacoco (abbreviation of Java Code Coverage) tool, the tool Application method referring to its specification.
S5, the test coverage report of current version code and the test of a preceding edition code are covered by merging algorithm The report of lid rate merges, and generates the coverage rate report of full dose.
The step S5 specifically may include following steps:
S51, show that current version code changes the generation of part compared with a preceding edition code by git diff order Code, to calculate the offset of code;
S52, the offset according to code close the code coverage in the test coverage report of a preceding edition code And into the report of the test coverage of current version code.
Using above-mentioned merging method, can be by the way that test coverage report be gradually merged two-by-two after, ultimately generate The coverage rate of full dose is reported.
S6, show that current version code changes the generation of part compared with a preceding edition code by git diff order Code takes out code coverage corresponding with the change code of part from full dose coverage rate report, generates increment Coverage rate report.
The report of test coverage described in the present embodiment is exactly that the coverage rate file being previously obtained is presented with report form Out.Including but not limited to the following contents:Coverage rate, method coverage rate, sentence covering rate, statement block coverage rate and the branch of class Coverage rate.
The difference of the present embodiment two and embodiment one is only in S2-S4, remaining step is the same as embodiment one.
In the third embodiment, based on the basis of embodiment one or two, the code coverage calculation and analysis methods are also Include the following steps:
S7, the coverage rate report of the increment and the coverage rate report of full dose are sent to and are surveyed to current version code The test man of examination.
Here it can specifically send report in the mailbox of test man, so that it reads in detail.
If it is desired, this report can also be automatically transmitted to all relevant personnel, as long as presetting relevant people in systems The mailbox of member.
It is sent and is reported by mailbox, test man can be allowed to learn test result in time, removed its active from and initiate to obtain report Operation.
Secondly, being stored with code coverage on the electronic device the invention proposes a kind of electronic device and calculating analysis System 20, the system 20 can be divided into one or more program module.
For example, Fig. 3 shows the program module schematic diagram that the code coverage calculates 20 first embodiment of analysis system, In the embodiment, the system 20 can be divided into Code obtaining module 201, packing collector 202, coverage rate file and connect Receive module 203, current report generation module 204, full dose report generation module 205 and increment report generation module 206.Wherein, The so-called program module of the present invention is the series of computation machine program instruction for referring to complete specific function.Being described below will be specific Introduce the concrete function of the program module 201-206.
The Code obtaining module 201 is used to obtain code and generation of current version from code library by git order The corresponding commit id of code.
Id in the commit id refers to that cryptographic Hash, the cryptographic Hash are passed through according to the data of the content of file The numerical value that logical operation obtains, the cryptographic Hash that different file (even identical filename) obtains also are different, so Cryptographic Hash can be used as the identity card for identifying each file.
When needing to test code, it is (i.e. current that newest code is just pulled by git order from code library The code of version) because the installation procedure of same version can may be modified every time and all can by repeatedly modification in the process of development A new code is generated, current version described here does not refer to the version number of code, but refers to the cryptographic Hash of code, the application In alleged current version and previous version distinguished by cryptographic Hash.
Specifically, Jenkins tool can be used by code being obtained from code library.The Jenkins be one open source, Continuous integrating (CI) tool at friendliness interface is provided, originates from Hudson (Hudson is commercial), is mainly used for holding Continuous, automatic building/test software project, the operation for monitoring external tasks.The concrete operations of Jenkins tool refer to its explanation Book.
The packing collector 202 is packaged the code to generate corresponding test bag, while described in compiling Code is to generate the file after compiling, and then the file by test bag and after compiling is saved to the corresponding commit of the code In the file of id name.
For the installation procedure for being applied to the end IOS, what is generated after code compilation is gcno file.
Being packaged for test bag can be by the way of Apple recommendation, i.e., with xcode, (xcode is to operate in operating system Integrated Development Tool on Mac OS X) archive function be packaged (be suitable for personal development), secondly can use The mode that iTunes (the apple equipment management tool that iTunes is profession) is dragged in can also write a full-automatic compiling foot The compiling of this realization code (with reference to described in embodiment of the method one).
Gcno file after the compiling is by obtaining after carrying out pitching pile to original code, this process is known as program and inserts Stake, described program pitching pile are the methods by by the insertion operation into tested program, to realize test purpose, i.e., in guarantee quilt Some probes (also known as " survey meter ") is inserted on the basis of the original logic integrality of ranging sequence in a program.These probes essence On be exactly the code segment for carrying out information collection, can be assignment statement or acquire coverage information function call.Pass through probe Execute the operation characteristic data of simultaneously output program.Based on the analysis to these characteristics, internal act and the spy of program are disclosed Sign.
For the installation procedure for being applied to Android system, the class file and source file that are generated after code compilation.
The test bag of code refers specifically to be inserted into the installation procedure after the code for generating coverage data, test man's installation After program operation, corresponding code tester rate ec file (file that suffix is .ec) can be automatically generated.
The packing of test bag usually completed by writing the included strapping tool of the tool of code, such as Eclipse included Strapping tool Ant, also some, which are write in the tool of code, has specific be packaged to order, and input is specific to be packaged order, and meeting is certainly It is dynamic to generate test bag.
The complete entitled Java class file of the class file, the source file write with java language (code) warp Crossing compiling will become corresponding * .class file.Compiling described here is general all to carry out reality by the compilation facility that developing instrument carries MyEclipse that is existing, such as developing for Java, Java EE and mobile application saves file by the code that it is developed After can be compiled into class file automatically.
Different from the code of IOS system is applied to, the code applied to Android system can also generate one after compiling Source file, this file is for saving source code.
The coverage rate file reception module 203 be used for receive test man upload test bag test after generate with The coverage rate file of the commit id name of code, and the coverage rate file is saved to being named with the commit id In file.
For the installation procedure for being applied to the end IOS, the coverage rate file of generation is gcda file, passes through gcov order work What tool obtained, the gcov order is the tool of the code coverage of a test program.The code is carried out by the tool It is final to obtain the coverage rate file that a suffix is gcda after test, and the title of this document is with tested code Commit id name.
For the installation procedure for being applied to Android system, the coverage rate file of generation is ec file, and this document passes through test The operation of packet can automatically generate, and the title of this document is still with the commit id name of tested code.
The coverage rate file is below for generating the basis of coverage rate report.
The current report generation module 204 is used for through code coverage tool in the commit id file File is calculated to generate the report of the test coverage of current code.
The generating process of report is as follows:Firstly, obtaining current version code and a preceding version by git diff order Code is compared to the code for changing part, to calculate the offset of code;Then according to the offset of code, by preceding primary version Code coverage in the test coverage report of this code is merged into the test coverage report of current version code.
After gradually being merged test coverage report two-by-two, the coverage rate report of full dose is ultimately generated.
The full dose report generation module 205 is used to report the test coverage of current version code by merging algorithm Test coverage report with a preceding edition code merges, and generates the coverage rate report of full dose;
Increment report generation module, for obtaining current version code and a preceding edition code by git diff order Compared to the code of change part, code corresponding with the change code of part is taken out from full dose coverage rate report Coverage rate generates the coverage rate report of increment.
The report of test coverage described in the present embodiment is exactly that the coverage rate file being previously obtained is presented with report form Out.Including but not limited to the following contents:Coverage rate, method coverage rate, sentence covering rate, statement block coverage rate and the branch of class Coverage rate.
Again, the present invention also puts forward a kind of computer equipment.
As shown in fig.4, being the hardware structure schematic diagram of one embodiment of computer equipment of the present invention.In the present embodiment, institute Stating computer equipment 2 is that one kind can be automatic to carry out at numerical value calculating and/or information according to the instruction for being previously set or storing The equipment of reason.For example, it may be smart phone, tablet computer, laptop, desktop computer, rack-mount server, blade Formula server, (including the service composed by independent server or multiple servers of tower server or Cabinet-type server Device cluster) etc..As shown, the computer equipment 2 includes at least, but it is not limited to, company can be in communication with each other by system bus It connects memory 21, processor 22, network interface 23 and code coverage and calculates analysis system 20.Wherein:
The memory 21 includes at least a type of computer readable storage medium, and the readable storage medium storing program for executing includes Flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory etc.), random access storage device (RAM), it is static with Machine accesses memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable Read memory (PROM), magnetic storage, disk, CD etc..In some embodiments, the memory 21 can be described The internal storage unit of computer equipment 2, such as the hard disk or memory of the computer equipment 2.In further embodiments, described Memory 21 is also possible to the plug-in type being equipped on the External memory equipment of the computer equipment 2, such as the computer equipment 2 Hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..Certainly, the memory 21 can also both include the internal storage unit of the computer equipment 2 or wrap Include its External memory equipment.In the present embodiment, the memory 21 is installed on the behaviour of the computer equipment 2 commonly used in storage Make system and types of applications software, such as the code coverage calculates the program code etc. of analysis system 20.In addition, described deposit Reservoir 21 can be also used for temporarily storing the Various types of data that has exported or will export.
The processor 22 can be in some embodiments central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor or other data processing chips.The processor 22 is commonly used in the control meter Calculate machine equipment 2 overall operation, such as execute with the computer equipment 2 carry out data interaction or communication it is relevant control and Processing etc..In the present embodiment, the processor 22 is for running the program code stored in the memory 21 or processing number According to, such as run the code coverage and calculate analysis system 20 etc..
The network interface 23 may include radio network interface or wired network interface, which is commonly used in Communication connection is established between the computer equipment 2 and other computer equipments.For example, the network interface 23 is for passing through The computer equipment 2 is connected by network with exterior terminal, establishes data between the computer equipment 2 and exterior terminal Transmission channel and communication connection etc..The network can be intranet (Intranet), internet (Internet), the whole world Mobile communcations system (Global System of Mobile communication, GSM), wideband code division multiple access (Wideband Code Division Multiple Access, WCDMA), 4G network, 5G network, bluetooth (Bluetooth), The wirelessly or non-wirelessly network such as Wi-Fi.
It should be pointed out that Fig. 4 illustrates only the computer equipment 2 with component 21-23, it should be understood that simultaneously All components shown realistic are not applied, the implementation that can be substituted is more or less component.
In the present embodiment, the code coverage being stored in memory 21 calculates analysis system 20 can be by one A or multiple processors (the present embodiment is processor 22) are performed, to complete the behaviour of above-mentioned code coverage calculation and analysis methods Make.
In addition, a kind of computer readable storage medium of the present invention, code is stored in the computer readable storage medium and is covered Lid rate calculates analysis system 20 and realizes when code coverage calculating analysis system 20 can be executed by one or more processors The operation of above-mentioned code coverage calculation and analysis methods or electronic device.
Although specific embodiments of the present invention have been described above, it will be appreciated by those of skill in the art that this is only For example, protection scope of the present invention is to be defined by the appended claims.Those skilled in the art without departing substantially from Under the premise of the principle and substance of the present invention, many changes and modifications may be made, but these change and Modification each falls within protection scope of the present invention.

Claims (10)

1. a kind of code coverage calculation and analysis methods, which is characterized in that include the following steps:
S1, the code for obtaining current version from code library by git order and the corresponding commit id of the code;
S2, the code is packaged to generate corresponding test bag, while compiles the code to generate the text after compiling Then part saves test bag into the file of the code corresponding commit id name with the file after compiling;
S3, the coverage rate text that the commit id with code generated after the test bag that test man uploads is tested is named is received Part, and the coverage rate file is saved into the file named with the commit id;
S4, the file in the commit id file is calculated to generate current code by code coverage tool Test coverage report;
S5, the test coverage by merging test coverage report and a preceding edition code of the algorithm by current version code Report merges, and generates the coverage rate report of full dose;
S6, show that current version code changes the code of part compared with a preceding edition code by git diff order, from Code coverage corresponding with the change code of part is taken out in the full dose coverage rate report, generates the covering of increment Rate report.
2. code coverage calculation and analysis methods according to claim 1, which is characterized in that this method further includes following step Suddenly:
S7, the report of the coverage rate of the increment and the coverage rate report of full dose be sent to, current version code is tested Test man.
3. code coverage calculation and analysis methods according to claim 1 or 2, which is characterized in that the code includes answering Installation procedure on the end IOS and applied to the installation procedure on Android end.
4. code coverage calculation and analysis methods according to claim 3, which is characterized in that when the code be applied to When installation procedure on the end IOS, the file after the compiling is gcno file, and the coverage rate file is gcda file.
5. code coverage calculation and analysis methods according to claim 3, which is characterized in that the code is applied to peace When installation procedure on Zhuo Duan, the file after the compiling includes class file and source file, and the coverage rate file is Ec file.
6. code coverage calculation and analysis methods according to claim 3, which is characterized in that the coverage rate report of the full dose The generating process of announcement is as follows:
S51, show that current version code changes the code of part compared with a preceding edition code by git diff order, from And calculate the offset of code;
Code coverage in the test coverage report of a preceding edition code is merged by S52, the offset according to code In the test coverage report of current version code.
7. code coverage calculation and analysis methods according to claim 3, which is characterized in that the coverage rate file is by surveying Examination person installs after test bag is tested on mobile phone terminal and automatically generates.
8. a kind of electronic device, which is characterized in that it is stored with code coverage on the electronic device and calculates analysis system, it is described Code coverage calculates analysis system:
Code obtaining module, the code for obtaining current version from code library by git order are corresponding with the code commit id;
Be packaged collector, for being packaged the code to generate corresponding test bag, at the same compile the code with Then file after generating compiling saves the file after test bag and compiling to the code corresponding commit id name File in;
Coverage rate file reception module, the test bag for receiving test man's upload generate after testing with code The coverage rate file of commit id name, and the coverage rate file is saved to the file named with the commit id In;
Current report generation module, based on being carried out by code coverage tool to the file in the commit id file It calculates to generate the report of the test coverage of current code;
Full dose report generation module, for by merging test coverage report and preceding primary version of the algorithm by current version code The test coverage report of this code merges, and generates the coverage rate report of full dose;
Increment report generation module, for obtaining current version code compared with a preceding edition code by git diff order The code for changing part takes out code coverage corresponding with the change code of part from full dose coverage rate report Rate generates the coverage rate report of increment.
9. a kind of computer equipment, including memory and processor, which is characterized in that being stored on the memory can be described The code coverage that processor executes calculates analysis system, and such as claim 1- is realized when the system is executed by the processor Described in any one of 7 the step of code coverage calculation and analysis methods.
10. a kind of computer readable storage medium, which is characterized in that be stored with code in the computer readable storage medium and cover Lid rate calculates analysis system, and the code coverage calculates analysis system can be performed by least one processor, so that described At least one processor is executed such as the step of code coverage calculation and analysis methods of any of claims 1-7.
CN201810569232.7A 2018-06-05 2018-06-05 Code coverage rate calculation and analysis method, device, equipment and storage medium Active CN108829593B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810569232.7A CN108829593B (en) 2018-06-05 2018-06-05 Code coverage rate calculation and analysis method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810569232.7A CN108829593B (en) 2018-06-05 2018-06-05 Code coverage rate calculation and analysis method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN108829593A true CN108829593A (en) 2018-11-16
CN108829593B CN108829593B (en) 2023-12-05

Family

ID=64143800

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810569232.7A Active CN108829593B (en) 2018-06-05 2018-06-05 Code coverage rate calculation and analysis method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN108829593B (en)

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109766261A (en) * 2018-12-14 2019-05-17 中国平安财产保险股份有限公司 Coverage test method, device, computer equipment and storage medium
CN110188048A (en) * 2019-06-05 2019-08-30 北京科摩仕捷科技有限公司 A method of realizing accurate monitor code coverage rate
CN110245073A (en) * 2019-05-21 2019-09-17 北京字节跳动网络技术有限公司 Client code coverage rate monitoring method, system, medium and electronic equipment
CN110413532A (en) * 2019-08-08 2019-11-05 上海新炬网络技术有限公司 More process version change code coverage acquisition methods suitable for agility test
CN110597710A (en) * 2019-08-13 2019-12-20 平安证券股份有限公司 Test coverage rate statistical method and device, computer equipment and storage medium
CN110618935A (en) * 2019-08-27 2019-12-27 绿漫科技有限公司 Code change coverage rate statistics realization method for manual test
CN110928776A (en) * 2019-11-15 2020-03-27 武汉极意网络科技有限公司 Detection method, device and equipment for realizing incremental code coverage rate based on lcov
CN111008143A (en) * 2019-12-17 2020-04-14 上海品顺信息科技有限公司 Coverage rate scheduling test method, terminal device and computer readable storage medium
CN111078563A (en) * 2019-12-18 2020-04-28 上海品顺信息科技有限公司 Coverage rate data processing method, terminal device and computer readable storage medium
CN111090583A (en) * 2019-11-25 2020-05-01 广州品唯软件有限公司 Method and device for generating code coverage rate report and computer equipment
CN111290943A (en) * 2020-01-13 2020-06-16 北京三快在线科技有限公司 Code coverage rate processing method, device, server and storage medium
CN111930619A (en) * 2020-08-06 2020-11-13 杭州有赞科技有限公司 Real-time coverage rate statistical method, computer equipment and readable storage medium
CN112463620A (en) * 2020-12-03 2021-03-09 广州品唯软件有限公司 Coverage rate testing method and device in android software integration test
CN112597041A (en) * 2020-12-28 2021-04-02 上海品顺信息科技有限公司 Cross-branch merging method, system, equipment and storage medium for code coverage rate
CN112612716A (en) * 2020-12-28 2021-04-06 上海品顺信息科技有限公司 Method, system, equipment and storage medium for enhancing marking of coverage rate of difference line codes
CN113806231A (en) * 2021-09-29 2021-12-17 锐捷网络股份有限公司 Code coverage rate analysis method, device, equipment and medium
CN113806227A (en) * 2021-09-26 2021-12-17 五八同城信息技术有限公司 Information processing method and device, electronic equipment and storage medium
CN113934627A (en) * 2021-09-26 2022-01-14 五八同城信息技术有限公司 Code execution coverage rate statistical method and device, electronic equipment and readable medium
CN114003513A (en) * 2021-12-30 2022-02-01 云账户技术(天津)有限公司 Code coverage rate processing method and device, electronic equipment and readable storage medium
CN114647570A (en) * 2020-12-21 2022-06-21 顺丰科技有限公司 Code increment coverage rate statistical method, device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030093716A1 (en) * 2001-11-13 2003-05-15 International Business Machines Corporation Method and apparatus for collecting persistent coverage data across software versions
CN105988926A (en) * 2015-02-13 2016-10-05 腾讯科技(深圳)有限公司 Method and device for processing multi-version test data
CN106126430A (en) * 2016-08-19 2016-11-16 浪潮(北京)电子信息产业有限公司 The method of testing of a kind of code coverage and device
CN106681912A (en) * 2016-12-08 2017-05-17 武汉斗鱼网络科技有限公司 Method and device for automatic testing of code coverage rate, applied to Android system
CN107729239A (en) * 2017-10-10 2018-02-23 郑州云海信息技术有限公司 A kind of code coverage statistical method, system, device and computer-readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030093716A1 (en) * 2001-11-13 2003-05-15 International Business Machines Corporation Method and apparatus for collecting persistent coverage data across software versions
CN105988926A (en) * 2015-02-13 2016-10-05 腾讯科技(深圳)有限公司 Method and device for processing multi-version test data
CN106126430A (en) * 2016-08-19 2016-11-16 浪潮(北京)电子信息产业有限公司 The method of testing of a kind of code coverage and device
CN106681912A (en) * 2016-12-08 2017-05-17 武汉斗鱼网络科技有限公司 Method and device for automatic testing of code coverage rate, applied to Android system
CN107729239A (en) * 2017-10-10 2018-02-23 郑州云海信息技术有限公司 A kind of code coverage statistical method, system, device and computer-readable storage medium

Cited By (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109766261B (en) * 2018-12-14 2024-05-24 中国平安财产保险股份有限公司 Coverage test method, coverage test device, computer equipment and storage medium
CN109766261A (en) * 2018-12-14 2019-05-17 中国平安财产保险股份有限公司 Coverage test method, device, computer equipment and storage medium
CN110245073A (en) * 2019-05-21 2019-09-17 北京字节跳动网络技术有限公司 Client code coverage rate monitoring method, system, medium and electronic equipment
CN110188048A (en) * 2019-06-05 2019-08-30 北京科摩仕捷科技有限公司 A method of realizing accurate monitor code coverage rate
CN110413532A (en) * 2019-08-08 2019-11-05 上海新炬网络技术有限公司 More process version change code coverage acquisition methods suitable for agility test
CN110597710B (en) * 2019-08-13 2024-04-05 平安证券股份有限公司 Test coverage rate statistical method, device, computer equipment and storage medium
CN110597710A (en) * 2019-08-13 2019-12-20 平安证券股份有限公司 Test coverage rate statistical method and device, computer equipment and storage medium
CN110618935A (en) * 2019-08-27 2019-12-27 绿漫科技有限公司 Code change coverage rate statistics realization method for manual test
CN110928776A (en) * 2019-11-15 2020-03-27 武汉极意网络科技有限公司 Detection method, device and equipment for realizing incremental code coverage rate based on lcov
CN111090583A (en) * 2019-11-25 2020-05-01 广州品唯软件有限公司 Method and device for generating code coverage rate report and computer equipment
CN111090583B (en) * 2019-11-25 2023-04-07 广州品唯软件有限公司 Method and device for generating code coverage rate report and computer equipment
CN111008143B (en) * 2019-12-17 2023-06-13 上海品顺信息科技有限公司 Coverage rate scheduling test method, terminal equipment and computer readable storage medium
CN111008143A (en) * 2019-12-17 2020-04-14 上海品顺信息科技有限公司 Coverage rate scheduling test method, terminal device and computer readable storage medium
CN111078563A (en) * 2019-12-18 2020-04-28 上海品顺信息科技有限公司 Coverage rate data processing method, terminal device and computer readable storage medium
CN111290943A (en) * 2020-01-13 2020-06-16 北京三快在线科技有限公司 Code coverage rate processing method, device, server and storage medium
CN111930619B (en) * 2020-08-06 2024-04-16 杭州有赞科技有限公司 Real-time coverage rate statistical method, computer equipment and readable storage medium
CN111930619A (en) * 2020-08-06 2020-11-13 杭州有赞科技有限公司 Real-time coverage rate statistical method, computer equipment and readable storage medium
CN112463620A (en) * 2020-12-03 2021-03-09 广州品唯软件有限公司 Coverage rate testing method and device in android software integration test
CN114647570A (en) * 2020-12-21 2022-06-21 顺丰科技有限公司 Code increment coverage rate statistical method, device, computer equipment and storage medium
CN112612716A (en) * 2020-12-28 2021-04-06 上海品顺信息科技有限公司 Method, system, equipment and storage medium for enhancing marking of coverage rate of difference line codes
CN112612716B (en) * 2020-12-28 2023-01-20 上海品顺信息科技有限公司 Method, system, equipment and storage medium for enhancing marking of coverage rate of difference line codes
CN112597041B (en) * 2020-12-28 2023-01-20 上海品顺信息科技有限公司 Cross-branch merging method, system, equipment and storage medium for code coverage rate
CN112597041A (en) * 2020-12-28 2021-04-02 上海品顺信息科技有限公司 Cross-branch merging method, system, equipment and storage medium for code coverage rate
CN113934627A (en) * 2021-09-26 2022-01-14 五八同城信息技术有限公司 Code execution coverage rate statistical method and device, electronic equipment and readable medium
CN113806227B (en) * 2021-09-26 2023-12-12 五八同城信息技术有限公司 Information processing method, device, electronic equipment and storage medium
CN113806227A (en) * 2021-09-26 2021-12-17 五八同城信息技术有限公司 Information processing method and device, electronic equipment and storage medium
CN113806231B (en) * 2021-09-29 2024-03-19 锐捷网络股份有限公司 Code coverage rate analysis method, device, equipment and medium
CN113806231A (en) * 2021-09-29 2021-12-17 锐捷网络股份有限公司 Code coverage rate analysis method, device, equipment and medium
CN114003513A (en) * 2021-12-30 2022-02-01 云账户技术(天津)有限公司 Code coverage rate processing method and device, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN108829593B (en) 2023-12-05

Similar Documents

Publication Publication Date Title
CN108829593A (en) Code coverage calculation and analysis methods, device, equipment and storage medium
US9342273B1 (en) Automatic communications graphing for a source application
US11704115B2 (en) Software pipeline configuration
US9367305B1 (en) Automatic container definition
CN107896244B (en) Version file distribution method, client and server
CN106293811A (en) A kind of packing and issuing method and device automatically
US20200183683A1 (en) Application architecture generation
CN106294113B (en) creation method and device based on programmable test service
CN106886445A (en) Java packets generation method and equipment and information extracting method and equipment
CN109902005A (en) A kind of method and system of automatic test
CN106873960A (en) The update method and equipment of a kind of application software
CN106095415A (en) Exploitation file packing method, Apparatus and system
CN108170588B (en) Test environment construction method and device
CN103186463B (en) Determine the method and system of the test specification of software
CN112835808A (en) Interface testing method and device, computer equipment and storage medium
CN114398293A (en) Interface test case generation method, electronic device and storage medium
CN107273298B (en) A kind of test method of shell adding tool, apparatus and system
CN115658496A (en) Extensible Web automatic test method, system, equipment and storage medium
CN104036193B (en) Local cross-domain vulnerability detection method and device for application program
CN112965731A (en) Method, device, equipment and storage medium for Flutter hot update based on Tinker
CN110362316A (en) A kind of Source code management method
CN109656825A (en) The method and device of fine arts resource processing, electronic equipment, storage medium
CN115952089A (en) Software automation unit testing method and device, server and storage medium
CN112579530B (en) Data resource organization method and device of automatic test system
CN114115982A (en) Code issuing method, device, equipment and storage medium

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