CN106326124A - Coverage rate detecting method, device and equipment - Google Patents

Coverage rate detecting method, device and equipment Download PDF

Info

Publication number
CN106326124A
CN106326124A CN201610734332.1A CN201610734332A CN106326124A CN 106326124 A CN106326124 A CN 106326124A CN 201610734332 A CN201610734332 A CN 201610734332A CN 106326124 A CN106326124 A CN 106326124A
Authority
CN
China
Prior art keywords
described
file
data
coverage rate
program
Prior art date
Application number
CN201610734332.1A
Other languages
Chinese (zh)
Inventor
吴庭
衣建中
王志伟
王佳
赵亮
胡文麟
王昊
Original Assignee
网易(杭州)网络有限公司
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 网易(杭州)网络有限公司 filed Critical 网易(杭州)网络有限公司
Priority to CN201610734332.1A priority Critical patent/CN106326124A/en
Publication of CN106326124A publication Critical patent/CN106326124A/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; 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

Abstract

The embodiment of the invention provides a coverage rate detecting method, device and equipment, wherein the method comprises the following steps: receiving program execution data sent by a server in real time, wherein the program execution data is data of a file, which is obtained by calling a data collecting function through the server, executed by the server; analyzing a line number of general codes of a source code file which corresponds to the file; and according to the program execution data and the line number of the general codes, calculating to obtain an existing coverage rate of the file. An order is not needed to be additionally increased, continuous stop and start are not needed in a detecting process, file data sent by the server is received in real time, and the file data is analyzed and processed, so that a real-time coverage rate of the server can be obtained.

Description

Coverage rate detection method, device and equipment

Technical field

The present invention relates to field of computer technology, particularly relate to a kind of coverage rate detection method, device and equipment.

Background technology

Code coverage test, be in software test procedure most important method of testing and test performance measures standard it One, coverage rate refers to ratio and the degree of tested covered code during source code performs, and generally uses percentage ratio table Show.

For different programming languages, there is the corresponding method detecting code coverage.The game of relatively main flow at present One of server architecture, is to realize based on layer building on C++ bottom and Python.Inspection currently for Python code coverage rate Survey, be most commonly used that technical scheme based on python class libraries coverage.Particularly utilize in the sys module of Python and carry For settrace function, follow the tracks of the implementation status of code, coverage data is stored in the Stack in Collector.Whenever When starting to gather, Collector constantly performs stack-incoming operation, when stopping gathering, can be obtained by Pop operations and gather Coverage rate information.

But, in software test procedure, generally require and obtain instant result feedback according to operation, by coverage rate number According to checking the execution result of test operation, when using above-mentioned test mode to carry out coverage rate test, it is necessary to test it starting After, operated by corresponding order line, obtain the output result of coverage rate, cause actual test process constantly to stop And beginning, it is impossible to meet the real-time coverage rate test needs of game server.

Summary of the invention

The embodiment of the present invention provides a kind of coverage rate detection method, device and equipment, is used for solving to use above-mentioned test side When formula carries out coverage rate test, it is necessary to after starting test, operated by corresponding order line, obtain the output of coverage rate As a result, cause actual test process constantly to stop and starting, it is impossible to meet the real-time coverage rate test of game server The problem needed.

First aspect present invention provides a kind of coverage rate detection method, including:

The program that real-time reception server sends performs data;It is server calls data collection function that program performs data The data of the file that the server obtained is carrying out;

Resolve the total code line number obtaining source code file corresponding to file;

Perform data and total code line number according to program, calculate and obtain the coverage rate that file is current.

Further, method also includes:

The coverage rate that display file is current.

Optionally, program performs data and includes the code line number that the file that server performs is performed, and performs according to program Data and total code line number, calculate and obtain the coverage rate that file is current, including:

According to the code line number being performed, obtain the line number of executed code in file;

Line number Le according to executed code and total code line number Lt, use R=Le/Lt to be calculated current the covering of file Lid rate R.

Optionally, resolve the total code line number obtaining source code file corresponding to file, including:

Source code file is carried out dissection process, rejects the blank line in source code file and comment line, obtain source code The total code line number of file.

Second aspect present invention provides a kind of coverage rate detection method, including:

During the program code performing file, call data collection function and obtain the program execution number of file in real time According to;

Program is performed data and is sent to coverage rate service end, so that coverage rate service end is real-time according to program execution data Obtain the coverage rate that file is current.

Further, method also includes:

Program is performed data store;Program performs the generation that data include that the file name of file and file are performed Code line number.

Optionally, program is performed data and stores, including:

