WO2019071891A1 - 代码覆盖率分析方法及应用服务器 - Google Patents

代码覆盖率分析方法及应用服务器 Download PDF

Info

Publication number
WO2019071891A1
WO2019071891A1 PCT/CN2018/076141 CN2018076141W WO2019071891A1 WO 2019071891 A1 WO2019071891 A1 WO 2019071891A1 CN 2018076141 W CN2018076141 W CN 2018076141W WO 2019071891 A1 WO2019071891 A1 WO 2019071891A1
Authority
WO
WIPO (PCT)
Prior art keywords
source code
branch
code
application server
coverage
Prior art date
Application number
PCT/CN2018/076141
Other languages
English (en)
French (fr)
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 平安科技(深圳)有限公司
Publication of WO2019071891A1 publication Critical patent/WO2019071891A1/zh

Links

Images

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

Definitions

  • the present application relates to the field of code testing technologies, and in particular, to a code coverage analysis method and an application server.
  • Code coverage is an important indicator of how well a test case covers the program under test. It is also a reference for measuring test integrity. The code coverage data can be used to assess whether the test is sufficient. In the process of software development, obtaining code coverage data through the client is generated based on all the code of the monitored project. The traditional test coverage analysis is for the coverage of the code line. Through the code coverage statistics, we can understand how much code is executed in the program, but can not really understand the complete coverage of a program module.
  • the present application proposes a code coverage analysis method and an application server, which can confirm whether the source code has covered all functional logic branches and ensure the functional integrity of the test item.
  • the present application provides a code coverage analysis method, which is applied to an application server, and the method includes:
  • the functional logic branch coverage report is fed back to the terminal device.
  • the present application further provides an application server, where the application server includes a memory, a processor, and a code coverage analysis system executable on the processor, where the code is stored.
  • the coverage analysis system is implemented by the processor to implement the following steps:
  • the functional logic branch coverage report is fed back to the terminal device.
  • the present application further provides a computer readable storage medium storing a code coverage analysis system, the code coverage analysis system being executable by at least one processor, The step of causing the at least one processor to perform the code coverage analysis method as described above.
  • the application server, the code coverage analysis method, and the computer readable storage medium proposed by the present application first analyze the structure of the source code when receiving the program source code sent by the terminal device; And generating, according to the structure of the source code, a functional logic branch of the source code; further, comparing a functional logic branch of the source code with a test item logical branch pre-stored in the application server; and then, according to The comparison result generates a functional logic branch coverage report of the source code; finally, the functional logic branch coverage report is fed back to the terminal device.
  • FIG. 1 is a schematic diagram of an optional application environment of each embodiment of the present application.
  • FIG. 2 is a schematic diagram of an optional hardware architecture of the application server of FIG. 1;
  • FIG. 3 is a schematic diagram of a program module of a first embodiment of the code coverage analysis system of the present application
  • FIG. 4 is a schematic diagram of a program module of a second embodiment of the code coverage analysis system of the present application.
  • FIG. 5 is a schematic diagram of a program module of a third embodiment of the code coverage analysis system of the present application.
  • FIG. 6 is a schematic flowchart of a first embodiment of a code coverage analysis method according to the present application.
  • FIG. 7 is a schematic flowchart of a second embodiment of a code coverage analysis method according to the present application.
  • FIG. 8 is a schematic flowchart diagram of a third embodiment of a code coverage analysis method according to the present application.
  • first, second and the like in the present application are for the purpose of description only, and are not to be construed as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. .
  • features defining “first” and “second” may include at least one of the features, either explicitly or implicitly.
  • the technical solutions between the various embodiments may be combined with each other, but must be based on the realization of those skilled in the art, and when the combination of the technical solutions is contradictory or impossible to implement, it should be considered that the combination of the technical solutions does not exist. Nor is it within the scope of protection required by this application.
  • FIG. 1 it is a schematic diagram of an optional application environment of each embodiment of the present application.
  • the present application is applicable to an application environment including, but not limited to, the terminal device 1, the application server 2, and the network 3.
  • the terminal device 1 may be a mobile phone, a smart phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet PC), a PMP (Portable Multimedia Player), a navigation device, or the like.
  • Mobile devices, as well as fixed terminals such as digital TVs, desktop computers, notebooks, servers, and the like.
  • the application server 2 may be a computing device such as a rack server, a blade server, a tower server, or a rack server.
  • the application server 2 may be a stand-alone server or a server cluster composed of multiple servers.
  • the network 3 may be an intranet, an Internet, a Global System of Mobile communication (GSM), a Wideband Code Division Multiple Access (WCDMA), a 4G network, Wireless or wired networks such as 5G networks, Bluetooth, Wi-Fi, etc.
  • GSM Global
  • the application server 2 is respectively connected to one or more of the terminal devices 1 through the network 3 for data transmission and interaction.
  • a code coverage analysis system 200 is installed and run in the application server 2, and when the code coverage analysis system 200 is running, the application server 2 receives the program source sent by the terminal device 1.
  • the application server 2 receives the program source sent by the terminal device 1.
  • analyzing the structure of the source code then, generating a functional logic branch of the source code according to the structure of the source code; further, branching and pre-storing the functional logic of the source code to the application server.
  • the test item logical branch is compared; then, the function logic branch coverage report of the source code is generated according to the comparison result; finally, the function logic branch coverage report is fed back to the terminal device 1.
  • FIG. 2 it is a schematic diagram of an optional hardware architecture of the application server 2 in FIG.
  • the application server 2 may include, but is not limited to, the memory 11, the processor 12, and the network interface 13 being communicably connected to each other through a system bus.
  • FIG. 2 only shows the terminal device 1 having the components 11-13, but it should be understood that not all illustrated components are required to be implemented, and more or fewer components may be implemented instead.
  • the memory 11 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (eg, SD or DX memory, etc.), and a random access memory (RAM). , static random access memory (SRAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), programmable read only memory (PROM), magnetic memory, magnetic disk, optical disk, and the like.
  • the memory 11 may be an internal storage unit of the application server 2, such as a hard disk or memory of the application server 2.
  • the memory 11 may also be an external storage device of the application server 2, such as a plug-in hard disk equipped on the application server 2, a smart memory card (SMC), and a secure digital number. (Secure Digital, SD) card, flash card, etc.
  • the memory 11 can also include both the internal storage unit of the application server 2 and its external storage device.
  • the memory 11 is generally used to store an operating system installed in the application server 2 and various types of application software, such as program code of the code coverage analysis system 200. Further, the memory 11 can also be used to temporarily store various types of data that have been output or are to be output.
  • the processor 12 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments.
  • the processor 12 is typically used to control the overall operation of the application server 2, such as performing control and processing related to data interaction or communication with the terminal device 1.
  • the processor 12 is configured to run program code or process data stored in the memory 11, such as running the code coverage analysis system 200 and the like.
  • the network interface 13 may comprise a wireless network interface or a wired network interface, which is typically used to establish a communication connection between the application server 2 and other electronic devices.
  • the network interface 13 is mainly used to connect the application server 2 to one or more of the terminal devices 1 through the network 3, and the application server 2 and the one or more terminals. A data transmission channel and a communication connection are established between the devices 1.
  • the present application proposes a code coverage analysis system 200.
  • FIG. 3 it is a program module diagram of the first embodiment of the code coverage analysis system 200 of the present application.
  • the code coverage analysis system 200 includes a series of computer program instructions stored on the memory 11, and when the computer program instructions are executed by the processor 12, the code coverage of the embodiments of the present application can be implemented. Analyze the operation.
  • code coverage analysis system 200 can be divided into one or more modules based on the particular operations implemented by the various portions of the computer program instructions. For example, in FIG. 3, the code coverage analysis system 200 can be divided into an analysis module 201, a generation module 202, a comparison module 203, and a feedback module 204. among them:
  • the analyzing module 201 is configured to analyze the structure of the source code when receiving the program source code sent by the terminal device 1.
  • the coverage analysis of traditional test program code is for the coverage of the code line, but by analyzing the coverage of the code line, you can understand how much code is executed in the program and cannot represent a functional unit. Complete coverage of the situation.
  • a functional unit needs to call 4 function combinations to complete this function according to different conditions. If the function will form 16 logical branches, and according to the code line coverage statistics, the source code only needs to write 4 logical branches to cover 4 functions, but from the perspective of functional integrity, the functional unit is Incomplete.
  • the function of the source code is to complete the registration of the username, and the user who completes the registration may have different types of login methods, and each login method is a functional logic branch.
  • each login method is a functional logic branch.
  • the user can log in by sending the authentication code through the mobile phone number, calling function B, so that the user can log in through the mailbox activation link, and can also call function A and function B at the same time to realize the activation of the link through the mailbox.
  • the number sends the authentication code to log in.
  • the coverage of the traditional test program code is analyzed, only the function A and function B in the program can be analyzed, and the function A and function B cannot be analyzed at the same time.
  • a logical branch which leads to incomplete coverage of test cases.
  • the application server 2 establishes a long connection with the terminal device 1, and when the application server 2 receives the program source code sent by the terminal device 1, analyzes the source through the analysis module 201.
  • the structure of the code specifically, the call relationship of the analysis function and method, the inclusion relationship of the structure, the inheritance relationship of the class, and so on.
  • the generating module 202 is configured to generate a functional logic branch of the source code according to the structure of the source code.
  • the function function called by each functional unit and the calling relationship of each function function are analyzed, thereby generating a functional logic branch of the source code for implementing each function.
  • the application server 2 analyzes the structure of the source code to form a syntax tree of the source code. According to the syntax tree, the function function and the calling relationship with the function function are searched, and the annotation and the public function that does not need the statistical coverage information are removed, the function function is searched, and the calling relationship of the function function is analyzed. A logical branch of the source code is generated according to a calling relationship of the function function.
  • the comparing module 203 is configured to compare the functional logic branch of the source code with a test item logical branch pre-stored in the application server.
  • the developer in order to verify the source code integrity, the developer pre-stores the logical branch required by the source code in the storage space of the application server.
  • the application server 2 adjusts the function logic branch of the software to be developed stored in advance, and the logical branch of the source code and the function logic of the software to be developed. The branches are analyzed and compared, and the functional logic branch coverage is analyzed by comparing the results.
  • the generating module 202 is further configured to generate a function logic branch coverage report of the source code according to the comparison result.
  • the application server 2 generates a function logical branch coverage report of the source code according to the comparison result by the generating module 202.
  • the logical branch coverage report includes a function and a function logic branch that have been overwritten and a function and a function logic branch that are not covered.
  • the feedback module 204 is configured to feed back the function logic branch coverage report to the terminal device 1.
  • the application server 2 sends the function logic branch coverage report to the web page display of the terminal device 1, and the developer may check the integrity of the source code according to the function logic branch coverage report, that is, the Whether the source code has covered all the functional logic branches, and if there are any omissions, you can make targeted modifications.
  • the application server 2 further sets a storage space, and stores the function logical branch coverage report and the source code to the storage space, so that the developer can access the function logic from the storage space.
  • the branch coverage report and the source code follow the design progress of the source code.
  • the code coverage analysis system 200 further includes an obtaining module 205, a matching module 206, and a calling module 207, where
  • the obtaining module 205 is configured to acquire an identifier of the source code when receiving the program source code sent by the terminal device 1.
  • the matching module 206 is configured to match a test item logical branch pre-stored in the application server according to the identifier.
  • the application server 2 receives a plurality of different source codes, and each source code has a corresponding test item logical branch pre-stored in the memory of the application server 2.
  • each source code has a specific identifier, and the test item logical branch is provided with an identifier corresponding to the source code.
  • the application server 2 receives the source code sent from the terminal device 1, the identifier of the source code is obtained by the obtaining module 205, and the matching module 206 matches the test item logic pre-stored in the application server 2 by the identifier matching. Branch to determine the logical branch of the corresponding test project.
  • the retrieving module 207 is configured to retrieve the logical branch of the test item.
  • the application server 2 retrieves the test item logical branch through the retrieving module 207, and then compares with the functional logic branch of the source code.
  • the code coverage analysis system 200 further includes a determination module 208 and an annotation module 209, wherein:
  • the determining module 208 is configured to determine whether the functional logic branch of the source code has completely covered the test item logical branch.
  • the labeling module 209 is configured to mark an uncovered test item logical branch when the function logic branch of the source code does not completely cover the test item logical branch.
  • the generating module 202 is further configured to generate a functional logical branch coverage report including a logical branch of the test item marked with no coverage.
  • the application server 2 when the functional logic branch of the source code has completely covered the test item logical branch, the application server 2 does not generate a functional logical branch coverage report. In other embodiments, when the functional logic branch of the source code has completely covered the test item logical branch, the application server 2 feeds back all the information that has been completely covered to the web interface of the terminal device 1 to remind the development. The functionality of the source code described by the personnel is complete and can be tested in the next step.
  • the present application also proposes a code coverage analysis method.
  • FIG. 6 it is a schematic flowchart of the first embodiment of the code coverage analysis method of the present application.
  • the order of execution of the steps in the flowchart shown in Fig. 6 may be changed according to different needs, and some steps may be omitted.
  • Step S301 when receiving the program source code sent by the terminal device 1, analyzing the structure of the source code.
  • the coverage analysis of traditional test program code is for the coverage of the code line, but by analyzing the coverage of the code line, you can understand how much code is executed in the program and cannot represent a functional unit. Complete coverage of the situation.
  • a functional unit needs to call 4 function combinations to complete this function according to different conditions. If the function will form 16 logical branches, and according to the code line coverage statistics, the source code only needs to write 4 logical branches to cover 4 functions, but from the perspective of functional integrity, the functional unit is Incomplete.
  • the function of the source code is to complete the registration of the username, and the user who completes the registration may have different types of login methods, and each login method is a functional logic branch.
  • each login method is a functional logic branch.
  • the user can log in by sending the authentication code through the mobile phone number, calling function B, so that the user can log in through the mailbox activation link, and can also call function A and function B at the same time to realize the activation of the link through the mailbox.
  • the number sends the authentication code to log in.
  • the coverage of the traditional test program code is analyzed, only the function A and function B in the program can be analyzed, and the function A and function B cannot be analyzed at the same time.
  • a logical branch which leads to incomplete coverage of test cases.
  • the application server 2 establishes a long connection with the terminal device 1, and when the application server 2 receives the program source code sent by the terminal device 1, the application server 2 analyzes the The structure of the source code, specifically, the call relationship of the analysis function and method, the inclusion relationship of the structure, the inheritance relationship of the class, and the like.
  • Step S302 generating a functional logic branch of the source code according to the structure of the source code.
  • the function function called by each functional unit and the calling relationship of each function function are analyzed, thereby generating a functional logic branch of the source code for implementing each function.
  • the application server 2 analyzes the structure of the source code to form a syntax tree of the source code. According to the syntax tree, the function function and the calling relationship with the function function are searched, and the annotation and the public function that does not need the statistical coverage information are removed, the function function is searched, and the calling relationship of the function function is analyzed. A logical branch of the source code is generated according to a calling relationship of the function function.
  • Step S303 comparing the functional logic branch of the source code with a test item logical branch pre-stored in the application server.
  • the developer in order to verify the source code integrity, the developer pre-stores the logical branch required by the source code in the storage space of the application server 2.
  • the application server 2 adjusts the function logic branch of the software to be developed stored in advance, and the logical branch of the source code and the function logic of the software to be developed. The branches are analyzed and compared, and the functional logic branch coverage is analyzed by comparing the results.
  • Step S304 generating a function logic branch coverage report of the source code according to the comparison result.
  • the application server 2 generates a function logical branch coverage report of the source code according to the comparison result by the generating module 202.
  • the logical branch coverage report includes a function and a function logic branch that have been overwritten and a function and a function logic branch that are not covered.
  • Step S305 feeding back the function logic branch coverage report to the terminal device 1.
  • the application server 2 sends the function logic branch coverage report to the web page display of the terminal device 1, and the developer may check the integrity of the source code according to the function logic branch coverage report, that is, the Whether the source code has covered all the functional logic branches, and if there are any omissions, you can make targeted modifications.
  • the application server 2 further sets a storage space, and stores the function logical branch coverage report and the source code to the storage space, so that the developer can access the function logic from the storage space.
  • the branch coverage report and the source code follow the design progress of the source code.
  • the code coverage analysis method proposed by the present application first analyzes the structure of the source code when receiving the program source code sent by the terminal device 1; and then, according to the source code Generating a functional logic branch of the source code; further, comparing a functional logic branch of the source code with a test item logical branch pre-stored in the application server 2; and then generating the source code based on the comparison result Functional logical branch coverage report; finally, the functional logical branch coverage report is fed back to the terminal device 1.
  • FIG. 7 is a schematic flowchart diagram of a second embodiment of the code coverage analysis method of the present application.
  • the step of comparing the function logic branch of the source code with the test case logical branch pre-stored in the application server 2, before generating the function logic branch coverage report of the source code further includes the following step:
  • Step S401 Acquire an identifier of the source code when receiving the program source code sent by the terminal device 1.
  • Step S402 matching a test item logical branch pre-stored in the application server according to the identifier.
  • the application server 2 receives a plurality of different source codes, and each source code has a corresponding test item logical branch pre-stored in the memory of the application server 2.
  • each source code has a specific identifier, and the test item logical branch is provided with an identifier corresponding to the source code.
  • the application server 2 receives the source code sent from the terminal device 1, the identifier of the source code is obtained by the obtaining module 205, and the matching module 206 matches the test item logic pre-stored in the application server 2 by the identifier matching. Branch to determine the logical branch of the corresponding test project.
  • Step S403 the logical branch of the test item is retrieved.
  • the application server 2 retrieves the test item logical branch through the retrieving module 207, and then compares with the functional logic branch of the source code.
  • the code coverage analysis method proposed by the present application can obtain the identifier of the source code, and then match the logical branch of the test item pre-stored in the application server 2 to perform different tests.
  • the logical branch of the test item corresponding to the source code is determined in the logical branch of the project to improve the testing efficiency.
  • FIG. 8 is a schematic flowchart diagram of a third embodiment of the code coverage analysis method of the present application.
  • the step of generating the function logic branch coverage report of the source code includes:
  • Step S501 determining whether the functional logic branch of the source code has completely covered the test item logical branch.
  • Step S502 when the functional logic branch of the source code does not completely cover the test item logical branch, mark the uncovered test item logical branch.
  • Step S503 generating a functional logic branch coverage report including the logical branch of the test item marked with no coverage.
  • the application server 2 when the functional logic branch of the source code has completely covered the test item logical branch, the application server 2 does not generate a functional logical branch coverage report. In other embodiments, when the functional logic branch of the source code has completely covered the test item logical branch, the application server 2 feeds back all the information that has been completely covered to the web interface of the terminal device 1 to remind the development. The functionality of the source code described by the personnel is complete and can be tested in the next step.
  • the code coverage analysis method proposed by the present application can also mark the uncovered test item logical branch when it is determined that the function logic branch of the source code does not completely cover the test item logical branch. And generate a functional logic branch coverage report containing the logical branch of the test item marked with uncovered, so that the developer can intuitively understand the functional logic branch that is not covered, so that the developer can make targeted modifications.
  • the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better.
  • Implementation Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present application.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

