CN107797923A - Code coverage rate analysis method and application server - Google Patents

Code coverage rate analysis method and application server Download PDF

Info

Publication number
CN107797923A
CN107797923A CN201710933579.0A CN201710933579A CN107797923A CN 107797923 A CN107797923 A CN 107797923A CN 201710933579 A CN201710933579 A CN 201710933579A CN 107797923 A CN107797923 A CN 107797923A
Authority
CN
China
Prior art keywords
source code
logic branch
function
code
application server
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
CN201710933579.0A
Other languages
Chinese (zh)
Other versions
CN107797923B (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 Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201710933579.0A priority Critical patent/CN107797923B/en
Priority to PCT/CN2018/076141 priority patent/WO2019071891A1/en
Publication of CN107797923A publication Critical patent/CN107797923A/en
Application granted granted Critical
Publication of CN107797923B publication Critical patent/CN107797923B/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

Abstract

The invention discloses a kind of code coverage rate analysis method, this method includes:When receiving the program source code that the terminal device is sent, the structure of the source code is analyzed;According to the function logic branch of source code described in the structural generation of the source code;By the function logic branch of the source code compared with the test event logic branch for being pre-stored in the application server;The function logic branch covering rate that the source code is generated according to comparative result is reported;Function logic branch covering rate report is fed back into terminal device.The present invention also provides a kind of application server and computer-readable recording medium.Code coverage rate analysis method, application server and computer-readable recording medium provided by the invention can confirm that whether source code has covered all function logic branches, ensure the functional completeness of test event.

Description

Code coverage rate analysis method and application server
Technical field
The present invention relates to code tester technical field, more particularly to a kind of code coverage rate analysis method and application service Device.
Background technology
Code coverage (codecoverage) is to reflect important indicator of the test case to tested program level of coverage, It is a reference value for weighing test completeness.It can be assessed and be tested whether fully by code coverage data.Opened in software During hair, it is whole code buildings based on monitored project to obtain code coverage data by client.Tradition Test coverage analysis both for code line coverage condition, counted by code coverage, we will appreciate that program In how many code be performed, but can not really understand the complete coverage condition of a program module.
The content of the invention
In view of this, the present invention proposes a kind of code coverage rate analysis method and application server, is able to confirm that source code All function logic branches whether have been covered, have ensured the functional completeness of test event.
First, to achieve the above object, the present invention proposes a kind of code coverage rate analysis method, and this method is applied to application Server, methods described include:
When receiving the program source code of terminal device transmission, the structure of the source code is analyzed;
According to the function logic branch of source code described in the structural generation of the source code;
By the function logic branch of the source code and the test event logic branch for being pre-stored in the application server It is compared;
The function logic branch covering rate that the source code is generated according to comparative result is reported;
Function logic branch covering rate report is fed back into the terminal device.
Alternatively, it is described the step of the logic branch of source code, specifically to be wrapped according to the structural generation of the source code Include following steps:
The structure of the source code is analyzed, forms the syntax tree of the source code;
According to the syntax tree locating function function and the call relation with power function;
According to the call relation of the power function, the logic branch of the source code is generated.
Alternatively, the function logic branch by the source code patrols with being pre-stored in the test cases of application server Volume branch is compared, and before the step of generating the function logic branch covering rate report of the source code, includes walking as follows Suddenly:
When receiving the program source code that the terminal device is sent, the mark of the source code is obtained;
The test event logic branch of the application server is pre-stored according to the mark matching;
Transfer the test event logic branch.
Alternatively, the step of function logic branch covering rate report of the generation source code, is specifically included:
Judge whether the function logic branch of the source code all covers the test event logic branch;
When the function logic branch of the source code is without all the test event logic branch is covered, mark does not cover The test event logic branch of lid;
Generation includes the function logic branch covering rate report for being labeled with unlapped test event logic branch.
Alternatively, methods described also includes:
Set a memory space;
The function logic branch covering rate report and the source code are stored to the memory space.
In addition, to achieve the above object, the present invention also provides a kind of application server, the application server includes storage Device, processor, the code coverage rate analysis system that can be run on the processor, the code are stored with the memory Following steps are realized when coverage rate analysis system is by the computing device:
When receiving the program source code of terminal device transmission, the structure of the source code is analyzed;
According to the function logic branch of source code described in the structural generation of the source code;
By the function logic branch of the source code and the test event logic branch for being pre-stored in the application server It is compared;
The function logic branch covering rate that the source code is generated according to comparative result is reported;
Function logic branch covering rate report is fed back into the terminal device.
Alternatively, it is described the step of the logic branch of source code, specifically to be wrapped according to the structural generation of the source code Include following steps:
The structure of the source code is analyzed, forms the syntax tree of the source code;
According to the syntax tree locating function function and the call relation with power function;
According to the call relation of the power function, the logic branch of the source code is generated.
Alternatively, the function logic branch by the source code patrols with being pre-stored in the test cases of application server Volume branch is compared, and before the step of generating the function logic branch covering rate report of the source code, includes walking as follows Suddenly:
When receiving the program source code that the terminal device is sent, the mark of the source code is obtained;
The test event logic branch of the application server is pre-stored according to the mark matching;
Transfer the test event logic branch.
Alternatively, the step of function logic branch covering rate report of the generation source code, is specifically included:
Judge whether the function logic branch of the source code all covers the test event logic branch;
When the function logic branch of the source code is without all the test event logic branch is covered, mark does not cover The test event logic branch of lid;
Generation includes the function logic branch covering rate report for being labeled with unlapped test event logic branch.
Further, to achieve the above object, the present invention also provides a kind of computer-readable recording medium, the computer Readable storage medium storing program for executing is stored with code coverage rate analysis system, and the code coverage rate analysis system can be by least one processor Perform, so that the step of at least one computing device code coverage rate analysis method described above.
Compared to prior art, application server proposed by the invention, code coverage rate analysis method and computer can Storage medium is read, first when receiving the program source code that the terminal device is sent, analyzes the structure of the source code;So Afterwards, according to the structural generation of the source code source code function logic branch;Further, by the work(of the source code Energy logic branch is compared with the test event logic branch for being pre-stored in the application server;Then, according to compare knot Fruit generates the function logic branch covering rate report of the source code;Finally the function logic branch covering rate is reported and fed back To terminal device.So, it can both avoid counting by code coverage in the prior art, how many is only capable of recognizing in program Code be performed, but the defects of can not really understand the complete coverage condition of program module, it is also possible that By the comparison of logic branch, confirm whether source code has covered all function logic branches, ensure test event Functional completeness.
Brief description of the drawings
Fig. 1 is each optional application environment schematic diagram of embodiment one of the present invention;
Fig. 2 is the schematic diagram of one optional hardware structure of application server in Fig. 1;
Fig. 3 is the program module schematic diagram of code coverage rate analysis system first embodiment of the present invention;
Fig. 4 is the program module schematic diagram of code coverage rate analysis system second embodiment of the present invention;
Fig. 5 is the program module schematic diagram of code coverage rate analysis system 3rd embodiment of the present invention;
Fig. 6 is the schematic flow sheet of code coverage rate analysis method first embodiment of the present invention;
Fig. 7 is the schematic flow sheet of code coverage rate analysis method second embodiment of the present invention;
Fig. 8 is the schematic flow sheet of code coverage rate analysis method 3rd embodiment of the present invention.
Reference:
Terminal device 1
Application server 2
Network 3
Memory 11
Processor 12
Network interface 13
Code coverage rate analysis system 200
Analysis module 201
Generation module 202
Comparison module 203
Feedback module 204
Acquisition module 205
Matching module 206
Transfer module 207
Judge module 208
Labeling module 209
The realization, functional characteristics and advantage of the object of the invention will be described further referring to the drawings in conjunction with the embodiments.
Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, it is right below in conjunction with drawings and Examples The present invention is further elaborated.It should be appreciated that specific embodiment described herein is only to explain the present invention, not For limiting the present invention.Based on the embodiment in the present invention, those of ordinary skill in the art are not before creative work is made The every other embodiment obtained is put, belongs to the scope of protection of the invention.
It should be noted that the description for being related to " first ", " second " etc. in the present invention is only used for describing purpose, and can not It is interpreted as indicating or implies its relative importance or imply the quantity of the technical characteristic indicated by indicating.Thus, define " the One ", at least one this feature can be expressed or be implicitly included to the feature of " second ".In addition, the skill between each embodiment Art scheme can be combined with each other, but must can be implemented as basis with those of ordinary skill in the art, when technical scheme With reference to occurring conflicting or will be understood that the combination of this technical scheme is not present when can not realize, also not in application claims Protection domain within.
As shown in fig.1, it is each optional application environment schematic diagram of embodiment one of the present invention.
In the present embodiment, present invention can apply to include but not limited to, terminal device 1, application server 2, network In 3 application environment.Wherein, the terminal device 1 can be that mobile phone, smart phone, notebook computer, digital broadcasting connect Receive device, PDA (personal digital assistant), PAD (tablet personal computer), PMP (portable media player), guider etc. can Mobile device, and the fixed terminal of such as digital TV, desktop computer, notebook, server etc..The application server 2 can be the computing devices such as rack-mount server, blade server, tower server or Cabinet-type server, the application clothes Business device 2 can be the server cluster that independent server or multiple servers are formed.The network 3 can be Intranet (Intranet), internet (Internet), global system for mobile communications (Global System of Mobile communication, GSM), WCDMA (Wideband Code Division Multiple Access, WCDMA), 4G networks, 5G networks, bluetooth (Bluetooth), the wirelessly or non-wirelessly network such as Wi-Fi.
Wherein, communicated respectively with one or more terminal devices 1 by the network 3 in the application server 2 Connection, to carry out data transmission and interact.
In the present embodiment, installed in the application server 2 and run code coverage rate analysis system 200, when described When code coverage rate analysis system 200 is run, the application server 2 receives the program source generation that the terminal device 1 is sent During code, the structure of the source code is analyzed;Then, the function logic of source code according to the structural generation of the source code divides Branch;Further, by the function logic branch of the source code and the test event logic for being pre-stored in the application server Branch is compared;Then, the function logic branch covering rate for the source code being generated according to comparative result is reported;Finally by institute State the report of function logic branch covering rate and feed back to terminal device 1.So, can both avoid passing through code coverage in the prior art Rate counts, and is only capable of recognizing in program that how many code is performed, but can not really understand program module The defects of complete coverage condition, it is also possible that by the comparison of logic branch, it is all to confirm whether source code has covered Function logic branch, ensure the functional completeness of test event.
As shown in fig.2, it is the schematic diagram of 2 one optional hardware structure of application server in Fig. 1.In the present embodiment, institute Stating application server 2 may include, but be not limited only to, and connection memory 11, processor 12, net can be in communication with each other by system bus Network interface 13.It is pointed out that Fig. 2 illustrate only the terminal device 1 with component 11-13, it should be understood that not It is required that implement all components shown, the more or less component of the implementation that can be substituted.
Wherein, the memory 11 comprises at least a type of readable storage medium storing program for executing, and the readable storage medium storing program for executing includes Flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memories etc.), random access storage device (RAM), it is static with Machine access memory (SRAM), read-only storage (ROM), Electrically Erasable Read Only Memory (EEPROM), it is programmable only Read memory (PROM), magnetic storage, disk, CD etc..In certain embodiments, the memory 11 can be described answers With the hard disk or internal memory of the internal storage unit of server 2, such as the application server 2.In further embodiments, it is described to deposit Reservoir 11 can also be that the plug-in type being equipped with the External memory equipment of the application server 2, such as the application server 2 is hard Disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..Certainly, the memory 11 can also both include the internal storage unit of the application server 2 or wrap Include its External memory equipment.In the present embodiment, the memory 11 is generally used for the behaviour that storage is installed on the application server 2 Make system and types of applications software, such as program code of the code coverage rate analysis system 200 etc..In addition, the storage Device 11 can be also used for temporarily storing the Various types of data that has exported or will export.
The processor 12 can be in certain embodiments central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor or other data processing chips.The processor 12 is generally used for should described in control With the overall operation of server 2, such as perform the control related with the terminal device 1 progress data interaction or communication and place Reason etc..In the present embodiment, the processor 12 is used to run the program code stored in the memory 11 or processing data, Such as run described code coverage rate analysis system 200 etc..
The network interface 13 may include radio network interface or wired network interface, and the network interface 13 is generally used for Communication connection is established between the application server 2 and other electronic equipments.In the present embodiment, the network interface 13 is mainly used In the application server 2 is connected with one or more terminal devices 1 by the network 3, in the application service Data transmission channel and communication connection are established between device 2 and one or more of terminal devices 1.
So far, oneself is through describing the application environment of each embodiment of the present invention and the hardware configuration and work(of relevant device in detail Energy.Below, above-mentioned application environment and relevant device will be based on, proposes each embodiment of the present invention.
First, the present invention proposes a kind of code coverage rate analysis system 200.
As shown in fig.3, it is the Program modual graph of the first embodiment of code coverage rate analysis system 200 of the present invention.
In the present embodiment, the code coverage rate analysis system 200 includes a series of meter being stored on memory 11 Calculation machine programmed instruction, when the computer program instructions are performed by processor 12, it is possible to achieve the code of various embodiments of the present invention Coverage rate analysis operates.In certain embodiments, the specific operation realized based on the computer program instructions each several part, generation Code coverage rate analysis system 200 can be divided into one or more modules.For example, in figure 3, the code coverage rate analysis System 200 can be divided into analysis module 201, generation module 202, comparison module 203 and feedback module 204.Wherein:
The analysis module 201, for when receiving the program source code that the terminal device 1 is sent, described in analysis The structure of source code.
Normally, the coverage rate analysis of traditional test program code both for code line coverage condition, but this Kind can understand that how many code in program is performed, and can not just represent one by the coverage condition of code analysis row The complete coverage condition of functional unit.Assuming that One function unit needs to call 4 combination of function to complete according to different condition This function.If the function can form 16 logic branches, and counted by code line coverage rate, source code, which only needs to write 4, patrols Collecting branch just can all override 4 functions, but from functional completeness, the functional unit is incomplete.
For example, the function of the source code is to complete user name registration, and the user for completing registration can have inhomogeneity The landing approach of type, each landing approach are One function logic branch.For example, by call function A, realize that user can be with Authentication code is sent by phone number to log in, call function B, realize that user can activate link by mailbox and log in, can be with Call function A and function B simultaneously, authentication code is sent by phone number while realizing and activate link by mailbox and logged in, this In the case of kind, if according to the covering analyzing of traditional test program code, function A and the function in program can only be analyzed B is called, and can not analyze while call function A and function B this logic branch, so as to cause test cases function occur Cover incomplete situation.
Therefore, in the present embodiment, the application server 2 establishes long connection with the terminal device 1, when the application Server 2 analyzes the knot of the source code by analysis module 201 when receiving the program source code of the transmission of terminal device 1 Structure, specifically, the call relation of analytic function and method, the inclusion relation, the inheritance of class etc. of structure.
The generation module 202, the function logic branch for source code described in the structural generation according to the source code.
Specifically, according to the structure of the source code, the power function that each functional unit calls is analyzed, and often The call relation of One function function, and then generate function logic branch of the source code on realizing each function.
In the present embodiment, the application server 2 analyzes the structure of the source code, forms the grammer of the source code Tree.According to the syntax tree locating function function and the call relation with power function, while remove annotation and need not unite Count public function of coverage rate information etc., locating function function, the call relation of analytic function function.According to the power function Call relation, generate the logic branch of the source code.
The comparison module 203, for the function logic branch of the source code and the application service will to be pre-stored in The test event logic branch of device is compared.
Normally, developer necessarily understands the function of software to be developed when carrying out source code design.In the present embodiment In, in order to verify the source code integrality, there is the application in advance and take by developer in the logic branch that source code needs The memory space of business device.In the present embodiment, when generating the logic branch of the source code, the application server 2 is adjusted The function logic branch for the software to be developed being previously stored with, and the function of the logic branch of source code and software to be developed is patrolled Collect branch and carry out com-parison and analysis, the function logic branch covering rate is analyzed by comparative result.
The generation module 202, it is additionally operable to generate the function logic branch covering rate of the source code according to comparative result Report.
Specifically, the application server 2 generates the source code by the generation module 202 according to comparative result Function logic branch covering rate is reported.In the present embodiment, the logic branch coverage rate report includes identifying having covered Function and function logic branch and the function that is not covered with and function logic branch.
The feedback module 204, for function logic branch covering rate report to be fed back into terminal device 1.
Specifically, the application server 2 sends function logic branch coverage report to the web of terminal device 1 The page shows, developer can according to the function logic branch covering rate report check source code integrality, i.e., Whether the source code has covered all function logic branches, if any omission, you can carries out specific aim modification.
In the present embodiment, the application server 2 also sets a memory space, and stores the function logic branch and cover Lid rate is reported and the source code is to the memory space, is easy to developer to access the function logic point from memory space Branch coverage rate is reported and the source code, the design progress for the source code that follows up.
By said procedure module 201-204, code coverage rate analysis system 200 proposed by the invention, first when connecing When receiving the program source code that the terminal device 1 is sent, the structure of the source code is analyzed;Then, according to the source code Structural generation described in source code function logic branch;Further, by the function logic branch of the source code with prestoring The test event logic branch stored up in the application server is compared;Then, the source code is generated according to comparative result Function logic branch covering rate report;Function logic branch covering rate report is finally fed back into terminal device 1.This It sample, can both avoid counting by code coverage in the prior art, be only capable of recognizing in program that how many code is performed , but the defects of can not really understand the complete coverage condition of program module, it is also possible that passing through logic branch Comparison, confirm source code whether covered all function logic branches, ensure the functional completeness of test event.
Further, the above-mentioned first embodiment based on code coverage rate analysis system 200 of the present invention, propose the present invention's Second embodiment (as shown in Figure 4).In the present embodiment, the code coverage rate analysis system 200 also includes acquisition module 205, Matching module 206 and module 207 is transferred, wherein,
The acquisition module 205, for when receiving the program source code that the terminal device 1 is sent, described in acquisition The mark of source code.
The matching module 206, for being pre-stored in the test event of the application server according to the mark matching Logic branch.
Specifically, the application server 2 can receive multiple different source codes, and each source code can have corresponding The test event logic branch being pre-stored in the internal memory of application server 2.In order to distinguish each source code, each source code There is specific mark, the test event logic branch is provided with mark corresponding with source code.When the application server 2 When receiving from the source code that terminal device 1 is sent, the mark of the source code is obtained by acquisition module 205, and then The test event logic branch of the application server 2 is pre-stored in by identifying matching with module 206, so that it is determined that corresponding Test event logic branch.
It is described to transfer module 207, for transferring the test event logic branch.
Specifically, the application server 2 transfers the test event logic branch by the module 207 of transferring, and enters And compared with the function logic branch of source code.
By said procedure module 205-207, code coverage rate analysis system 200 proposed by the invention can be by obtaining The mark of the source code is taken, and then matches the test event logic branch being pre-stored in the application server 2, with never Test event logic branch corresponding with the source code is determined in same test event logic branch, improves testing efficiency.
Further, the above-mentioned first embodiment based on code coverage rate analysis system 200 of the present invention, propose the present invention's 3rd embodiment (as shown in Figure 5).In the present embodiment, described code coverage rate analysis system 200 also includes judge module 208 And labeling module 209, wherein:
The judge module 208, for judge the source code function logic branch whether all covering described in Test event logic branch.
The labeling module 209, for when the function logic branch of the source code is without all covering test items During mesh logic branch, unlapped test event logic branch is marked.
The generation module 202, it is additionally operable to generation and includes the function of being labeled with unlapped test event logic branch Logic branch coverage rate is reported.
In the present embodiment, when the function logic branch of the source code has all covered the test event logic During branch, the application server 2 not report by systematic function logic branch coverage rate.In other embodiments, when the source generation When the function logic branch of code has all covered the test event logic branch, the application server 2 feeds back The information all covered reminds the feature of source code described in developer complete to the web interface of the terminal device 1 It is whole, the test of next step can be carried out.
By said procedure module 208-209, code coverage rate analysis system 200 proposed by the invention, additionally it is possible to When judging the function logic branch of the source code without the test event logic branch is all covered, mark is unlapped Test event logic branch, and generate and include the function logic branch for being labeled with unlapped test event logic branch covering Rate is reported, is facilitated developer to be visually known the function logic branch being not covered with, is easy to developer's specific aim to repair Change.
In addition, the present invention also proposes a kind of code coverage rate analysis method.
As shown in fig.6, it is the schematic flow sheet of code coverage rate analysis method first embodiment of the present invention.In this implementation In example, according to different demands, the execution sequence of the step in flow chart shown in Fig. 6 can change, and some steps can save Slightly.
Step S301, when receiving the program source code that the terminal device 1 is sent, analyze the knot of the source code Structure.
Normally, the coverage rate analysis of traditional test program code both for code line coverage condition, but this Kind can understand that how many code in program is performed, and can not just represent one by the coverage condition of code analysis row The complete coverage condition of functional unit.Assuming that One function unit needs to call 4 combination of function to complete according to different condition This function.If the function can form 16 logic branches, and counted by code line coverage rate, source code, which only needs to write 4, patrols Collecting branch just can all override 4 functions, but from functional completeness, the functional unit is incomplete.
For example, the function of the source code is to complete user name registration, and the user for completing registration can have inhomogeneity The landing approach of type, each landing approach are One function logic branch.For example, by call function A, realize that user can be with Authentication code is sent by phone number to log in, call function B, realize that user can activate link by mailbox and log in, can be with Call function A and function B simultaneously, authentication code is sent by phone number while realizing and activate link by mailbox and logged in, this In the case of kind, if according to the covering analyzing of traditional test program code, function A and the function in program can only be analyzed B is called, and can not analyze while call function A and function B this logic branch, so as to cause test cases function occur Cover incomplete situation.
Therefore, in the present embodiment, the application server 2 establishes long connection with the terminal device 1, when the application For server 2 when receiving the program source code of the transmission of terminal device 1, the application server 2 analyzes the knot of the source code Structure, specifically, the call relation of analytic function and method, the inclusion relation, the inheritance of class etc. of structure.
Step S302, according to the function logic branch of source code described in the structural generation of the source code.
Specifically, according to the structure of the source code, the power function that each functional unit calls is analyzed, and often The call relation of One function function, and then generate function logic branch of the source code on realizing each function.
In the present embodiment, the application server 2 analyzes the structure of the source code, forms the grammer of the source code Tree.According to the syntax tree locating function function and the call relation with power function, while remove annotation and need not unite Count public function of coverage rate information etc., locating function function, the call relation of analytic function function.According to the power function Call relation, generate the logic branch of the source code.
Step S303, by the function logic branch of the source code and the test event for being pre-stored in the application server Logic branch is compared.
Normally, developer necessarily understands the function of software to be developed when carrying out source code design.In the present embodiment In, in order to verify the source code integrality, there is the application in advance and take by developer in the logic branch that source code needs The memory space of business device 2.In the present embodiment, when generating the logic branch of the source code, the application server 2 is adjusted The function logic branch for the software to be developed being previously stored with, and the function of the logic branch of source code and software to be developed is patrolled Collect branch and carry out com-parison and analysis, the function logic branch covering rate is analyzed by comparative result.
Step S304, the function logic branch covering rate that the source code is generated according to comparative result are reported.
Specifically, the application server 2 generates the source code by the generation module 202 according to comparative result Function logic branch covering rate is reported.In the present embodiment, the logic branch coverage rate report includes identifying having covered Function and function logic branch and the function that is not covered with and function logic branch.
Step S305, function logic branch covering rate report is fed back into terminal device 1.
Specifically, the application server 2 sends function logic branch coverage report to the web of terminal device 1 The page shows, developer can according to the function logic branch covering rate report check source code integrality, i.e., Whether the source code has covered all function logic branches, if any omission, you can carries out specific aim modification.
In the present embodiment, the application server 2 also sets a memory space, and stores the function logic branch and cover Lid rate is reported and the source code is to the memory space, is easy to developer to access the function logic point from memory space Branch coverage rate is reported and the source code, the design progress for the source code that follows up.
By above-mentioned steps S301-305, code coverage rate analysis method proposed by the invention, first when receiving When stating the program source code of the transmission of terminal device 1, the structure of the source code is analyzed;Then, according to the structure of the source code Generate the function logic branch of the source code;Further, by the function logic branch of the source code with being pre-stored in institute The test event logic branch for stating application server 2 is compared;Then, the function of the source code is generated according to comparative result Logic branch coverage rate is reported;Function logic branch covering rate report is finally fed back into terminal device 1.So, both may be used To avoid counting by code coverage in the prior art, it is only capable of recognizing in program that how many code is performed, still The defects of complete coverage condition of program module can not really be understood, it is also possible that by the comparison of logic branch, Confirm whether source code has covered all function logic branches, ensure the functional completeness of test event.
Further, the above-mentioned first embodiment based on code coverage rate analysis method of the present invention, proposes code of the present invention The second embodiment of coverage ratio analysis method.
As shown in fig. 7, it is the schematic flow sheet of code coverage rate analysis method second embodiment of the present invention.The present embodiment In, the function logic branch by the source code and the test cases logic branch progress for being pre-stored in application server 2 Compare, generate the source code function logic branch covering rate report the step of before, also comprise the following steps:
Step S401, when receiving the program source code that the terminal device 1 is sent, obtain the mark of the source code Know.
Step S402, the test event logic branch of the application server is pre-stored according to the mark matching.
Specifically, the application server 2 can receive multiple different source codes, and each source code can have corresponding The test event logic branch being pre-stored in the internal memory of application server 2.In order to distinguish each source code, each source code There is specific mark, the test event logic branch is provided with mark corresponding with source code.When the application server 2 When receiving from the source code that terminal device 1 is sent, the mark of the source code is obtained by acquisition module 205, and then The test event logic branch of the application server 2 is pre-stored in by identifying matching with module 206, so that it is determined that corresponding Test event logic branch.
Step S403, transfer the test event logic branch.
Specifically, the application server 2 transfers the test event logic branch by the module 207 of transferring, and enters And compared with the function logic branch of source code.
By above-mentioned steps S401-S402, code coverage rate analysis method proposed by the invention can be by obtaining State the mark of source code, and then match the test event logic branch being pre-stored in the application server 2, with from different Test event logic branch corresponding with the source code is determined in test event logic branch, improves testing efficiency.
Further, above-mentioned first and second embodiment based on code coverage rate analysis method of the present invention, proposes this hair The 3rd embodiment of Ming Dynasty's code coverage ratio analysis method.
As shown in figure 8, it is the schematic flow sheet of code coverage rate analysis method 3rd embodiment of the present invention.The present embodiment In, the step of the function logic branch covering rate report of the generation source code, specifically include:
Step S501, judges whether the function logic branch of the source code all covers the test event logic Branch.
Step S502, when the function logic branch of the source code is without all covering test event logic branches When, mark unlapped test event logic branch.
Step S503, generation include the function logic branch covering rate for being labeled with unlapped test event logic branch Report.
In the present embodiment, when the function logic branch of the source code has all covered the test event logic During branch, the application server 2 not report by systematic function logic branch coverage rate.In other embodiments, when the source generation When the function logic branch of code has all covered the test event logic branch, the application server 2 feeds back The information all covered reminds the feature of source code described in developer complete to the web interface of the terminal device 1 It is whole, the test of next step can be carried out.
By above-mentioned steps S501-S503, code coverage rate analysis method proposed by the invention, additionally it is possible to judging When the function logic branch of the source code is without the test event logic branch is all covered, unlapped test item is marked Mesh logic branch, and generate the function logic branch covering rate report for including and being labeled with unlapped test event logic branch Accuse, facilitate developer to be visually known the function logic branch being not covered with, be easy to developer's specific aim to change.
The embodiments of the present invention are for illustration only, do not represent the quality of embodiment.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can add the mode of required general hardware platform to realize by software, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on such understanding, technical scheme is substantially done to prior art in other words Going out the part of contribution can be embodied in the form of software product, and the computer software product is stored in a storage medium In (such as ROM/RAM, magnetic disc, CD), including some instructions to cause a station terminal equipment (can be mobile phone, computer, clothes Be engaged in device, air conditioner, or network equipment etc.) perform method described in each embodiment of the present invention.
The preferred embodiments of the present invention are these are only, are not intended to limit the scope of the invention, it is every to utilize this hair The equivalent structure or equivalent flow conversion that bright specification and accompanying drawing content are made, or directly or indirectly it is used in other related skills Art field, is included within the scope of the present invention.

Claims (10)

  1. A kind of 1. code coverage rate analysis method, applied to application server, it is characterised in that methods described includes:
    When receiving the program source code of terminal device transmission, the structure of the source code is analyzed;
    According to the function logic branch of source code described in the structural generation of the source code;
    The function logic branch of the source code and the test event logic branch for being pre-stored in the application server are carried out Compare;
    The function logic branch covering rate that the source code is generated according to comparative result is reported;
    Function logic branch covering rate report is fed back into the terminal device.
  2. 2. code coverage rate analysis method as claimed in claim 1, it is characterised in that the structure according to the source code The step of generating the logic branch of the source code, specifically comprises the following steps:
    The structure of the source code is analyzed, forms the syntax tree of the source code;
    According to the syntax tree locating function function and the call relation with power function;
    According to the call relation of the power function, the logic branch of the source code is generated.
  3. 3. code coverage rate analysis method as claimed in claim 1, it is characterised in that the function by the source code is patrolled Branch is collected compared with the test cases logic branch for being pre-stored in application server, generates the function logic of the source code Before the step of branch covering rate is reported, also comprise the following steps:
    When receiving the program source code that the terminal device is sent, the mark of the source code is obtained;
    The test event logic branch of the application server is pre-stored according to the mark matching;
    Transfer the test event logic branch.
  4. 4. code coverage rate analysis method as claimed in claim 1, it is characterised in that the function of the generation source code The step of logic branch coverage rate is reported, specifically includes:
    Judge whether the function logic branch of the source code all covers the test event logic branch;
    When the function logic branch of the source code is without all the test event logic branch is covered, mark is unlapped Test event logic branch;
    Generation includes the function logic branch covering rate report for being labeled with unlapped test event logic branch.
  5. 5. the code coverage rate analysis method as described in claim 1-4 as described in any one, it is characterised in that methods described is also wrapped Include:
    Set a memory space;
    The function logic branch covering rate report and the source code are stored to the memory space.
  6. 6. a kind of application server, it is characterised in that the application server includes memory, processor, on the memory The code coverage rate analysis system that can be run on the processor is stored with, the code coverage rate analysis system is by the place Reason device realizes following steps when performing:
    When receiving the program source code of terminal device transmission, the structure of the source code is analyzed;
    According to the function logic branch of source code described in the structural generation of the source code;
    The function logic branch of the source code and the test event logic branch for being pre-stored in the application server are carried out Compare;
    The function logic branch covering rate that the source code is generated according to comparative result is reported;
    Function logic branch covering rate report is fed back into the terminal device.
  7. 7. application server as claimed in claim 6, it is characterised in that described according to the structural generation of the source code The step of logic branch of source code, specifically comprise the following steps:
    The structure of the source code is analyzed, forms the syntax tree of the source code;
    According to the syntax tree locating function function and the call relation with power function;
    According to the call relation of the power function, the logic branch of the source code is generated.
  8. 8. application server as claimed in claim 6, it is characterised in that the function logic branch by the source code with The test cases logic branch for being pre-stored in application server is compared, and generates the function logic branch covering of the source code Before the step of rate is reported, also comprise the following steps:
    When receiving the program source code that the terminal device is sent, the mark of the source code is obtained;
    The test event logic branch of the application server is pre-stored according to the mark matching;
    Transfer the test event logic branch.
  9. 9. application server as claimed in claim 6, it is characterised in that the function logic branch of the generation source code The step of coverage rate is reported, specifically includes:
    Judge whether the function logic branch of the source code all covers the test event logic branch;
    When the function logic branch of the source code is without all the test event logic branch is covered, mark is unlapped Test event logic branch;
    Generation includes the function logic branch covering rate report for being labeled with unlapped test event logic branch.
  10. 10. a kind of computer-readable recording medium, the computer-readable recording medium storage has code coverage rate analysis system, The code coverage rate analysis system can be by least one computing device, so that at least one computing device such as right It is required that the step of code coverage rate analysis method any one of 1-5.
CN201710933579.0A 2017-10-10 2017-10-10 Code coverage rate analysis method and application server Active CN107797923B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201710933579.0A CN107797923B (en) 2017-10-10 2017-10-10 Code coverage rate analysis method and application server
PCT/CN2018/076141 WO2019071891A1 (en) 2017-10-10 2018-02-10 Code coverage analysis method and application server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710933579.0A CN107797923B (en) 2017-10-10 2017-10-10 Code coverage rate analysis method and application server

Publications (2)

Publication Number Publication Date
CN107797923A true CN107797923A (en) 2018-03-13
CN107797923B CN107797923B (en) 2019-04-26

Family

ID=61533000

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710933579.0A Active CN107797923B (en) 2017-10-10 2017-10-10 Code coverage rate analysis method and application server

Country Status (2)

Country Link
CN (1) CN107797923B (en)
WO (1) WO2019071891A1 (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542789A (en) * 2018-11-26 2019-03-29 泰康保险集团股份有限公司 A kind of code coverage statistical method and device
CN109582574A (en) * 2018-11-27 2019-04-05 平安科技(深圳)有限公司 A kind of code coverage statistical method, device, storage medium and terminal device
CN110209582A (en) * 2019-05-31 2019-09-06 口碑(上海)信息技术有限公司 The statistical method and device of code coverage, electronic equipment, storage medium
CN110209576A (en) * 2019-05-21 2019-09-06 深圳壹账通智能科技有限公司 The calculation method and relevant device of test case coverage rate
WO2019200800A1 (en) * 2018-04-17 2019-10-24 平安科技(深圳)有限公司 Test effect display method for test case, electronic device, and storage medium
CN110765017A (en) * 2019-10-24 2020-02-07 上海创景信息科技有限公司 RISC-V extended instruction-based source code coverage rate test method and system
CN111831573A (en) * 2020-07-27 2020-10-27 中国工商银行股份有限公司 Method, device, computer system and medium for determining code branch coverage condition
CN111949505A (en) * 2019-05-14 2020-11-17 阿里巴巴集团控股有限公司 Test method, device and equipment
CN112612716A (en) * 2020-12-28 2021-04-06 上海品顺信息科技有限公司 Method, system, equipment and storage medium for enhancing marking of coverage rate of difference line codes
CN113032254A (en) * 2021-03-19 2021-06-25 中国工商银行股份有限公司 Evaluation method and device for test coverage condition
CN113127362A (en) * 2021-04-23 2021-07-16 中国工商银行股份有限公司 Object testing method, object testing device, electronic device, and readable storage medium
CN113407393A (en) * 2021-05-25 2021-09-17 鹏城实验室 Chip verification method, terminal device, verification platform and storage medium
CN111949505B (en) * 2019-05-14 2024-05-14 阿里云计算有限公司 Test method, device and equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1885273A (en) * 2005-06-21 2006-12-27 华为技术有限公司 Function coverage ratio analysis method for logic test
CN101625709A (en) * 2008-07-09 2010-01-13 华为技术有限公司 Method and device for collecting functional coverage
CN101706751A (en) * 2009-11-23 2010-05-12 中兴通讯股份有限公司 Method and system for calculating coverage rate of service functions of software
CN103164337A (en) * 2013-02-28 2013-06-19 汉柏科技有限公司 Cloud calculation software test method based on finite-state machine (FSM)
CN105302573A (en) * 2015-11-20 2016-02-03 浪潮集团有限公司 Method for establishing function point matching setting automation platform for function verification platform
CN105573908A (en) * 2015-09-01 2016-05-11 北京中电华大电子设计有限责任公司 Functional verification method and device
CN106293809A (en) * 2016-07-28 2017-01-04 东软集团股份有限公司 The method and device of optimization program
CN106775704A (en) * 2016-12-12 2017-05-31 广州视源电子科技股份有限公司 The software attributes demand method of inspection and device
CN106874187A (en) * 2016-12-29 2017-06-20 腾讯科技(深圳)有限公司 code coverage collection method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090287729A1 (en) * 2008-05-16 2009-11-19 Microsoft Corporation Source code coverage testing
IN2015DE01249A (en) * 2015-05-06 2015-06-05 Hcl Technologies Ltd
CN105630670A (en) * 2015-12-16 2016-06-01 北京奇虎科技有限公司 Code coverage rate test method and device
CN106649110B (en) * 2016-12-15 2023-09-15 中标软件有限公司 Software testing method and system

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1885273A (en) * 2005-06-21 2006-12-27 华为技术有限公司 Function coverage ratio analysis method for logic test
CN101625709A (en) * 2008-07-09 2010-01-13 华为技术有限公司 Method and device for collecting functional coverage
CN101706751A (en) * 2009-11-23 2010-05-12 中兴通讯股份有限公司 Method and system for calculating coverage rate of service functions of software
CN103164337A (en) * 2013-02-28 2013-06-19 汉柏科技有限公司 Cloud calculation software test method based on finite-state machine (FSM)
CN105573908A (en) * 2015-09-01 2016-05-11 北京中电华大电子设计有限责任公司 Functional verification method and device
CN105302573A (en) * 2015-11-20 2016-02-03 浪潮集团有限公司 Method for establishing function point matching setting automation platform for function verification platform
CN106293809A (en) * 2016-07-28 2017-01-04 东软集团股份有限公司 The method and device of optimization program
CN106775704A (en) * 2016-12-12 2017-05-31 广州视源电子科技股份有限公司 The software attributes demand method of inspection and device
CN106874187A (en) * 2016-12-29 2017-06-20 腾讯科技(深圳)有限公司 code coverage collection method and device

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019200800A1 (en) * 2018-04-17 2019-10-24 平安科技(深圳)有限公司 Test effect display method for test case, electronic device, and storage medium
CN109542789A (en) * 2018-11-26 2019-03-29 泰康保险集团股份有限公司 A kind of code coverage statistical method and device
CN109582574A (en) * 2018-11-27 2019-04-05 平安科技(深圳)有限公司 A kind of code coverage statistical method, device, storage medium and terminal device
CN109582574B (en) * 2018-11-27 2024-03-19 平安科技(深圳)有限公司 Code coverage rate statistical method, device, storage medium and terminal equipment
CN111949505A (en) * 2019-05-14 2020-11-17 阿里巴巴集团控股有限公司 Test method, device and equipment
CN111949505B (en) * 2019-05-14 2024-05-14 阿里云计算有限公司 Test method, device and equipment
CN110209576A (en) * 2019-05-21 2019-09-06 深圳壹账通智能科技有限公司 The calculation method and relevant device of test case coverage rate
CN110209582A (en) * 2019-05-31 2019-09-06 口碑(上海)信息技术有限公司 The statistical method and device of code coverage, electronic equipment, storage medium
CN110765017A (en) * 2019-10-24 2020-02-07 上海创景信息科技有限公司 RISC-V extended instruction-based source code coverage rate test method and system
CN111831573B (en) * 2020-07-27 2024-03-08 中国工商银行股份有限公司 Method, device, computer system and medium for determining code branch coverage condition
CN111831573A (en) * 2020-07-27 2020-10-27 中国工商银行股份有限公司 Method, device, computer system and medium for determining code branch coverage condition
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
CN113032254A (en) * 2021-03-19 2021-06-25 中国工商银行股份有限公司 Evaluation method and device for test coverage condition
CN113127362A (en) * 2021-04-23 2021-07-16 中国工商银行股份有限公司 Object testing method, object testing device, electronic device, and readable storage medium
CN113407393B (en) * 2021-05-25 2023-01-24 鹏城实验室 Chip verification method, terminal device, verification platform and storage medium
CN113407393A (en) * 2021-05-25 2021-09-17 鹏城实验室 Chip verification method, terminal device, verification platform and storage medium

Also Published As

Publication number Publication date
WO2019071891A1 (en) 2019-04-18
CN107797923B (en) 2019-04-26

Similar Documents

Publication Publication Date Title
CN107797923B (en) Code coverage rate analysis method and application server
US8793660B2 (en) Automated testing of programming code for a web service
CN109302522A (en) Test method, device and computer system and medium
CN107797919A (en) The method and computing device of a kind of automatic test
CN103530226B (en) Electronic equipment peripheral hardware compatibility test method and device
CN107957940B (en) Test log processing method, system and terminal
CN108255701B (en) Scene testing method and mobile terminal
CN105302732A (en) Automatic mobile terminal testing method and device
CN108920376A (en) Test method, device and the medium of application program
CN112367680B (en) External communication test method and device based on intelligent ammeter and computer equipment
CN104133765B (en) The test case sending method of network activity and test case server
CN107992424A (en) Automatic test analysis method, application server and computer-readable recording medium
CN106612204B (en) Service checking method and device
CN106339273A (en) Application program restoration method, terminal and server
CN107143976A (en) Air-conditioning fault detection method, motion detection device, air-conditioning
CN109815105A (en) Applied program testing method and device based on Btrace
CN108021621A (en) Database data acquisition method, application server and computer-readable recording medium
CN108306921A (en) Call external service method and application server
CN106792784B (en) A kind of method, server and system carrying out data check in server side
CN107798064A (en) Page processing method, electronic equipment and computer-readable recording medium
CN104468288A (en) Terminal network data testing method and device
CN107908480A (en) Wages computational methods, application server and computer-readable recording medium
CN108170600A (en) The coverage rate statistical method of front-end code test, apparatus and system
CN105404574A (en) Method and apparatus for testing consistency of smart card and mobile terminal
CN108255914A (en) webpage generating method and application server

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