According to file name, whether detection this locality exists the program corresponding with file performs data;

If existing, then, when there is not the code line number that file is performed in this locality, the code line number being performed by file is deposited Store up in program performs data;

Otherwise, increasing in this locality with file name is that the program that the file indexed is corresponding performs data.

Third aspect present invention provides a kind of coverage rate detection device, including:

Receiver module, the program sent for real-time reception server performs data;It is that server is adjusted that program performs data The data of the file that the server obtained with data collection function is carrying out;

Processing module, for resolving the total code line number obtaining source code file corresponding to file;

Processing module is additionally operable to perform data and total code line number according to program, calculates and obtains the coverage rate that file is current.

Further, device also includes:

Display module, for showing the coverage rate that file is current.

Optionally, program performs data and includes the code line number that the file that server performs is performed, and processing module is concrete For:

According to the code line number being performed, obtain the line number of executed code in file;

Line number Le according to executed code and total code line number Lt, use R=Le/Lt to be calculated current the covering of file Lid rate R.

Optionally, processing module also particularly useful for:

Source code file is carried out dissection process, rejects the blank line in source code file and comment line, obtain source code The total code line number of file.

Fourth aspect present invention provides a kind of coverage rate detection device, including:

Processing module, for, during the program code performing file, calling data collection function and obtain literary composition in real time The program of part performs data;

Sending module, is sent to coverage rate service end, so that coverage rate service end is according to journey for program is performed data Sequence performs data and obtains the coverage rate that file is current in real time.

Further, device also includes:

Memory module, stores for program is performed data;Program perform data include file file name and The code line number that file is performed.

Optionally, memory module specifically for:

According to the file name of file, whether detection this locality exists the program corresponding with file performs data;

If existing, then, when there is not the code line number that file is performed in this locality, the code line number being performed by file is deposited Store up in program performs data;

Otherwise, increasing in this locality with file name is that the program that the file indexed is corresponding performs data.

Fifth aspect present invention provides a kind of server, including: for storing the memorizer of programmed instruction, for controlling journey The processor of sequence instruction execution and receptor;

The program that receptor sends for real-time reception server performs data;It is server calls number that program performs data Data according to the file that the server collecting function acquisition is carrying out;

Processor is used for:

Resolve the total code line number obtaining source code file corresponding to file;

Perform data and total code line number according to program, calculate and obtain the coverage rate that file is current.

Sixth aspect present invention provides a kind of server, including: for storing the memorizer of programmed instruction, for controlling journey The processor of sequence instruction execution and transmitter;

Processor is for, during the program code performing file, calling data collection function and obtain file in real time Program performs data;

Transmitter is sent to coverage rate service end, so that coverage rate service end is held according to program for program is performed data Line number factually time obtain the current coverage rate of file.

Coverage rate detection method, device and the equipment that the embodiment of the present invention provides, server is to the clothes of coverage rate test side The business real-time router of device performs data, is then covered by the journey that the server real-time reception actuating station server of rate test side sends Sequence performs data, and carries out resolving acquisition total code line number to the source code of the file being carrying out, and performs then in conjunction with program Data and total code line number calculate and obtain the coverage rate that this document is current, it is not necessary to additionally increase order, in test process also Need not constantly stop and starting, the file data sent by real-time reception server, and this document data are carried out point Analysis processes, it is possible to obtain the real-time coverage rate of this server.

Accompanying drawing explanation

In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing In having technology to describe, the required accompanying drawing used is briefly described, it should be apparent that, the accompanying drawing in describing below is this Some bright embodiments, for those of ordinary skill in the art, on the premise of not paying creative work, it is also possible to Other accompanying drawing is obtained according to these accompanying drawings.

The flow chart of the coverage rate detection method example one that Fig. 1 provides for the embodiment of the present invention;

The flow chart of the coverage rate detection method example two that Fig. 2 provides for the embodiment of the present invention;

The flow chart of the coverage rate detection method example three that Fig. 3 provides for the embodiment of the present invention;

Fig. 4 detects the system architecture diagram of an example for the coverage rate that the embodiment of the present invention provides;

The structural representation of the coverage rate detection device embodiment one that Fig. 5 provides for the embodiment of the present invention;

The structural representation of the coverage rate detection device embodiment two that Fig. 6 provides for the embodiment of the present invention;

The structural representation of the coverage rate detection device embodiment three that Fig. 7 provides for the embodiment of the present invention;

The structural representation of the coverage rate detection device embodiment four that Fig. 8 provides for the embodiment of the present invention;

The structural representation of the server example one that Fig. 9 provides for the embodiment of the present invention;