一种代码覆盖率分析方法、应用服务器以及计算机可读存储介质,所述方法包括:当接收到所述终端设备发送的程序源代码时,分析所述源代码的结构(S301);根据所述源代码的结构生成所述源代码的功能逻辑分支(S302);将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较(S303);根据比较结果生成所述源代码的功能逻辑分支覆盖率报告(S304);将所述功能逻辑分支覆盖率报告反馈至终端设备(S305)。所述代码覆盖率分析方法可以确认源代码是否已经覆盖了所有的功能逻辑分支,保证测试项目的功能完整性。

Description

代码覆盖率分析方法及应用服务器
本申请要求于2017年10月10日提交中国专利局、申请号为201710933579.0、发明名称为“代码覆盖率分析方法及应用服务器”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及代码测试技术领域,尤其涉及一种代码覆盖率分析方法及应用服务器。
背景技术
代码覆盖率(codecoverage)是反映测试用例对被测程序覆盖程度的重要指标,也是衡量测试完整性的一个参考值。通过代码覆盖率数据可以评估测试是否充分。在软件开发的过程中,通过客户端获取代码覆盖率数据是基于被监控项目的全部代码生成的。传统的测试覆盖率分析都是针对代码行的覆盖情况,通过代码覆盖率统计,我们能了解到程序中有多少的代码被执行了,但是并不能真正了解一个程序模块的完整覆盖情况。
发明内容
有鉴于此,本申请提出一种代码覆盖率分析方法及应用服务器,能够确认源代码是否已经覆盖了所有的功能逻辑分支,保证测试项目的功能完整性。
首先,为实现上述目的,本申请提出一种代码覆盖率分析方法,该方法应用于应用服务器,所述方法包括:
当接收到终端设备发送的程序源代码时,分析所述源代码的结构;
根据所述源代码的结构生成所述源代码的功能逻辑分支;
将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻 辑分支进行比较;
根据比较结果生成所述源代码的功能逻辑分支覆盖率报告;
将所述功能逻辑分支覆盖率报告反馈至所述终端设备。
此外,为实现上述目的,本申请还提供一种应用服务器,所述应用服务器包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的代码覆盖率分析系统,所述代码覆盖率分析系统被所述处理器执行时实现如下步骤:
当接收到终端设备发送的程序源代码时,分析所述源代码的结构;
根据所述源代码的结构生成所述源代码的功能逻辑分支;
将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较;
根据比较结果生成所述源代码的功能逻辑分支覆盖率报告;
将所述功能逻辑分支覆盖率报告反馈至所述终端设备。
进一步地,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质存储有代码覆盖率分析系统,所述代码覆盖率分析系统可被至少一个处理器执行,以使所述至少一个处理器执行如上述的代码覆盖率分析方法的步骤。
相较于现有技术,本申请所提出的应用服务器、代码覆盖率分析方法及计算机可读存储介质,首先当接收到所述终端设备发送的程序源代码时,分析所述源代码的结构;然后,根据所述源代码的结构生成所述源代码的功能逻辑分支;进一步地,将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较;接着,根据比较结果生成所述源代码的功能逻辑分支覆盖率报告;最后将所述功能逻辑分支覆盖率报告反馈至终端设备。这样,既可以避免现有技术中通过代码覆盖率统计,仅能了解到程序中有多少的代码被执行了,但是并不能真正了解一个程序模块的完整覆盖情况的缺陷,也可以使得通过逻辑分支的比较,确认源代码是否已经覆盖了所 有的功能逻辑分支,保证测试项目的功能完整性。
附图说明
图1是本申请各个实施例一可选的应用环境示意图;
图2是图1中应用服务器一可选的硬件架构的示意图;
图3是本申请代码覆盖率分析系统第一实施例的程序模块示意图;
图4是本申请代码覆盖率分析系统第二实施例的程序模块示意图;
图5是本申请代码覆盖率分析系统第三实施例的程序模块示意图;
图6为本申请代码覆盖率分析方法第一实施例的流程示意图;
图7为本申请代码覆盖率分析方法第二实施例的流程示意图;
图8为本申请代码覆盖率分析方法第三实施例的流程示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
需要说明的是,在本申请中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本申请要求的保护范围之 内。
参阅图1所示,是本申请各个实施例一可选的应用环境示意图。
在本实施例中,本申请可应用于包括,但不仅限于,终端设备1、应用服务器2、网络3的应用环境中。其中,所述终端设备1可以是移动电话、智能电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、导航装置等等的可移动设备,以及诸如数字TV、台式计算机、笔记本、服务器等等的固定终端。所述应用服务器2可以是机架式服务器、刀片式服务器、塔式服务器或机柜式服务器等计算设备,该应用服务器2可以是独立的服务器,也可以是多个服务器所组成的服务器集群。所述网络3可以是企业内部网(Intranet)、互联网(Internet)、全球移动通讯系统(Global System of Mobile communication,GSM)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、4G网络、5G网络、蓝牙(Bluetooth)、Wi-Fi等无线或有线网络。
其中,所述应用服务器2中通过所述网络3分别与一个或多个所述终端设备1通信连接,以进行数据传输和交互。
本实施例中,所述应用服务器2内安装并运行有代码覆盖率分析系统200,当所述代码覆盖率分析系统200运行时,所述应用服务器2接收到所述终端设备1发送的程序源代码时,分析所述源代码的结构;然后,根据所述源代码的结构生成所述源代码的功能逻辑分支;进一步地,将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较;接着,根据比较结果生成所述源代码的功能逻辑分支覆盖率报告;最后将所述功能逻辑分支覆盖率报告反馈至终端设备1。这样,既可以避免现有技术中通过代码覆盖率统计,仅能了解到程序中有多少的代码被执行了,但是并不能真正了解一个程序模块的完整覆盖情况的缺陷,也可以使得通过逻辑分支的比较,确认源代码是否已经覆盖了所有的功能逻辑分支,保证测试项目的功能完整性。
参阅图2所示,是图1中应用服务器2一可选的硬件架构的示意图。本实施例中,所述应用服务器2可包括,但不仅限于,可通过系统总线相互通信连接存储器11、处理器12、网络接口13。需要指出的是,图2仅示出了具有组件11-13的终端设备1,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
其中,所述存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,所述存储器11可以是所述应用服务器2的内部存储单元,例如该应用服务器2的硬盘或内存。在另一些实施例中,所述存储器11也可以是所述应用服务器2的外部存储设备,例如该应用服务器2上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。当然,所述存储器11还可以既包括所述应用服务器2的内部存储单元也包括其外部存储设备。本实施例中,所述存储器11通常用于存储安装于所述应用服务器2的操作系统和各类应用软件,例如所述代码覆盖率分析系统200的程序代码等。此外,所述存储器11还可以用于暂时地存储已经输出或者将要输出的各类数据。
所述处理器12在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器12通常用于控制所述应用服务器2的总体操作,例如执行与所述终端设备1进行数据交互或者通信相关的控制和处理等。本实施例中,所述处理器12用于运行所述存储器11中存储的程序代码或者处理数据,例如运行所述的代码覆盖率分析系统200等。
所述网络接口13可包括无线网络接口或有线网络接口,该网络接口13通常用于在所述应用服务器2与其他电子设备之间建立通信连接。本实施例 中,所述网络接口13主要用于通过所述网络3将所述应用服务器2与一个或多个所述终端设备1相连,在所述应用服务器2与所述一个或多个终端设备1之间的建立数据传输通道和通信连接。
至此,己经详细介绍了本申请各个实施例的应用环境和相关设备的硬件结构和功能。下面,将基于上述应用环境和相关设备,提出本申请的各个实施例。
首先,本申请提出一种代码覆盖率分析系统200。
参阅图3所示,是本申请代码覆盖率分析系统200第一实施例的程序模块图。
本实施例中,所述代码覆盖率分析系统200包括一系列的存储于存储器11上的计算机程序指令,当该计算机程序指令被处理器12执行时,可以实现本申请各实施例的代码覆盖率分析操作。在一些实施例中,基于该计算机程序指令各部分所实现的特定的操作,代码覆盖率分析系统200可以被划分为一个或多个模块。例如,在图3中,所述代码覆盖率分析系统200可以被分割成分析模块201、生成模块202、比较模块203、以及反馈模块204。其中:
所述分析模块201,用于当接收到所述终端设备1发送的程序源代码时,分析所述源代码的结构。
通常地,传统的测试程序代码的覆盖率分析都是针对代码行的覆盖情况,但是这种通过分析代码行的覆盖情况,能够了解程序中有多少代码被执行了,并不能正代表一个功能单元的完整覆盖情况。假设一个功能单元根据不同条件需要调用4个函数组合来完成这个功能。若该功能会形成16个逻辑分支,而按代码行覆盖率统计,源代码只需要写4个逻辑分支就能把4个函数都覆盖掉,但从功能完整性上看,所述功能单元是不完整的。
举例而言,所述源代码的功能是完成用户名注册,完成注册的用户可以有不同类型的登陆方式,每一种登陆方式为一个功能逻辑分支。例如,通过调用函数A,实现用户可以通过手机号码发送认证码登陆,调用函数B,实现 用户可以通过邮箱激活链接登陆,还可以同时调用函数A及函数B,实现通过邮箱激活链接的同时通过手机号码发送认证码登陆,这种情况下,如果按照传统的测试程序代码的覆盖分析,则只能分析出程序中的函数A和函数B被调用,而不能分析出同时调用函数A和函数B这一逻辑分支,从而导致测试案例出现功能覆盖不完整的情况。
因此,在本实施例中,所述应用服务器2与所述终端设备1建立长连接,当所述应用服务器2在接收到终端设备1发送的程序源代码时,通过分析模块201分析所述源代码的结构,具体地,分析函数及方法的调用关系,结构的包含关系,类的继承关系等等。
所述生成模块202,用于根据所述源代码的结构生成所述源代码的功能逻辑分支。
具体地,根据所述源代码的结构,分析每一个功能单元调用到的功能函数,以及每一个功能函数的调用关系,进而生成源代码关于实现每一个功能的功能逻辑分支。
在本实施例中,所述应用服务器2分析所述源代码的结构,形成所述源代码的语法树。根据所述语法树查找功能函数及与功能函数的调用关系,同时去除注释以及不需要统计覆盖率信息的公共函数等,查找功能函数,分析功能函数的调用关系。根据所述功能函数的调用关系,生成所述源代码的逻辑分支。
所述比较模块203,用于将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较。
通常地,开发人员在进行源代码设计时,必然了解待开发软件的功能。在本实施例中,为了验证所述源代码完整性,开发人员预先把源代码需要的逻辑分支存在所述应用服务器的存储空间。在本实施例中,当生成了所述源代码的逻辑分支时,所述应用服务器2调预先存储有的待开发软件的功能逻辑分支,并将源代码的逻辑分支与待开发软件的功能逻辑分支进行分析比较, 通过比较结果分析所述功能逻辑分支覆盖率。
所述生成模块202,还用于根据比较结果生成所述源代码的功能逻辑分支覆盖率报告。
具体地,所述应用服务器2通过所述生成模块202根据比较结果生成所述源代码的功能逻辑分支覆盖率报告。在本实施例中,所述逻辑分支覆盖率报告包括标识出已经覆盖的函数及功能逻辑分支和没有覆盖的函数及功能逻辑分支。
所述反馈模块204,用于将所述功能逻辑分支覆盖率报告反馈至终端设备1。
具体地,所述应用服务器2将所述功能逻辑分支覆盖报告发送至终端设备1的web页面显示,开发人员可以根据所述功能逻辑分支覆盖率报告检查所述源代码的完整性,即所述源代码是否已经覆盖了所有的功能逻辑分支,如有遗漏,即可进行针对性修改。
在本实施例中,所述应用服务器2还设定一存储空间,并存储所述功能逻辑分支覆盖率报告以及所述源代码至所述存储空间,便于开发人员从存储空间访问所述功能逻辑分支覆盖率报告以及所述源代码,跟进源代码的设计进展。
进一步地,基于本申请代码覆盖率分析系统200的上述第一实施例,提出本申请的第二实施例(如图4所示)。本实施例中,所述代码覆盖率分析系统200还包括获取模块205,匹配模块206以及调取模块207,其中,
所述获取模块205,用于当接收到所述终端设备1发送的程序源代码时,获取所述源代码的标识。
所述匹配模块206,用于根据所述标识匹配预存储在所述应用服务器的测试项目逻辑分支。
具体地,所述应用服务器2会接收多个不同的源代码,每一个源代码都会有对应的预存储在所述应用服务器2内存中的测试项目逻辑分支。为了区 别每个源代码,每个源代码都有特定的标识,所述测试项目逻辑分支设置有与源代码对应的标识。当所述应用服务器2在接收到从终端设备1发送的源代码时,通过获取模块205获取所述源代码的标识,进而匹配模块206通过标识匹配预存储在所述应用服务器2的测试项目逻辑分支,从而确定对应的测试项目逻辑分支。
所述调取模块207,用于调取所述测试项目逻辑分支。
具体地,所述应用服务器2通过所述调取模块207调取所述测试项目逻辑分支,进而与源代码的功能逻辑分支进行比较。
进一步地,基于本申请代码覆盖率分析系统200的上述第一实施例,提出本申请的第三实施例(如图5所示)。本实施例中,所述的代码覆盖率分析系统200还包括判断模块208及标注模块209,其中:
所述判断模块208,用于判断所述源代码的功能逻辑分支是否已经全部覆盖所述测试项目逻辑分支。
所述标注模块209,用于当所述源代码的功能逻辑分支没有全部覆盖所述测试项目逻辑分支时,标注未覆盖的测试项目逻辑分支。
所述生成模块202,还用于生成包含有标注有未覆盖的测试项目逻辑分支的功能逻辑分支覆盖率报告。
在本实施例中,当所述源代码的功能逻辑分支已经全部覆盖了所述测试项目逻辑分支时,所述应用服务器2不生成功能逻辑分支覆盖率报告。在其他实施例中,当所述源代码的功能逻辑分支已经全部覆盖了所述测试项目逻辑分支时,所述应用服务器2反馈已经全部覆盖的信息至所述终端设备1的web界面,提醒开发人员所述源代码的功能性已经完整,可以进行下一步的测试。
此外,本申请还提出一种代码覆盖率分析方法。
参阅图6所示,是本申请代码覆盖率分析方法第一实施例的流程示意图。在本实施例中,根据不同的需求,图6所示的流程图中的步骤的执行顺序可 以改变,某些步骤可以省略。
步骤S301,当接收到所述终端设备1发送的程序源代码时,分析所述源代码的结构。
通常地,传统的测试程序代码的覆盖率分析都是针对代码行的覆盖情况,但是这种通过分析代码行的覆盖情况,能够了解程序中有多少代码被执行了,并不能正代表一个功能单元的完整覆盖情况。假设一个功能单元根据不同条件需要调用4个函数组合来完成这个功能。若该功能会形成16个逻辑分支,而按代码行覆盖率统计,源代码只需要写4个逻辑分支就能把4个函数都覆盖掉,但从功能完整性上看,所述功能单元是不完整的。
举例而言,所述源代码的功能是完成用户名注册,完成注册的用户可以有不同类型的登陆方式,每一种登陆方式为一个功能逻辑分支。例如,通过调用函数A,实现用户可以通过手机号码发送认证码登陆,调用函数B,实现用户可以通过邮箱激活链接登陆,还可以同时调用函数A及函数B,实现通过邮箱激活链接的同时通过手机号码发送认证码登陆,这种情况下,如果按照传统的测试程序代码的覆盖分析,则只能分析出程序中的函数A和函数B被调用,而不能分析出同时调用函数A和函数B这一逻辑分支,从而导致测试案例出现功能覆盖不完整的情况。
因此,在本实施例中,所述应用服务器2与所述终端设备1建立长连接,当所述应用服务器2在接收到终端设备1发送的程序源代码时,所述应用服务器2分析所述源代码的结构,具体地,分析函数及方法的调用关系,结构的包含关系,类的继承关系等等。
步骤S302,根据所述源代码的结构生成所述源代码的功能逻辑分支。
具体地,根据所述源代码的结构,分析每一个功能单元调用到的功能函数,以及每一个功能函数的调用关系,进而生成源代码关于实现每一个功能的功能逻辑分支。
在本实施例中,所述应用服务器2分析所述源代码的结构,形成所述源 代码的语法树。根据所述语法树查找功能函数及与功能函数的调用关系,同时去除注释以及不需要统计覆盖率信息的公共函数等,查找功能函数,分析功能函数的调用关系。根据所述功能函数的调用关系,生成所述源代码的逻辑分支。
步骤S303,将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较。
通常地,开发人员在进行源代码设计时,必然了解待开发软件的功能。在本实施例中,为了验证所述源代码完整性,开发人员预先把源代码需要的逻辑分支存在所述应用服务器2的存储空间。在本实施例中,当生成了所述源代码的逻辑分支时,所述应用服务器2调预先存储有的待开发软件的功能逻辑分支,并将源代码的逻辑分支与待开发软件的功能逻辑分支进行分析比较,通过比较结果分析所述功能逻辑分支覆盖率。
步骤S304,根据比较结果生成所述源代码的功能逻辑分支覆盖率报告。
具体地,所述应用服务器2通过所述生成模块202根据比较结果生成所述源代码的功能逻辑分支覆盖率报告。在本实施例中,所述逻辑分支覆盖率报告包括标识出已经覆盖的函数及功能逻辑分支和没有覆盖的函数及功能逻辑分支。
步骤S305,将所述功能逻辑分支覆盖率报告反馈至终端设备1。
具体地,所述应用服务器2将所述功能逻辑分支覆盖报告发送至终端设备1的web页面显示,开发人员可以根据所述功能逻辑分支覆盖率报告检查所述源代码的完整性,即所述源代码是否已经覆盖了所有的功能逻辑分支,如有遗漏,即可进行针对性修改。
在本实施例中,所述应用服务器2还设定一存储空间,并存储所述功能逻辑分支覆盖率报告以及所述源代码至所述存储空间,便于开发人员从存储空间访问所述功能逻辑分支覆盖率报告以及所述源代码,跟进源代码的设计进展。
通过上述步骤S301-305,本申请所提出的代码覆盖率分析方法,首先当接收到所述终端设备1发送的程序源代码时,分析所述源代码的结构;然后,根据所述源代码的结构生成所述源代码的功能逻辑分支;进一步地,将所述源代码的功能逻辑分支与预存储在所述应用服务器2的测试项目逻辑分支进行比较;接着,根据比较结果生成所述源代码的功能逻辑分支覆盖率报告;最后将所述功能逻辑分支覆盖率报告反馈至终端设备1。这样,既可以避免现有技术中通过代码覆盖率统计,仅能了解到程序中有多少的代码被执行了,但是并不能真正了解一个程序模块的完整覆盖情况的缺陷,也可以使得通过逻辑分支的比较,确认源代码是否已经覆盖了所有的功能逻辑分支,保证测试项目的功能完整性。
进一步地,基于本申请代码覆盖率分析方法的上述第一实施例,提出本申请代码覆盖率分析方法的第二实施例。
如图7所示,是本申请代码覆盖率分析方法第二实施例的流程示意图。本实施例中,所述将所述源代码的功能逻辑分支与预存储在应用服务器2的测试案例逻辑分支进行比较,生成所述源代码的功能逻辑分支覆盖率报告的步骤之前,还包括如下步骤:
步骤S401,当接收到所述终端设备1发送的程序源代码时,获取所述源代码的标识。
步骤S402,根据所述标识匹配预存储在所述应用服务器的测试项目逻辑分支。
具体地,所述应用服务器2会接收多个不同的源代码,每一个源代码都会有对应的预存储在所述应用服务器2内存中的测试项目逻辑分支。为了区别每个源代码,每个源代码都有特定的标识,所述测试项目逻辑分支设置有与源代码对应的标识。当所述应用服务器2在接收到从终端设备1发送的源代码时,通过获取模块205获取所述源代码的标识,进而匹配模块206通过标识匹配预存储在所述应用服务器2的测试项目逻辑分支,从而确定对应的 测试项目逻辑分支。
步骤S403,调取所述测试项目逻辑分支。
具体地,所述应用服务器2通过所述调取模块207调取所述测试项目逻辑分支,进而与源代码的功能逻辑分支进行比较。
通过上述步骤S401-S402,本申请所提出的代码覆盖率分析方法,可以通过获取所述源代码的标识,进而匹配预存储在所述应用服务器2中的测试项目逻辑分支,以从不同的测试项目逻辑分支中确定与所述源代码对应的测试项目逻辑分支,提高测试效率。
进一步地,基于本申请代码覆盖率分析方法的上述第一和第二实施例,提出本申请代码覆盖率分析方法的第三实施例。
如图8所示,是本申请代码覆盖率分析方法第三实施例的流程示意图。本实施例中,所述生成所述源代码的功能逻辑分支覆盖率报告的步骤,具体包括:
步骤S501,判断所述源代码的功能逻辑分支是否已经全部覆盖所述测试项目逻辑分支。
步骤S502,当所述源代码的功能逻辑分支没有全部覆盖所述测试项目逻辑分支时,标注未覆盖的测试项目逻辑分支。
步骤S503,生成包含有标注有未覆盖的测试项目逻辑分支的功能逻辑分支覆盖率报告。
在本实施例中,当所述源代码的功能逻辑分支已经全部覆盖了所述测试项目逻辑分支时,所述应用服务器2不生成功能逻辑分支覆盖率报告。在其他实施例中,当所述源代码的功能逻辑分支已经全部覆盖了所述测试项目逻辑分支时,所述应用服务器2反馈已经全部覆盖的信息至所述终端设备1的web界面,提醒开发人员所述源代码的功能性已经完整,可以进行下一步的测试。
通过上述步骤S501-S503,本申请所提出的代码覆盖率分析方法,还能够 在判断出所述源代码的功能逻辑分支没有全部覆盖所述测试项目逻辑分支时,标注未覆盖的测试项目逻辑分支,并生成包含有标注有未覆盖的测试项目逻辑分支的功能逻辑分支覆盖率报告,方便开发人员直观地了解到没有被覆盖的功能逻辑分支,便于开发人员针对性修改。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种代码覆盖率分析方法,应用于应用服务器,其特征在于,所述方法包括:
    当接收到终端设备发送的程序源代码时,分析所述源代码的结构;
    根据所述源代码的结构生成所述源代码的功能逻辑分支;
    将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较;
    根据比较结果生成所述源代码的功能逻辑分支覆盖率报告;
    将所述功能逻辑分支覆盖率报告反馈至所述终端设备。
  2. 如权利要求1所述的代码覆盖率分析方法,其特征在于,所述根据所述源代码的结构生成所述源代码的逻辑分支的步骤,具体包括如下步骤:
    分析所述源代码的结构,形成所述源代码的语法树;
    根据所述语法树查找功能函数及与功能函数的调用关系;
    根据所述功能函数的调用关系,生成所述源代码的逻辑分支。
  3. 如权利要求1所述的代码覆盖率分析方法,其特征在于,所述将所述源代码的功能逻辑分支与预存储在应用服务器的测试案例逻辑分支进行比较,生成所述源代码的功能逻辑分支覆盖率报告的步骤之前,还包括如下步骤:
    当接收到所述终端设备发送的程序源代码时,获取所述源代码的标识;
    根据所述标识匹配预存储在所述应用服务器的测试项目逻辑分支;
    调取所述测试项目逻辑分支。
  4. 如权利要求2所述的代码覆盖率分析方法,其特征在于,所述将所述源代码的功能逻辑分支与预存储在应用服务器的测试案例逻辑分支进行比较,生成所述源代码的功能逻辑分支覆盖率报告的步骤之前,还包括如下步骤:
    当接收到所述终端设备发送的程序源代码时,获取所述源代码的标识;
    根据所述标识匹配预存储在所述应用服务器的测试项目逻辑分支;
    调取所述测试项目逻辑分支。
  5. 如权利要求1所述的代码覆盖率分析方法,其特征在于,所述生成所述源代码的功能逻辑分支覆盖率报告的步骤,具体包括:
    判断所述源代码的功能逻辑分支是否已经全部覆盖所述测试项目逻辑分支;
    当所述源代码的功能逻辑分支没有全部覆盖所述测试项目逻辑分支时,标注未覆盖的测试项目逻辑分支;
    生成包含有标注有未覆盖的测试项目逻辑分支的功能逻辑分支覆盖率报告。
  6. 如权利要求1所述的代码覆盖率分析方法,其特征在于,所述方法还包括:
    设定一个存储空间;
    存储所述功能逻辑分支覆盖率报告以及所述源代码至所述存储空间。
  7. 如权利要求2所述的代码覆盖率分析方法,其特征在于,所述方法还包括:
    设定一个存储空间;
    存储所述功能逻辑分支覆盖率报告以及所述源代码至所述存储空间。
  8. 如权利要求3所述的代码覆盖率分析方法,其特征在于,所述方法还包括:
    设定一个存储空间;
    存储所述功能逻辑分支覆盖率报告以及所述源代码至所述存储空间。
  9. 如权利要求5所述的代码覆盖率分析方法,其特征在于,所述方法还包括:
    设定一个存储空间;
    存储所述功能逻辑分支覆盖率报告以及所述源代码至所述存储空间。
  10. 一种应用服务器,其特征在于,所述应用服务器包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的代码覆盖率分析系统,所述代码覆盖率分析系统被所述处理器执行时实现如下步骤:
    当接收到终端设备发送的程序源代码时,分析所述源代码的结构;
    根据所述源代码的结构生成所述源代码的功能逻辑分支;
    将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较;
    根据比较结果生成所述源代码的功能逻辑分支覆盖率报告;
    将所述功能逻辑分支覆盖率报告反馈至所述终端设备。
  11. 如权利要求10所述的应用服务器,其特征在于,所述根据所述源代码的结构生成所述源代码的逻辑分支的步骤,具体包括如下步骤:
    分析所述源代码的结构,形成所述源代码的语法树;
    根据所述语法树查找功能函数及与功能函数的调用关系;
    根据所述功能函数的调用关系,生成所述源代码的逻辑分支。
  12. 如权利要求10所述的应用服务器,其特征在于,所述将所述源代码的功能逻辑分支与预存储在应用服务器的测试案例逻辑分支进行比较,生成所述源代码的功能逻辑分支覆盖率报告的步骤之前,还包括如下步骤:
    当接收到所述终端设备发送的程序源代码时,获取所述源代码的标识;
    根据所述标识匹配预存储在所述应用服务器的测试项目逻辑分支;
    调取所述测试项目逻辑分支。
  13. 如权利要求11所述的应用服务器,其特征在于,所述将所述源代码的功能逻辑分支与预存储在应用服务器的测试案例逻辑分支进行比较,生成所述源代码的功能逻辑分支覆盖率报告的步骤之前,还包括如下步骤:
    当接收到所述终端设备发送的程序源代码时,获取所述源代码的标识;
    根据所述标识匹配预存储在所述应用服务器的测试项目逻辑分支;
    调取所述测试项目逻辑分支。
  14. 如权利要求10所述的应用服务器,其特征在于,所述生成所述源代码的功能逻辑分支覆盖率报告的步骤,具体包括:
    判断所述源代码的功能逻辑分支是否已经全部覆盖所述测试项目逻辑分支;
    当所述源代码的功能逻辑分支没有全部覆盖所述测试项目逻辑分支时,标注未覆盖的测试项目逻辑分支;
    生成包含有标注有未覆盖的测试项目逻辑分支的功能逻辑分支覆盖率报告。
  15. 如权利要求10所述的应用服务器,其特征在于,所述代码覆盖率分析系统被所述处理器执行时还实现如下步骤:
    设定一个存储空间;
    存储所述功能逻辑分支覆盖率报告以及所述源代码至所述存储空间。
  16. 一种计算机可读存储介质,所述计算机可读存储介质存储有代码覆盖率分析系统,所述代码覆盖率分析系统可被至少一个处理器执行,以使所述至少一个处理器执行时实现如下步骤:
    当接收到终端设备发送的程序源代码时,分析所述源代码的结构;
    根据所述源代码的结构生成所述源代码的功能逻辑分支;
    将所述源代码的功能逻辑分支与预存储在所述应用服务器的测试项目逻辑分支进行比较;
    根据比较结果生成所述源代码的功能逻辑分支覆盖率报告;
    将所述功能逻辑分支覆盖率报告反馈至所述终端设备。
  17. 如权利要求16所述的计算机可读存储介质,其特征在于,所述根据所述源代码的结构生成所述源代码的逻辑分支的步骤,具体包括如下步骤:
    分析所述源代码的结构,形成所述源代码的语法树;
    根据所述语法树查找功能函数及与功能函数的调用关系;
    根据所述功能函数的调用关系,生成所述源代码的逻辑分支。
  18. 如权利要求16所述的计算机可读存储介质,其特征在于,所述将所述源代码的功能逻辑分支与预存储在应用服务器的测试案例逻辑分支进行比较,生成所述源代码的功能逻辑分支覆盖率报告的步骤之前,还包括如下步骤:
    当接收到所述终端设备发送的程序源代码时,获取所述源代码的标识;
    根据所述标识匹配预存储在所述应用服务器的测试项目逻辑分支;
    调取所述测试项目逻辑分支。
  19. 如权利要求16所述的计算机可读存储介质,其特征在于,所述生成所述源代码的功能逻辑分支覆盖率报告的步骤,具体包括:
    判断所述源代码的功能逻辑分支是否已经全部覆盖所述测试项目逻辑分支;
    当所述源代码的功能逻辑分支没有全部覆盖所述测试项目逻辑分支时,标注未覆盖的测试项目逻辑分支;
    生成包含有标注有未覆盖的测试项目逻辑分支的功能逻辑分支覆盖率报告。
  20. 如权利要求16所述的计算机可读存储介质,其特征在于,所述代码覆盖率分析系统被所述处理器执行时还实现如下步骤:
    设定一个存储空间;
    存储所述功能逻辑分支覆盖率报告以及所述源代码至所述存储空间。