The structural representation of the server example two that Figure 10 provides for the embodiment of the present invention.

Detailed description of the invention

For making the purpose of the embodiment of the present invention, technical scheme and advantage clearer, below in conjunction with the embodiment of the present invention In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is The a part of embodiment of the present invention rather than whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art The all other embodiments obtained under not making creative work premise, broadly fall into the scope of protection of the invention.

The flow chart of the coverage rate detection method example one that Fig. 1 provides for the embodiment of the present invention, as it is shown in figure 1, the program Executive agent be the server for detecting coverage rate, or detection coverage rate other equipment, this coverage rate detection method The step that implements be:

Step S101, the program that real-time reception server sends performs data.

In the present embodiment, program performs data is the described server that described server calls data collection function obtains The data of the file being carrying out.Here router performs the server of data is the server performing this program, such as: fortune The game server of row games.

Step S102, resolves the total code line number obtaining source code file corresponding to file.

In this programme, the server of detection coverage rate or other equipment perform the program of side execution to said procedure Source file carries out dissection process, obtains the line number of source code corresponding to file, and line number here does not include space and comment line, i.e. Obtain the total code line number of program.

Step S103, performs data and total code line number according to program, calculates and obtains the coverage rate that file is current.

In this step, this program execution data at least include that the program that can determine has performed the parameter of line number, such as: The code line number being performed, or the line number etc. performed.

The server of detection coverage rate carries out process according to the program execution data that file is corresponding and obtains currently having performed The line number of code, then according to line number and the total code line number of executed code, is calculated coverage rate.

This process is carried out in real time, the service of device (or server) the real-time reception program actuating station of detection coverage rate Device sends the program come and performs data, processes in the manner described above, can obtain the real-time coverage rate of each file.

The coverage rate detection method that the present embodiment provides, the real-time router of the server server to coverage rate test side Perform data, be then covered by the program execution data that the server real-time reception actuating station server of rate test side sends, and right The source code of the file being carrying out carries out resolving acquisition total code line number, performs data and total code line number then in conjunction with program Calculate and obtain the coverage rate that this document is current, it is not necessary to additionally increase order, also without constantly stopping in test process And beginning, the file data sent by real-time reception server, and it is analyzed this document data processing, it is possible to be somebody's turn to do The real-time coverage rate of server.

The flow chart of the coverage rate detection method example two that Fig. 2 provides for the embodiment of the present invention, as in figure 2 it is shown, above-mentioned On the basis of embodiment, it is provided that this coverage rate detection specific implementation:

Step S201, the program that real-time reception server sends performs data.

In this step, by embedding instrument in the server, obtain server in real time and obtain during file performs The program arrived performs data, and the equipment to coverage rate test side returns, and i.e. detects equipment side in this coverage rate, needs to connect in real time Receiving the program execution data that the server of running paper sends, this program performs data and includes the described file quilt that server performs The code line number performed.

Step S202, carries out dissection process to source code file, rejects the blank line in source code file and comment line, Total code line number to source code file.

In this step, only phase to the execution of certain file in the data that the equipment end of coverage rate test side receives Close data, not this document send lines of code, therefore the equipment of this coverage rate test side needs the source code to this document File resolves, and is rejected by the non-code line of the wherein independent programs such as comment line and blank line essence, and statistics obtains The total code line number of this source code file.

Step S203, according to the code line number being performed, obtains the line number of executed code in file.

According to abovementioned steps, the equipment of coverage rate test side has been received that the code line number that file is performed, then will The lines of code performed is as having performed the line number sum of code, such as: the code line number being performed got is 50, Then think that the code of this document has been carried out 50 row, or, data show that certain file, the 1st, 3-10,55 row have occurred that Execution event, then now the value of executed lines of code should be 1+8+1=10 row.Obtain in file according to this kind of mode Lines of code through performing.

Step S204, according to line number Le and total code line number Lt of executed code, uses R=Le/Lt to be calculated literary composition Coverage rate R that part is current.

In this step, complete coverage data collection by the equipment of abovementioned steps coverage rate test side, obtained The lines of code performed, and this document executable code line sum.Utilize the data that above-mentioned two step obtains, herein Use R=Le/Lt can calculate real-time coverage rate R of current file by formula.Wherein, Le represents the row of executed code Number, Lt represents total code line number.

Step S205, the coverage rate that display file is current.

This step S205 is optional step, i.e. it is not necessary to execution, at the equipment of coverage rate test side, if connect Receive the request of data that user is sent by client or front end, or be pre-configured with needs the coverage rate obtained is shown Show, then by display or front-end client, the coverage rate obtained can be shown.

The coverage rate detection method that the present embodiment provides, the file data sent by real-time reception server, and to this File data is analyzed processing, it is possible to obtains the real-time coverage rate of this server, it is not necessary to additionally increase order, was testing Also without constantly stopping and starting in journey.

The flow chart of the coverage rate detection method example three that Fig. 3 provides for the embodiment of the present invention;As it is shown on figure 3, the program The server that executive agent is running paper end or other devices, the step that implements of this coverage rate detection method is:

Step S301, during the program code performing file, calls data collection function and obtains file in real time Program performs data.

In this step, the server of running paper end embeds real-time collecting and performs the client of data, or should Real-time collecting program performs the client of data and is embedded in the program of file, during operating file, starts data acquisition Collection thread, the program obtaining this document in real time performs data.

Step S302, performs data by program and stores.

In this step, this program performs data and at least includes what the file name of described file and described file were performed Code line number.The program of collection can be performed data and enter according to file name by the server of running paper end or other devices Row storage, after there occurs new code execution event, can perform data according to file name to this program and be updated.

Concrete, the implementation storing program execution data is: according to described file name, detection this locality is The program execution data that no existence is corresponding with described file;If existing, then there is not the code that described file is performed in this locality During line number, the code line number being performed by described file is stored in described program and performs in data;If not existing, then increase in this locality In addition described file name is that the described program that the described file of index is corresponding performs data.

Above-mentioned steps S302 is optional step, is not necessarily to perform, the server of running paper end or other dresses Put the equipment that can directly send it to coverage rate test side after collecting program and performing data.

Step S303, performs program data and is sent to coverage rate service end, so that coverage rate service end is held according to program Line number factually time obtain the current coverage rate of file.

The program got execution data are sent to coverage rate by server or other devices of running paper end in real time Service end, so that the program that the service end of coverage rate test side (such as server) real-time reception actuating station server sends performs Data, and carry out the source code of the file being carrying out resolving obtaining total code line number, then in conjunction with program perform data and Total code line number calculates and obtains the current coverage rate of this document, it is not necessary to additionally increase order, in test process also without Constantly stop and starting, the file data sent by real-time reception server, and be analyzed this document data processing, The real-time coverage rate of this server can be obtained.

On the basis of above-described embodiment one to embodiment three, below with coverage rate test side for based on Twsited framework Coverage rate server, as a example by file actuating station is game server, coverage rate detection method of the present invention is illustrated.

Fig. 4 detects the system architecture diagram of an example for the coverage rate that the embodiment of the present invention provides;As shown in Figure 4, this system Framework is broadly divided into three parts, and in figure, lower section, is the core coverage rate server of the technical program, based on Twisted framework Realizing, main modular is data receiver, processes, and storage is read and sent, and major function is to collect coverage rate from game server Data also do corresponding process and storage, then carry out the displaying of the data of correspondence according to the demand of front end.

Upper right side in figure, is the test object-game server code of native system, and the collection client of native system is embedded into In all game server codes to be tested, and by starting collecting thread, data acquisition, data send three modules and complete The in real time acquisition of coverage data and be sent to coverage rate server capability.

Upper left side in figure, is the fore-end of coverage rate detection instrument, is mainly used in showing corresponding coverage data.

Game server end (the test object-game server code of native system):

For detecting the client that program performs the instrument of data, it is used for being embedded in game server code, and obtains Being sent to coverage rate utility services end after the data (namely program execution data) that real-time coverage rate is relevant, the most above-mentioned covers Lid rate server.Data collection function is realized by three modules, is to start collecting thread respectively, and data collection, data send.

When game server starts, start collecting thread (websocket is connected to coverage rate server) simultaneously and open Beginning data acquisition, concrete data acquisition is as follows:

First, utilize sys.settrace function, obtain and be currently performed the filename of file and the code line of execution Number, specific code is as follows:

Wherein, by the frame (stack frame) of python, can obtain filename filename is frame.f_code.co_ Filename, and code line number lineno being performed currently traced into is frame.f_lineno.

Then, data are collected by data collection (the collect function in code) functional module.

As shown in Figure 4, when carrying out data collection, by data, with dictionary, (the entitled key of file, the code line number of executed is Value) form storage, after there occurs new code execution event, get the current name performing file by sys.settrace Whether the code line number claimed and be performed, next have the value of file name index, if it is not, add in search data File name;If existing, then judge that the current code line number performed the most in data, is the most then added.