PCT/CN2018/076141 2017-10-10 2018-02-10 代码覆盖率分析方法及应用服务器 WO2019071891A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710933579.0A CN107797923B (zh) 2017-10-10 2017-10-10 代码覆盖率分析方法及应用服务器
CN201710933579.0 2017-10-10

Publications (1)

Publication Number Publication Date
WO2019071891A1 true WO2019071891A1 (zh) 2019-04-18

Family

ID=61533000

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/076141 WO2019071891A1 (zh) 2017-10-10 2018-02-10 代码覆盖率分析方法及应用服务器

Country Status (2)

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

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108763054B (zh) * 2018-04-17 2021-03-23 平安科技(深圳)有限公司 测试案例的测试效果展示方法、电子装置及存储介质
CN109542789B (zh) * 2018-11-26 2022-03-25 泰康保险集团股份有限公司 一种代码覆盖率统计方法及装置
CN109582574B (zh) * 2018-11-27 2024-03-19 平安科技(深圳)有限公司 一种代码覆盖率统计方法、装置、存储介质及终端设备
CN111949505B (zh) * 2019-05-14 2024-05-14 阿里云计算有限公司 一种测试方法、装置及设备
CN110209576A (zh) * 2019-05-21 2019-09-06 深圳壹账通智能科技有限公司 测试用例覆盖率的计算方法及相关设备
CN110209582A (zh) * 2019-05-31 2019-09-06 口碑(上海)信息技术有限公司 代码覆盖率的统计方法及装置、电子设备、存储介质
CN110765017A (zh) * 2019-10-24 2020-02-07 上海创景信息科技有限公司 基于risc-v扩展指令的源码覆盖率测试方法和系统
CN111831573B (zh) * 2020-07-27 2024-03-08 中国工商银行股份有限公司 代码分支覆盖情况的确定方法、装置、计算机系统和介质
CN112612716B (zh) * 2020-12-28 2023-01-20 上海品顺信息科技有限公司 差异行代码覆盖率增强标记方法、系统、设备及存储介质
CN113127362A (zh) * 2021-04-23 2021-07-16 中国工商银行股份有限公司 对象测试方法、对象测试装置、电子设备及可读存储介质
CN113407393B (zh) * 2021-05-25 2023-01-24 鹏城实验室 芯片验证方法、终端设备、验证平台以及存储介质