Finally, the program that previous step is collected by the data sending function module of game server side performs data, presses According to specifying time interval (such as 1s) by websocket thread, it is sent to coverage rate server.

Coverage rate server end:

Coverage rate utility services end is responsible for collecting and processing data, has a following function:

First, receive the program of game server and perform Data Data, the data that will receive, according to ip address and Game server title, stores respectively.

Secondly, carry out data process, in the data collected, the code line set that only certain file is performed, but do not have There is total lines of code.Now in coverage rate server side, by sound code file is resolved, i.e. get rid of comment line and blank The non-code lines such as row, count the sum of code line.

Finally, coverage rate calculating is carried out, it is known that game server coverage rate computing formula is:Wherein, Rate represents coverage rate, lineexecutsRepresent the lines of code performed in current file, linetotalExpression ought be above The executable lines of codes sum of part.

According to the coverage data received before, it is known that certain pyc file, the lines of code performed is exactly it In the data transmitted, perform the line number sum of code.Such as, data show that certain py file, the 1st, 3-10,55 row have been sent out Give birth to execution event, then now the value of executed lines of code should be 1+8+1=10 row.

By the coverage data collection of game server, it is thus achieved that lineexecute, the most executed code line Number.Parsing by local source code, it is thus achieved that linetotal, namely current file executable code line sum.Utilize above-mentioned The data that two steps obtain, can calculate the real-time coverage rate of current file herein by formula.

Finally, when there is request of data front end, the real-time coverage rate calculated is sent to front end by websocket and enters Row display.

Front end, after receiving coverage rate, can show coverage rate situation by webpage in real time.Display in concrete webpage Content includes: first, the bibliographic structure of game server (collection client) source code, shows the literary composition corresponding to each catalogue level Part folder and file.Second, the real-time code coverage rate situation of each file.

Coverage data can be obtained in real time, it is also possible to simultaneously to multiple runtime servers or program by such scheme The coverage rate running client is acquired.

The structural representation of the coverage rate detection device embodiment one that Fig. 5 provides for the embodiment of the present invention, as it is shown in figure 5, The coverage rate detection device 10 that the present embodiment provides includes:

Receiver module 11, the program sent for real-time reception server performs data;It is institute that described program performs data State the data of file that the described server that server calls data collection function obtains is carrying out;

Processing module 12, for resolving the total code line number obtaining source code file corresponding to described file;

Described processing module 12 is additionally operable to perform data and described total code line number according to described program, calculates described in obtaining The coverage rate that file is current.

The coverage rate detection device that the present embodiment provides, for performing coverage rate in the method that aforementioned any embodiment provides The technical scheme of test side, it is similar with technique effect that it realizes principle, does not repeats them here.

In the embodiment two of coverage rate of the present invention detection device, the coverage rate detection that Fig. 6 provides for the embodiment of the present invention The structural representation of device embodiment two, as shown in Figure 6, on the basis of above-described embodiment one, this coverage rate detection device 10 Also include:

Display module 13, for showing the described coverage rate that described file is current.

On the basis of any of the above-described embodiment, optionally, described program execution data include what described server performed The code line number that described file is performed, described processing module 12 specifically for:

According to the described code line number being performed, obtain the line number of executed code in described file;

Line number Le according to described executed code and described total code line number Lt, use R=Le/Lt to be calculated described Coverage rate R that file is current.

Optionally, described processing module 12 also particularly useful for:

Described source code file is carried out dissection process, rejects the blank line in described source code file and comment line, Described total code line number to described source code file.

The coverage rate detection device that the present embodiment provides, is used for performing coverage rate in the method that aforementioned any embodiment provides The technical scheme of test side, it is similar with technique effect that it realizes principle, does not repeats them here.

The structural representation of the coverage rate detection device embodiment three that Fig. 7 provides for the embodiment of the present invention, as it is shown in fig. 7, This coverage rate detection device 20 includes:

Processing module 21, for, during the program code performing file, calling data collection function and obtain in real time The program of described file performs data;

Sending module 22, for described program execution data are sent to coverage rate service end, so that described coverage rate clothes Business end performs data according to described program and obtains the coverage rate that described file is current in real time.

The coverage rate detection device that the present embodiment provides, is used for performing the method Program fortune that aforementioned any embodiment provides The technical scheme of row side, it is similar with technique effect that it realizes principle, does not repeats them here.

The structural representation of the coverage rate detection device embodiment four that Fig. 8 provides for the embodiment of the present invention, as shown in Figure 8, This coverage rate detection device 20 also includes:

Memory module 23, for storing described program execution data;Described program performs data and includes described literary composition The code line number that the file name of part and described file are performed.

On the basis of above-described embodiment three and embodiment four, described memory module 23 specifically for:

According to the file name of described file, whether detection this locality exists the program corresponding with described file performs data;

If existing, then when there is not the code line number that described file is performed in this locality, the generation that described file is performed Code line number is stored in described program and performs in data;

Otherwise, increasing in this locality with described file name is that the described program that the described file indexed is corresponding performs data.

The coverage rate detection device that the present embodiment provides, is used for performing the method Program fortune that aforementioned any embodiment provides The technical scheme of row side, it is similar with technique effect that it realizes principle, does not repeats them here.

The structural representation of the server example one that Fig. 9 provides for the embodiment of the present invention, as it is shown in figure 9, this server Can be embodied in methods that: have program stored therein instruction memorizer 31, receptor 32 and for control programmed instruction perform Processor 33;

The program that described receptor 32 sends for real-time reception server performs data;It is institute that described program performs data State the data of file that the described server that server calls data collection function obtains is carrying out;

Described processor 33 is used for:

Resolve the total code line number obtaining source code file corresponding to described file;

Perform data and described total code line number according to described program, calculate and obtain the coverage rate that described file is current.

Optionally, it is also possible to include display, for showing the described coverage rate that described file is current.

Optionally, described program performs data and includes the code line number that the described file that described server performs is performed, Described processor 33 specifically for:

According to the described code line number being performed, obtain the line number of executed code in described file;

Line number Le according to described executed code and described total code line number Lt, use R=Le/Lt to be calculated described Coverage rate R that file is current.

Optionally, described processor 33 also particularly useful for:

Described source code file is carried out dissection process, rejects the blank line in described source code file and comment line, Described total code line number to described source code file.

The server that the present embodiment provides is the server covering test side, is used for performing what aforementioned any embodiment provided The technical scheme of coverage rate test side in method, it is similar with technique effect that it realizes principle, does not repeats them here.

The structural representation of the server example two that Figure 10 provides for the embodiment of the present invention, as shown in Figure 10, this service Device can be embodied in methods that: for storing the memorizer 41 of programmed instruction, for controlling the processor 42 that programmed instruction performs And transmitter 43;

Described processor 42 is for, during the program code performing file, calling data collection function and obtain in real time The program of described file performs data;

Described transmitter 43 is for being sent to coverage rate service end by described program execution data, so that described coverage rate clothes Business end performs data according to described program and obtains the coverage rate that described file is current in real time.

Optionally, memorizer 41 is for storing described program execution data;Described program performs data and includes institute State the file name of file and code line number that described file is performed.

Optionally, described memorizer 41 specifically for:

According to the file name of described file, whether detection this locality exists the program corresponding with described file performs data;

If existing, then when there is not the code line number that described file is performed in this locality, the generation that described file is performed Code line number is stored in described program and performs in data;

Otherwise, increasing in this locality with described file name is that the described program that the described file indexed is corresponding performs data.

The server that the present embodiment provides is program runtime server, is used for performing the method that aforementioned any embodiment provides Program runs the technical scheme of side, such as game server, and it is similar with technique effect that it realizes principle, does not repeats them here.

In the embodiment of any of the above-described server, it should be appreciated that processor can be CPU (English: Central Processing Unit, is called for short: CPU), it is also possible to be other general processors, digital signal processor (English: Digital Signal Processor, is called for short: DSP), special IC (English: Application Specific Integrated Circuit, is called for short: ASIC) etc..General processor can be microprocessor or this processor can also be The processor etc. of any routine.Step in conjunction with the method disclosed in the embodiment of the present invention can be embodied directly in hardware processor Execution completes, or completes with the hardware in processor and software module combination execution.

One of ordinary skill in the art will appreciate that: all or part of step realizing above-mentioned each method embodiment can be led to The hardware crossing programmed instruction relevant completes.Aforesaid program can be stored in a computer read/write memory medium.This journey Sequence upon execution, performs to include the step of above-mentioned each method embodiment;And aforesaid storage medium includes: read only memory (English Literary composition: read-only memory, abbreviation: ROM), RAM, flash memory, hard disk, solid state hard disc, tape (English: magnetic Tape), floppy disk (English: floppy disk), CD (English: optical disc) and combination in any.

Last it is noted that various embodiments above is only in order to illustrate technical scheme, it is not intended to limit;To the greatest extent The present invention has been described in detail by pipe with reference to foregoing embodiments, it will be understood by those within the art that: it depends on So the technical scheme described in foregoing embodiments can be modified, or the most some or all of technical characteristic is entered Row equivalent;And these amendments or replacement, do not make the essence of appropriate technical solution depart from various embodiments of the present invention technology The scope of scheme.