Citations (5)

* 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
CN101706751A (zh) * 2009-11-23 2010-05-12 中兴通讯股份有限公司 软件业务功能覆盖率的统计方法及系统
CN105630670A (zh) * 2015-12-16 2016-06-01 北京奇虎科技有限公司 一种代码覆盖率的测试方法和装置
US20160328314A1 (en) * 2015-05-06 2016-11-10 Hcl Technologies Limited System and method for providing code coverage
CN106649110A (zh) * 2016-12-15 2017-05-10 中标软件有限公司 软件测试方法及系统

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100349132C (zh) * 2005-06-21 2007-11-14 华为技术有限公司 一种逻辑测试的功能覆盖率分析方法
CN101625709B (zh) * 2008-07-09 2011-05-18 华为技术有限公司 功能覆盖率的收集方法及装置
CN103164337B (zh) * 2013-02-28 2015-12-09 汉柏科技有限公司 基于有限状态机的云计算软件测试方法
CN105573908A (zh) * 2015-09-01 2016-05-11 北京中电华大电子设计有限责任公司 一种功能验证方法和装置
CN105302573A (zh) * 2015-11-20 2016-02-03 浪潮集团有限公司 一种用于功能验证平台的功能点匹配设置自动化平台的搭建方法
CN106293809A (zh) * 2016-07-28 2017-01-04 东软集团股份有限公司 优化程序的方法及装置
CN106775704B (zh) * 2016-12-12 2021-01-26 广州视源电子科技股份有限公司 软件属性需求检验方法及装置
CN106874187B (zh) * 2016-12-29 2020-09-11 腾讯科技(深圳)有限公司 代码覆盖率收集方法和装置