Claims (16)

1. a coverage rate detection method, it is characterised in that including:
The program that real-time reception server sends performs data;It is described server calls data collection that described program performs data The data of the file that the described server that function obtains is carrying out;
Resolve the total code line number obtaining source code file corresponding to described file;
Perform data and described total code line number according to described program, calculate and obtain the coverage rate that described file is current.
Method the most according to claim 1, it is characterised in that described method also includes:
Show the described coverage rate that described file is current.
Method the most according to claim 1 and 2, it is characterised in that described program performs data and includes that described server is held The code line number that the described file of row is performed, described according to described program execution data and described total code line number, calculating obtains Take the coverage rate that described file is current, including:
According to the described code line number being performed, obtain the line number of executed code in described file;
Line number Le according to described executed code and described total code line number Lt, use R=Le/Lt to be calculated described file Current coverage rate R.
Method the most according to claim 1 and 2, it is characterised in that described parsing obtains the source code that described file is corresponding The total code line number of file, including:
Described source code file is carried out dissection process, rejects the blank line in described source code file and comment line, obtain institute State the described total code line number of source code file.
5. a coverage rate detection method, it is characterised in that including:
During the program code performing file, call data collection function and obtain the program execution number of described file in real time According to;
Described program execution data are sent to coverage rate service end, so that described coverage rate service end performs according to described program Data obtain the coverage rate that described file is current in real time.
Method the most according to claim 5, it is characterised in that described method also includes:
Described program execution data are stored;Described program performs data and includes the file name of described file and described literary composition The code line number that part is performed.
Method the most according to claim 6, it is characterised in that described by described program execution data store, including:
According to described file name, whether detection this locality exists the program corresponding with described file performs data;
If existing, then when there is not the code line number that described file is performed in this locality, the code line that described file is performed Number it is stored in described program to perform in data;
Otherwise, increasing in this locality with described file name is that the described program that the described file indexed is corresponding performs data.
8. a coverage rate detection device, it is characterised in that including:
Receiver module, the program sent for real-time reception server performs data;It is described service that described program performs data Device calls the data of file that the described server that data collection function obtains is carrying out;
Processing module, for resolving the total code line number obtaining source code file corresponding to described file;
Described processing module is additionally operable to perform data and described total code line number according to described program, calculates the described file of acquisition and works as Front coverage rate.
Device the most according to claim 8, it is characterised in that described device also includes:
Display module, for showing the described coverage rate that described file is current.
Device the most according to claim 8 or claim 9, it is characterised in that described program performs data and includes that described server is held The code line number that is performed of described file of row, described processing module specifically for:
According to the described code line number being performed, obtain the line number of executed code in described file;
Line number Le according to described executed code and described total code line number Lt, use R=Le/Lt to be calculated described file Current coverage rate R.
11. devices according to claim 8 or claim 9, it is characterised in that described processing module also particularly useful for:
Described source code file is carried out dissection process, rejects the blank line in described source code file and comment line, obtain institute State the described total code line number of source code file.
12. 1 kinds of coverage rate detection devices, it is characterised in that including:
Processing module, for, during the program code performing file, calling data collection function and obtain described literary composition in real time The program of part performs data;
Sending module, for described program execution data are sent to coverage rate service end, so that described coverage rate service end root Perform data according to described program and obtain the coverage rate that described file is current in real time.
13. devices according to claim 12, it is characterised in that described device also includes:
Memory module, for storing described program execution data;Described program performs data and includes the literary composition of described file The code line number that part title and described file are performed.
14. devices according to claim 13, it is characterised in that described memory module specifically for:
According to the file name of described file, whether detection this locality exists the program corresponding with described file performs data;
If existing, then when there is not the code line number that described file is performed in this locality, the code line that described file is performed Number it is stored in described program to perform in data;
Otherwise, increasing in this locality with described file name is that the described program that the described file indexed is corresponding performs data.
15. 1 kinds of servers, it is characterised in that including: for storing the memorizer of programmed instruction, holding for controlling programmed instruction The processor of row and receptor;
The program that described receptor sends for real-time reception server performs data;It is described service that described program performs data Device calls the data of file that the described server that data collection function obtains is carrying out;
Described processor is used for:
Resolve the total code line number obtaining source code file corresponding to described file;
Perform data and described total code line number according to described program, calculate and obtain the coverage rate that described file is current.
16. 1 kinds of servers, it is characterised in that including: for storing the memorizer of programmed instruction, holding for controlling programmed instruction The processor of row and transmitter;
Described processor is for, during the program code performing file, calling data collection function and obtain described literary composition in real time The program of part performs data;
Described transmitter is for being sent to coverage rate service end by described program execution data, so that described coverage rate service end root Perform data according to described program and obtain the coverage rate that described file is current in real time.
CN201610734332.1A 2016-08-25 2016-08-25 Coverage rate detecting method, device and equipment CN106326124A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610734332.1A CN106326124A (en) 2016-08-25 2016-08-25 Coverage rate detecting method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610734332.1A CN106326124A (en) 2016-08-25 2016-08-25 Coverage rate detecting method, device and equipment