Patent Citations (5)

* 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
CN101706751A (zh) * 2009-11-23 2010-05-12 中兴通讯股份有限公司 软件业务功能覆盖率的统计方法及系统
US20160328314A1 (en) * 2015-05-06 2016-11-10 Hcl Technologies Limited System and method for providing code coverage
CN105630670A (zh) * 2015-12-16 2016-06-01 北京奇虎科技有限公司 一种代码覆盖率的测试方法和装置
CN106649110A (zh) * 2016-12-15 2017-05-10 中标软件有限公司 软件测试方法及系统

Also Published As

Publication number Publication date
CN107797923B (zh) 2019-04-26
CN107797923A (zh) 2018-03-13

Similar Documents

Publication Publication Date Title
WO2019071891A1 (zh) 代码覆盖率分析方法及应用服务器
US9792374B2 (en) Method and system for facilitating terminal identifiers
CN107870860B (zh) 埋点验证系统及方法
US20130117855A1 (en) Apparatus for automatically inspecting security of applications and method thereof
US10698797B2 (en) Mobile application program testing method, server, terminal, and storage medium
WO2018000607A1 (zh) 一种识别测试用例失败原因的方法及电子设备
CN107329894B (zh) 应用程序系统测试方法、装置及电子设备
CN111459495B (zh) 单元测试代码文件生成方法、电子装置及存储介质
US7536599B2 (en) Methods and systems for validating a system environment
CN110866258B (zh) 快速定位漏洞方法、电子装置及存储介质
CN108255701B (zh) 场景测试方法及移动终端
CN113076104A (zh) 页面生成方法、装置、设备及存储介质
WO2019071959A1 (zh) 增加渠道方法、应用服务器及计算机可读存储介质
CN112039900A (zh) 网络安全风险检测方法、系统、计算机设备和存储介质
CN104579830A (zh) 服务监控方法及装置
WO2019114209A1 (zh) 自动化测试分析方法、系统、应用服务器及计算机可读存储介质
US20200293688A1 (en) Report comprising a masked value
CN111654495B (zh) 用于确定流量产生来源的方法、装置、设备及存储介质
CN110688096A (zh) 包含插件的应用程序的构建方法、装置、介质及电子设备
CN110990346A (zh) 基于区块链的文件数据处理方法、装置、设备及存储介质
US10754748B2 (en) System and method for constructing extensible event log with javascript object notation (JSON) encoded payload data
CN113362173A (zh) 防重机制验证方法、验证系统、电子设备及存储介质
US20180069774A1 (en) Monitoring and reporting transmission and completeness of data upload from a source location to a destination location
CN111046393B (zh) 漏洞信息上传方法、装置、终端设备及存储介质
CN111190824B (zh) 监测方法、装置、终端设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18865641

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 24.09.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18865641

Country of ref document: EP

Kind code of ref document: A1