Publications (1)

Publication Number Publication Date
CN106326124A true CN106326124A (en) 2017-01-11

Family

ID=57790724

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610734332.1A CN106326124A (en) 2016-08-25 2016-08-25 Coverage rate detecting method, device and equipment

Country Status (1)

Country Link
CN (1) CN106326124A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101464829A (en) * 2007-12-18 2009-06-24 珠海金山软件股份有限公司 Method and test device for confirming code coverage rate
CN102938040A (en) * 2012-09-29 2013-02-20 中兴通讯股份有限公司 Malicious Android application program detection method, system and device
CN103365771A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Method and equipment for obtaining code coverage rate
CN103699476A (en) * 2012-09-27 2014-04-02 腾讯科技(深圳)有限公司 Coverage rate testing method and system
CN104063321A (en) * 2014-06-27 2014-09-24 北京控制工程研究所 Test verifying system and test verifying method for microblaze soft-core program
US20150169435A1 (en) * 2013-12-12 2015-06-18 Tencent Technology (Shenzhen) Company Limited Method and apparatus for mining test coverage data
CN105404585A (en) * 2015-12-01 2016-03-16 腾讯科技(深圳)有限公司 Method and apparatus for acquiring code coverage rate

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101464829A (en) * 2007-12-18 2009-06-24 珠海金山软件股份有限公司 Method and test device for confirming code coverage rate
CN103365771A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Method and equipment for obtaining code coverage rate
CN103699476A (en) * 2012-09-27 2014-04-02 腾讯科技(深圳)有限公司 Coverage rate testing method and system
CN102938040A (en) * 2012-09-29 2013-02-20 中兴通讯股份有限公司 Malicious Android application program detection method, system and device
US20150169435A1 (en) * 2013-12-12 2015-06-18 Tencent Technology (Shenzhen) Company Limited Method and apparatus for mining test coverage data
CN104063321A (en) * 2014-06-27 2014-09-24 北京控制工程研究所 Test verifying system and test verifying method for microblaze soft-core program
CN105404585A (en) * 2015-12-01 2016-03-16 腾讯科技(深圳)有限公司 Method and apparatus for acquiring code coverage rate

Similar Documents

Publication Publication Date Title
RU2419986C2 (en) Combining multiline protocol accesses
KR20090055584A (en) Persistent saving portal
US8364463B2 (en) Optimizing a language/media translation map
US7543189B2 (en) Automated multilingual software testing method and apparatus
JP5325169B2 (en) Web application operation reproduction method and system
CN102135992A (en) Terminal application program classifying method and terminal
JP5753350B2 (en) Method and computer program for enhancing screen capture function for form manipulation
EP1576487B1 (en) Web server hit multiplier and redirector
US9886375B2 (en) Automated execution of functional test scripts on a remote system within a unit testing framework
CN102164045B (en) Parameterized computer monitor system and method
US9489234B2 (en) Dynamically adjusting a log level of a transaction
JP2006174157A (en) Reliability verification program and reliability verification method
US9632916B2 (en) Method and apparatus to semantically connect independent build and test processes
JP5483965B2 (en) Web application operation recording / reproducing method and system
US8171406B1 (en) Automating user interface navigation
CN101408862B (en) Embedded system test method
US8972374B2 (en) Content acquisition system and method of implementation
CN102483700B (en) Lightweight service based on dynamic binary rewriter framework
US10114148B2 (en) Heterogeneous log analysis
CN102831052B (en) Test exemple automation generating apparatus and method
US9727407B2 (en) Log analytics for problem diagnosis
CN101853300A (en) Method and system for identifying and evaluating video downloading service website
US8880588B2 (en) Technique for stateless distributed parallel crawling of interactive client-server applications
CN104598380A (en) Method and system for automatic testing based on control
US20150339388A1 (en) Collection of Telemetry Data by a Telemetry Library Within a Client Device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
C10 Entry into substantive examination