WO2014180396A1 - Code coverage rate processing method and device - Google Patents

Code coverage rate processing method and device Download PDF

Info

Publication number
WO2014180396A1
WO2014180396A1 PCT/CN2014/078560 CN2014078560W WO2014180396A1 WO 2014180396 A1 WO2014180396 A1 WO 2014180396A1 CN 2014078560 W CN2014078560 W CN 2014078560W WO 2014180396 A1 WO2014180396 A1 WO 2014180396A1
Authority
WO
WIPO (PCT)
Prior art keywords
test
code coverage
software
unit
testing
Prior art date
Application number
PCT/CN2014/078560
Other languages
French (fr)
Chinese (zh)
Inventor
程敏
魏霄鹏
徐双桑
刘美霞
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2014180396A1 publication Critical patent/WO2014180396A1/en

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

Definitions

  • FIG. 7 is a structural block diagram of a code coverage automatic test system according to a preferred embodiment of the present invention.
  • a flowchart of a code coverage automated test method in accordance with an embodiment of the present invention FIG. 9 is a flow diagram of a unit automated test module 76 test in accordance with a preferred embodiment of the present invention.
  • BEST MODE FOR CARRYING OUT THE INVENTION FIG. 1 is a flowchart of a code coverage processing method according to an embodiment of the present invention. As shown in FIG.
  • Step S102 software The unit scans.
  • the software unit can be a test object for code coverage. Usually, it refers to the software code of one functional module; Step S104, testing the code coverage of the scanned one or more software units; Step S106, generating code coverage test results of one or more software units .
  • the software unit is scanned, and the scanned one or more software units are tested.
  • the software unit is manually determined, and the test parameters are set by artificially. The unit is tested, resulting in a lot of human intervention, complicated process, and low test efficiency.
  • the above scanning is used to automatically test the scanned software unit, and the code coverage is completely tested.
  • Test cases, test tools, and test environments corresponding to test cases and test tools are tested; in test environments, test tools and test cases are used to test the code coverage of one or more software units that are scanned. It should be noted that the above processes are completed by automatic triggering, automatic selection, and pre-setting of automation. Among them, no human intervention is required, not only for one software unit test, but also for multiple software at the same time. Unit testing. In order to more clearly understand the test details involved in testing the software unit's code coverage, one or more of the test coverage may be generated after testing the code coverage of the scanned one or more software units. The code coverage of the software units is the result of one or more software unit tests at the time of testing.
  • the code coverage test result file generated by the unit automation test module 76 may include the code file name of the test, the total number of lines of code, and the number of lines of code tested.
  • 8 is a flowchart of a code coverage automatic test method according to an embodiment of the present invention. As shown in FIG.
  • Step S814 the next unit is scanned by the task scanning module 72; in step S816, all unit scans are completed.
  • FIG. 9 is a flowchart of a unit automation test module 76 according to a preferred embodiment of the present invention. As shown in FIG. 9, the process includes the following steps: Step S902, the unit test module 76 uploads the specified test unit through the FTP protocol. Go to the specified result server; Step S904, the unit automation test module 76 remotely launches the test platform through the TELNET protocol; Step S906, the unit auto-test module 76 starts the wake-up procedure, and sends the wake-up test message to the unit test tool; Step S908, unit The test tool receives the wake-up test message and starts the test.

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

Provided in the present invention are a method and a device for processing code coverage rates, said method comprising: scanning a software unit or units; testing the code coverage rate of the one or more scanned software units; generating code coverage rate test results for the one or more software units. The present invention overcomes the problems in current code coverage rate testing techniques of multiple human interventions, procedural complexity and low test efficiency, while also achieving complete automation of such testing, thus reducing procedural complexity and enhancing test efficiency.

Description

代码覆盖率处理方法及装置 技术领域 本发明涉及通信领域, 具体而言, 涉及一种代码覆盖率处理方法及装置。 背景技术 随着电信业务的发展, 电信增值业务的种类的增多, 提供服务的软件和设备逐步 增多, 软件的测试越来越复杂和繁琐。代码覆盖率是用来度量测试完整性的一个手段。 软件的覆盖率总体上可以分为逻辑覆盖 (代码覆盖和结构化覆盖) 和功能覆盖。 通过 覆盖率数据, 可以知道测试得是否充分, 测试的弱点在哪些方面, 进而可以指导设计 出能够增加覆盖率的测试用例。因此,代码覆盖率作为软件测试的一项重要衡量指标, 已越来越受到重视。但在相关技术中,对代码覆盖率的测试需要人工确定测试的对象, 而且测试时只能针对一个对象进行测试, 不仅人为干预多, 流程烦杂, 而且测试效率 也不高。 因此, 在相关技术中, 对代码覆盖率的测试存在人为干预多, 流程烦杂, 以及测 试效率不高的问题。 发明内容 本发明提供了一种代码覆盖率处理方法及装置, 以至少解决在相关技术中, 对代 码覆盖率的测试存在人为干预多, 流程烦杂, 以及测试效率不高的问题。 根据本发明的一个方面, 提供了一种代码覆盖率处理方法, 包括: 对软件单元进 行扫描; 对扫描到的一个或多个软件单元的代码覆盖率进行测试; 生成所述一个或多 个软件单元的代码覆盖率测试结果。 其中, 对所述软件单元进行扫描包括: 确定对所述软件单元进行扫描的预定扫描 条件; 依据确定的所述预定扫描条件对所述软件单元进行扫描。 其中, 对扫描到的所述一个或多个软件单元的所述代码覆盖率进行测试包括: 选 择对所述一个或多个软件单元的所述代码覆盖率进行测试的测试用例、 测试工具、 以 及与所述测试用例和测试工具对应的测试环境; 在所述测试环境下, 采用所述测试工 具以及所述测试用例对扫描到的所述一个或多个软件单元的代码覆盖率进行测试。 其中, 在对扫描到的所述一个或多个软件单元的所述代码覆盖率进行测试之后, 还包括: 生成对所述一个或多个软件单元的代码覆盖率进行测试时的一个或多个软件 单元测试结果。 其中, 在生成的所述一个或多个软件单元的一个或多个代码覆盖率测试结果和所 述一个或多个软件单元测试结果之后, 还包括: 对所述一个或多个代码覆盖率测试结 果和 /或所述一个或多个软件单元测试结果进行显示。 根据本发明的另一方面, 提供了一种代码覆盖率处理装置, 包括: 扫描模块, 设 置为对软件单元进行扫描; 测试模块, 设置为对扫描到的所述一个或多个软件单元的 代码覆盖率进行测试; 第一生成模块, 设置为生成所述一个或多个软件单元的代码覆 盖率测试结果。 其中, 所述扫描模块包括: 确定单元, 设置为确定对所述软件单元进行扫描的预 定扫描条件; 扫描单元, 设置为依据确定的所述预定扫描条件对所述软件单元进行扫 描。 其中, 所述测试模块包括: 选择单元, 设置为选择对所述一个或多个软件单元的 所述代码覆盖率进行测试的测试用例、 测试工具、 以及与所述测试用例和测试工具对 应的测试环境; 测试单元, 设置为在所述测试环境下, 采用所述测试工具以及所述测 试用例对扫描到的所述一个或多个软件单元的代码覆盖率进行测试。 其中, 该装置还包括: 第二生成模块, 设置为生成对所述一个或多个软件单元的 代码覆盖率进行测试时的一个或多个软件单元测试结果。 其中, 该装置还包括: 显示模块, 设置为对所述一个或多个代码覆盖率测试结果 和 /或所述一个或多个软件单元测试结果进行显示。 通过本发明, 采用对软件单元进行扫描; 对扫描到的所述一个或多个软件单元的 代码覆盖率进行测试; 生成所述一个或多个软件单元的代码覆盖率测试结果, 解决了 在相关技术中, 对代码覆盖率的测试存在人为干预多, 流程烦杂, 以及测试效率不高 的问题, 进而达到了对代码覆盖率的测试完全自动化, 不仅减少了流程的烦杂性, 而 且有效地提高了测试效率的效果。 附图说明 此处所说明的附图用来提供对本发明的进一步理解, 构成本申请的一部分, 本发 明的示意性实施例及其说明用于解释本发明, 并不构成对本发明的不当限定。 在附图 中: 图 1是根据本发明实施例的代码覆盖率处理方法的流程图; 图 2是根据本发明实施例的代码覆盖率处理装置的结构框图; 图 3是根据本发明实施例的代码覆盖率处理装置中扫描模块 22的优选结构框图; 图 4是根据本发明实施例的代码覆盖率处理装置中测试模块 24的优选结构框图; 图 5是根据本发明实施例的代码覆盖率处理装置的优选结构框图一; 图 6是根据本发明实施例的代码覆盖率处理装置的优选结构框图二; 图 7是根据本发明优选实施方式的代码覆盖率自动化测试系统的结构框图; 图 8是根据本发明实施例的代码覆盖率自动化测试方法的流程图; 图 9是根据本发明优选实施方式的单元自动化测试模块 76测试的流程图。 具体实施方式 下文中将参考附图并结合实施例来详细说明本发明。 需要说明的是, 在不冲突的 情况下, 本申请中的实施例及实施例中的特征可以相互组合。 在本实施例中提供了一种代码覆盖率处理方法, 图 1是根据本发明实施例的代码 覆盖率处理方法的流程图, 如图 1所示, 该流程包括如下步骤: 步骤 S102, 对软件单元进行扫描, 需要说明的是, 该软件单元可以为代码覆盖率 的测试对象。 通常情况下是指代一个功能性模块的软件代码; 步骤 S104, 对扫描到的一个或多个软件单元的代码覆盖率进行测试; 步骤 S106, 生成一个或多个软件单元的代码覆盖率测试结果。 通过上述步骤, 采用对软件单元进行扫描, 将扫描到的一个或多个软件单元进行 测试, 相对于相关技术中需要人为地确定软件单元后, 通过人为设置测试参数对软件 单元进行测试, 导致对代码覆盖率的测试存在人为干预多, 流程烦杂, 以及测试效率 不高的问题, 采用上述扫描, 对扫描到的软件单元进行自动测试, 实现了对代码覆盖 率的测试完全自动化, 不仅减少了流程的烦杂性,而且有效地提高了测试效率的效果。 对软件单元进行扫描时, 依据需要测试的目标软件单元的不同可以设置不同的预 定扫描条件, 也可以依据对测试的频率的不同设置不同的扫描时段 (例如, 可以设置 定时扫描), 例如, 在对软件单元进行扫描之前, 先确定对软件单元进行扫描的预定扫 描条件(例如, 对软件单元的一些筛选条件); 依据确定的预定扫描条件对软件单元进 行扫描。 对更新的一个或多个软件单元的代码覆盖率进行测试时, 实现对每个扫描到的软 件单元实现自动化的测试, 在测试的过程中, 先选择对一个或多个软件单元的代码覆 盖率进行测试的测试用例、 测试工具、 以及与测试用例和测试工具对应的测试环境; 在测试环境下, 采用测试工具以及测试用例对扫描到的一个或多个软件单元的代码覆 盖率进行测试。 需要说明的是, 上述过程均是通过自动化触发, 自动化选择, 自动化 搭建的预先设置完成的, 其中, 并不需要人为的干预, 不仅仅针对一个软件单元的测 试, 还能够同时实现对多个软件单元的测试。 为了更清楚的获知在对软件单元的代码覆盖率进行测试的过程中所涉及到的测试 细节, 可以在对扫描到的一个或多个软件单元的代码覆盖率进行测试之后, 生成对一 个或多个软件单元的代码覆盖率进行测试时的一个或多个软件单元测试结果。 该软件 单元测试结果可以包括多种内容, 例如, 可以包括以下各项至少之一: 测试的单元名 称、 使用的测试工具、 总共测试的测试用例数、 测试结果为成功的用例数、 测试结果 为失败的用例数等。 为了直观地展示代码覆盖率测试结果和 /或软件单元测试结果,在生成的一个或多 个软件单元的一个或多个代码覆盖率测试结果和一个或多个软件单元测试结果之后, 还可以对一个或多个代码覆盖率测试结果和 /或一个或多个软件单元测试结果进行显 示。 在本实施例中还提供了一种代码覆盖率处理装置, 该装置用于实现上述实施例及 优选实施方式, 已经进行过说明的不再赘述。 如以下所使用的, 术语 "模块"可以实 现预定功能的软件和 /或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实 现, 但是硬件, 或者软件和硬件的组合的实现也是可能并被构想的。 图 2是根据本发明实施例的代码覆盖率处理装置的结构框图, 如图 2所示, 该装 置包括扫描模块 22、 测试模块 24和第一生成模块 26, 下面对该装置进行说明。 扫描模块 22, 设置为对软件单元进行扫描; 测试模块 24, 连接至上述扫描模块 22,设置为对扫描到的一个或多个软件单元的代码覆盖率进行测试;第一生成模块 26, 连接至上述测试模块 24, 设置为生成一个或多个软件单元的代码覆盖率测试结果。 图 3是根据本发明实施例的代码覆盖率处理装置中扫描模块 22的优选结构框图, 如图 3所示, 该扫描模块 22包括确定单元 32和扫描单元 34, 下面对该扫描模块 22 进行说明。 确定单元 32, 设置为确定对软件单元进行扫描的预定扫描条件; 扫描单元 34, 连 接至上述确定单元 32, 设置为依据确定的预定扫描条件对软件单元进行扫描。 图 4是根据本发明实施例的代码覆盖率处理装置中测试模块 24的优选结构框图, 如图 4所示, 该测试模块 24包括选择单元 42和测试单元 44, 下面对该测试模块 24 进行说明。 选择单元 42, 设置为选择对一个或多个软件单元的代码覆盖率进行测试的测试用 例、 测试工具、 以及与测试用例和测试工具对应的测试环境; 测试单元 44, 连接至上 述选择单元 42, 设置为在测试环境下, 采用测试工具以及测试用例对扫描到的一个或 多个软件单元的代码覆盖率进行测试。 图 5是根据本发明实施例的代码覆盖率处理装置的优选结构框图一,如图 5所示, 该装置除包括图 2所示的所有模块外, 还包括: 第二生成模块 52, 下面对该第二生成 模块 52进行说明。 该第二生成模块 52,连接至上述测试模块 24,设置为生成对一个或多个软件单元 的代码覆盖率进行测试时的一个或多个软件单元测试结果。 图 6是根据本发明实施例的代码覆盖率处理装置的优选结构框图二,如图 6所示, 该装置除包括图 5所示的所有模块外, 还包括显示模块 62, 下面对该显示模块 62进 行说明。 显示模块 62, 连接至上述第一生成模块 26和 /或第二生成模块 52, 设置为对一个 或多个代码覆盖率测试结果和 /或一个或多个软件单元测试结果进行显示。 针对相关技术中无法实现代码覆盖率的自动化测试, 在本实施例中提供了一种实 现代码覆盖率自动化测试的方案, 该方案包括: 定时扫描更新的单元, 对扫描到更新 的单元, 调用单元自动化测试功能进行自动化测试, 并将单元测试结果和单元测试的 代码覆盖率结果上传到指定服务器。 同时提供给界面, 用以直观的展示各单元历次测 试过程和结果, 比对历次结果文件更新。 下面结合附图对本发明优选实施方式进行说明。 图 7是根据本发明优选实施方式的代码覆盖率自动化测试系统的结构框图, 如图 7所示, 该系统包括: 界面模块 70 (功能同上述显示模块 62)、 任务扫描模块 72 (功 能同上述扫描模块 22)、结果服务器 74和单元自动化测试模块 76 (功能同上述测试模 块 24)。 界面模块 70, 设置为展示各单元历次测试过程和结果, 浏览测试结果文件, 浏览 测试的代码覆盖率结果, 和比对历次结果文件更新的功能。 任务扫描模块 72, 设置为根据设置的任务条件, 定时扫描更新的单元, 调用单元 自动化测试模块 76, 将测试结果上传到指定的结果服务器 74。 结果服务器 74, 设置为保存任务扫描模块 72中产生的结果文件。 单元自动化测试模块 76 (可以是多个, 例如, 单元 1 自动化测试模块〜单元 n自 动化测模块) 搭建测试环境, 发送测试消息, 进行指定测试例测试。 单元自动化测试模块 76, 设置为实现对每个单元设备进行自动化测试的目的, 自 动搭建测试环境, 自动发送测试消息, 自动进行指定测试用例测试, 自动生成单元测 试结果文件和单元测试的代码覆盖率结果文件。 单元自动化测试模块 76, 自动启动测试工具, 将需要测试的单元上传到指定的结 果服务器上, 远程启动测试平台, 搭建测试环境。 单元自动化测试模块 76, 还可以启动一个唤醒测试程序, 该程序发送一个唤醒测 试消息给测试工具, 测试工具收到唤醒测试消息后开始发送测试消息到测试单元。 其 中, 该测试工具可以根据指定测试用例对测试单元进行测试。 单元自动化测试模块 76, 还设置为自动扫描结果文件是否生成, 当扫描到结果文 件生成, 停止测试工具, 关闭测试环境。 其中, 该单元自动化测试模块生成的结果文 件包括单元测试结果文件和测试的代码覆盖率结果文件。 其中,该单元自动化测试模块 76生成的单元测试结果文件可以是一个通用的指定 格式的文件, 包括测试的单元名称, 使用的测试工具, 总共测试的测试用例数, 测试 结果为成功的用例数,测试结果为失败的用例数。单元自动化测试模块 76生成的代码 覆盖率测试结果文件可以包括测试的代码文件名, 代码总行数, 测试的代码行数。 图 8是根据本发明实施例的代码覆盖率自动化测试方法的流程图, 如图 8所示, 该流程包括如下步骤: 步骤 S802, 由任务扫描模块 72根据任务配置的时间定时扫描各单元; 步骤 S804, 由任务扫描模块 72判断当前单元是否有更新, 如果有更新进入步骤 S806, 否则进入步骤 S808; 步骤 S806, 由任务扫描模块 72调用单元自动化测试模块 76, 开始自动化测试; 步骤 S808, 在扫描到更新的一个或多个软件单元时, 对更新的一个或多个软件单 元的代码覆盖率进行测试,并由任务扫描模块 72将结果文件上传到指定的结果服务器 74; 步骤 S810, 由界面模块 70展示本单元测试结果。 步骤 S812, 由界面模块 70展示单元测试的代码覆盖率测试结果。 步骤 S814, 由任务扫描模块 72扫描下一单元; 步骤 S816, 所有单元扫描完成。 图 9是根据本发明优选实施方式的单元自动化测试模块 76测试的流程图, 如图 9 所示, 该流程包括如下步骤: 步骤 S902, 由单元自动化测试模块 76将指定的测试单元通过 FTP协议上传到指 定的结果服务器上; 步骤 S904, 由单元自动化测试模块 76通过 TELNET协议远程启动测试平台; 步骤 S906, 由单元自动化测试模块 76启动唤醒程序, 发送唤醒测试消息到单元 测试工具; 步骤 S908, 单元测试工具收到唤醒测试消息, 开始进行测试; 步骤 S910, 单元自动化测试模块 76扫描结果文件是否生成; 步骤 S912, 单元自动化测试模块 76判断结果文件未生成时等待超时; 步骤 S914,单元结果文件已经生成或者超时,停止测试工具,远程停止测试平台。 显然, 本领域的技术人员应该明白, 上述的本发明的各模块或各步骤可以用通用 的计算装置来实现, 它们可以集中在单个的计算装置上, 或者分布在多个计算装置所 组成的网络上, 可选地, 它们可以用计算装置可执行的程序代码来实现, 从而, 可以 将它们存储在存储装置中由计算装置来执行, 并且在某些情况下, 可以以不同于此处 的顺序执行所示出或描述的步骤, 或者将它们分别制作成各个集成电路模块, 或者将 它们中的多个模块或步骤制作成单个集成电路模块来实现。 这样, 本发明不限制于任 何特定的硬件和软件结合。 以上所述仅为本发明的优选实施例而已, 并不用于限制本发明, 对于本领域的技 术人员来说, 本发明可以有各种更改和变化。 凡在本发明的精神和原则之内, 所作的 任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之内。 工业实用性 如上所述, 通过本发明不仅解决了在相关技术中, 对代码覆盖率的测试存在人为 干预多, 流程烦杂, 以及测试效率不高的问题, 实现了对代码覆盖率的测试完全自动 化, 不仅减少了流程的烦杂性, 而且有效地提高了测试效率。 The present invention relates to the field of communications, and in particular to a code coverage processing method and apparatus. BACKGROUND With the development of telecommunication services, the types of telecom value-added services are increasing, software and devices for providing services are gradually increasing, and software testing is increasingly complicated and cumbersome. Code coverage is a means of measuring test integrity. Software coverage can be broadly divided into logical coverage (code coverage and structured coverage) and functional coverage. Through the coverage data, you can know whether the test is sufficient and the weaknesses of the test, and then you can guide the design of test cases that can increase the coverage. Therefore, code coverage has become an increasingly important measure of software testing. However, in the related art, the test of the code coverage needs to manually determine the object of the test, and the test can only be tested for one object, not only the human intervention is more, the process is complicated, and the test efficiency is not high. Therefore, in the related art, the test of code coverage has many problems of human intervention, complicated processes, and low test efficiency. SUMMARY OF THE INVENTION The present invention provides a code coverage processing method and apparatus to at least solve the problem that in the related art, the code coverage rate test has many human interventions, complicated processes, and low test efficiency. According to an aspect of the present invention, a code coverage processing method is provided, comprising: scanning a software unit; testing code coverage of the scanned one or more software units; generating the one or more software The unit's code coverage test results. The scanning the software unit includes: determining a predetermined scanning condition for scanning the software unit; and scanning the software unit according to the determined predetermined scanning condition. Wherein testing the code coverage of the scanned one or more software units comprises: selecting test cases, testing tools, and testing the code coverage of the one or more software units a test environment corresponding to the test case and the test tool; in the test environment, the test tool and the test case are used to test the code coverage of the scanned one or more software units. After testing the code coverage of the scanned one or more software units, the method further includes: generating one or more when testing the code coverage of the one or more software units Software unit test results. Wherein, after the generated one or more code coverage test results of the one or more software units and the one or more software unit test results, the method further comprises: testing the one or more code coverage ratios The results and/or the one or more software unit test results are displayed. According to another aspect of the present invention, a code coverage processing apparatus is provided, comprising: a scanning module configured to scan a software unit; a testing module configured to code the scanned one or more software units Coverage is tested; a first generation module is configured to generate code coverage test results for the one or more software units. The scanning module includes: a determining unit configured to determine a predetermined scanning condition for scanning the software unit; and a scanning unit configured to scan the software unit according to the determined predetermined scanning condition. The test module includes: a selection unit configured to select a test case, a test tool, and a test corresponding to the test case and the test tool for testing the code coverage of the one or more software units An environment; a test unit configured to test, in the test environment, code coverage of the scanned one or more software units using the test tool and the test case. The apparatus further includes: a second generation module configured to generate one or more software unit test results when the code coverage of the one or more software units is tested. The apparatus further includes: a display module configured to display the one or more code coverage test results and/or the one or more software unit test results. Through the present invention, scanning a software unit; testing code coverage of the scanned one or more software units; generating code coverage test results of the one or more software units, and solving related In the technology, the test of code coverage has many human interventions, complicated processes, and low test efficiency, which has completely automated the testing of code coverage, which not only reduces the complexity of the process, but also effectively improves the efficiency. The effect of testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS The accompanying drawings, which are set to illustrate,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, In the drawings: FIG. 1 is a flowchart of a code coverage processing method according to an embodiment of the present invention; FIG. 2 is a structural block diagram of a code coverage processing apparatus according to an embodiment of the present invention; A preferred block diagram of the scanning module 22 in the code coverage processing apparatus; FIG. 4 is a block diagram showing a preferred structure of the testing module 24 in the code coverage processing apparatus according to an embodiment of the present invention; FIG. 5 is a code coverage processing according to an embodiment of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS FIG. 6 is a block diagram showing a preferred structure of a code coverage processing apparatus according to an embodiment of the present invention; FIG. 7 is a structural block diagram of a code coverage automatic test system according to a preferred embodiment of the present invention; A flowchart of a code coverage automated test method in accordance with an embodiment of the present invention; FIG. 9 is a flow diagram of a unit automated test module 76 test in accordance with a preferred embodiment of the present invention. BEST MODE FOR CARRYING OUT THE INVENTION Hereinafter, the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict. In this embodiment, a code coverage processing method is provided. FIG. 1 is a flowchart of a code coverage processing method according to an embodiment of the present invention. As shown in FIG. 1, the process includes the following steps: Step S102, software The unit scans. It should be noted that the software unit can be a test object for code coverage. Usually, it refers to the software code of one functional module; Step S104, testing the code coverage of the scanned one or more software units; Step S106, generating code coverage test results of one or more software units . Through the above steps, the software unit is scanned, and the scanned one or more software units are tested. Compared with the related art, the software unit is manually determined, and the test parameters are set by artificially. The unit is tested, resulting in a lot of human intervention, complicated process, and low test efficiency. The above scanning is used to automatically test the scanned software unit, and the code coverage is completely tested. Automation not only reduces the complexity of the process, but also effectively improves the efficiency of the test. When scanning a software unit, different predetermined scanning conditions may be set according to different target software units to be tested, or different scanning periods may be set according to different frequency of testing (for example, timing scanning may be set), for example, Prior to scanning the software unit, predetermined scan conditions for scanning the software unit (eg, some screening conditions for the software unit) are determined; the software unit is scanned in accordance with the determined predetermined scan conditions. When testing the code coverage of one or more software units that are updated, an automated test is performed on each scanned software unit. During the test, code coverage for one or more software units is selected. Test cases, test tools, and test environments corresponding to test cases and test tools are tested; in test environments, test tools and test cases are used to test the code coverage of one or more software units that are scanned. It should be noted that the above processes are completed by automatic triggering, automatic selection, and pre-setting of automation. Among them, no human intervention is required, not only for one software unit test, but also for multiple software at the same time. Unit testing. In order to more clearly understand the test details involved in testing the software unit's code coverage, one or more of the test coverage may be generated after testing the code coverage of the scanned one or more software units. The code coverage of the software units is the result of one or more software unit tests at the time of testing. The software unit test result may include a plurality of contents, for example, may include at least one of the following: a unit name of the test, a test tool used, a total number of test cases tested, a test result number of successful use cases, and a test result of The number of failed use cases, etc. In order to visually demonstrate code coverage test results and/or software unit test results, after one or more code coverage test results and one or more software unit test results of one or more software units are generated, One or more code coverage test results and/or one or more software unit test results are displayed. In the embodiment, a code coverage processing device is provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and has not been described again. As used hereinafter, the term "module" may implement a combination of software and/or hardware of a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware, is also possible and conceivable. 2 is a block diagram showing the structure of a code coverage processing apparatus according to an embodiment of the present invention. As shown in FIG. 2, the apparatus includes a scanning module 22, a testing module 24, and a first generating module 26. The apparatus will be described below. The scanning module 22 is configured to scan the software unit; the testing module 24 is connected to the scanning module 22, and is configured to test the code coverage of the scanned one or more software units; the first generating module 26 is connected to The test module 24 is configured to generate code coverage test results for one or more software units. FIG. 3 is a block diagram showing a preferred structure of the scanning module 22 in the code coverage processing apparatus according to the embodiment of the present invention. As shown in FIG. 3, the scanning module 22 includes a determining unit 32 and a scanning unit 34, and the scanning module 22 is performed below. Description. The determining unit 32 is arranged to determine a predetermined scanning condition for scanning the software unit; the scanning unit 34 is connected to the determining unit 32, and is configured to scan the software unit according to the determined predetermined scanning condition. 4 is a block diagram showing a preferred structure of a test module 24 in a code coverage processing apparatus according to an embodiment of the present invention. As shown in FIG. 4, the test module 24 includes a selection unit 42 and a test unit 44, and the test module 24 is performed below. Description. The selecting unit 42 is configured to select a test case, a test tool, and a test environment corresponding to the test case and the test tool for testing the code coverage of the one or more software units; the test unit 44 is connected to the selection unit 42, Set to test the code coverage of one or more software units scanned using test tools and test cases in a test environment. FIG. 5 is a block diagram of a preferred structure of a code coverage processing apparatus according to an embodiment of the present invention. As shown in FIG. 5, the apparatus includes, in addition to all the modules shown in FIG. 2, a second generation module 52, below. The second generation module 52 will be described. The second generation module 52 is coupled to the test module 24 and configured to generate one or more software unit test results when testing code coverage of one or more software units. 6 is a block diagram of a preferred structure of a code coverage processing apparatus according to an embodiment of the present invention. As shown in FIG. 6, the apparatus includes a display module 62 in addition to all the modules shown in FIG. Module 62 is described. The display module 62 is coupled to the first generation module 26 and/or the second generation module 52, and is configured to display one or more code coverage test results and/or one or more software unit test results. In the embodiment, an automatic test for implementing code coverage is provided, which includes: a unit for periodically scanning and updating, a unit for scanning to updating, and a calling unit. Automated testing capabilities for automated testing, and unit test results and unit testing The code coverage result is uploaded to the specified server. At the same time, it is provided to the interface to visually display the test process and results of each unit, and compare the previous result files. Preferred embodiments of the present invention will now be described with reference to the accompanying drawings. 7 is a structural block diagram of a code coverage automatic test system according to a preferred embodiment of the present invention. As shown in FIG. 7, the system includes: an interface module 70 (functioning with the display module 62 described above), and a task scanning module 72 (functioning as described above) Scan module 22), result server 74, and unit automation test module 76 (functioning as test module 24 described above). The interface module 70 is configured to display the test process and results of each unit, browse the test result file, browse the code coverage result of the test, and compare the functions of the previous result files. The task scanning module 72 is configured to periodically scan the updated unit according to the set task condition, call the unit automation test module 76, and upload the test result to the specified result server 74. The result server 74 is arranged to save the result file generated in the task scan module 72. The unit automation test module 76 (may be multiple, for example, unit 1 automated test module ~ unit n automated test module) to set up a test environment, send test messages, and perform specified test case tests. The unit automation test module 76 is configured to implement automatic test for each unit device, automatically set up a test environment, automatically send test messages, automatically perform specified test case tests, and automatically generate unit test result files and unit test code coverage. Result file. The unit automation test module 76 automatically starts the test tool, uploads the unit to be tested to the specified result server, remotely starts the test platform, and builds the test environment. The unit automation test module 76 can also start a wake-up test program, which sends a wake-up test message to the test tool, and the test tool starts sending the test message to the test unit after receiving the wake-up test message. The test tool can test the test unit according to the specified test case. The unit automation test module 76 is also set to automatically scan whether the result file is generated, when the scan results to the file generation, stop the test tool, and close the test environment. The result file generated by the unit automated test module includes a unit test result file and a code coverage result file of the test. The unit test result file generated by the unit automated test module 76 may be a general specified format file, including the unit name of the test, the test tool used, the total number of test cases tested, and the test. The result is the number of successful use cases, and the test result is the number of failed use cases. The code coverage test result file generated by the unit automation test module 76 may include the code file name of the test, the total number of lines of code, and the number of lines of code tested. 8 is a flowchart of a code coverage automatic test method according to an embodiment of the present invention. As shown in FIG. 8, the process includes the following steps: Step S802, the task scanning module 72 scans each unit according to a time schedule configured by a task; S804, the task scanning module 72 determines whether the current unit has an update, if there is an update to step S806, otherwise proceeds to step S808; step S806, the task scanning module 72 calls the unit automation test module 76 to start the automated test; step S808, in the scan When the one or more software units are updated, the code coverage of the updated one or more software units is tested, and the result file is uploaded by the task scanning module 72 to the specified result server 74; Step S810, by the interface module 70 shows the results of this unit test. Step S812, the code coverage test result of the unit test is displayed by the interface module 70. Step S814, the next unit is scanned by the task scanning module 72; in step S816, all unit scans are completed. FIG. 9 is a flowchart of a unit automation test module 76 according to a preferred embodiment of the present invention. As shown in FIG. 9, the process includes the following steps: Step S902, the unit test module 76 uploads the specified test unit through the FTP protocol. Go to the specified result server; Step S904, the unit automation test module 76 remotely launches the test platform through the TELNET protocol; Step S906, the unit auto-test module 76 starts the wake-up procedure, and sends the wake-up test message to the unit test tool; Step S908, unit The test tool receives the wake-up test message and starts the test. In step S910, the unit automation test module 76 scans whether the result file is generated. In step S912, the unit automation test module 76 determines that the result file is not generated and waits for timeout; In step S914, the unit result file has been generated or timed out, the test tool is stopped, and the test platform is stopped remotely. Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general-purpose computing device, which can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device, such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein. The steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps are fabricated as a single integrated circuit module. Thus, the invention is not limited to any specific combination of hardware and software. The above is only the preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes can be made to the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and scope of the present invention are intended to be included within the scope of the present invention. INDUSTRIAL APPLICABILITY As described above, the present invention not only solves the problem that in the related art, the code coverage rate test has many human interventions, complicated processes, and low test efficiency, and the test of code coverage is completely automated. , not only reduces the complexity of the process, but also effectively improves the testing efficiency.

Claims

权 利 要 求 书 Claim
1. 一种代码覆盖率处理方法, 包括: 1. A code coverage processing method, comprising:
对软件单元进行扫描;  Scan the software unit;
对扫描到的一个或多个软件单元的代码覆盖率进行测试;  Testing the code coverage of one or more software units scanned;
生成所述一个或多个软件单元的代码覆盖率测试结果。  Generating code coverage test results for the one or more software units.
2. 根据权利要求 1所述的方法, 其中, 对所述软件单元进行扫描包括: 2. The method of claim 1, wherein scanning the software unit comprises:
确定对所述软件单元进行扫描的预定扫描条件;  Determining a predetermined scan condition for scanning the software unit;
依据确定的所述预定扫描条件对所述软件单元进行扫描。  The software unit is scanned in accordance with the determined predetermined scan condition.
3. 根据权利要求 1所述的方法, 其中, 对扫描到的所述一个或多个软件单元的所 述代码覆盖率进行测试包括: 3. The method of claim 1, wherein testing the code coverage of the scanned one or more software units comprises:
选择对所述一个或多个软件单元的所述代码覆盖率进行测试的测试用例、 测试工具、 以及与所述测试用例和测试工具对应的测试环境;  Selecting test cases, test tools, and test environments corresponding to the test cases and test tools for testing the code coverage of the one or more software units;
在所述测试环境下, 采用所述测试工具以及所述测试用例对扫描到的所述 一个或多个软件单元的代码覆盖率进行测试。  In the test environment, the test tool and the test case are used to test the code coverage of the scanned one or more software units.
4. 根据权利要求 1所述的方法, 其中, 在对扫描到的所述一个或多个软件单元的 所述代码覆盖率进行测试之后, 还包括: 4. The method according to claim 1, wherein after testing the code coverage of the scanned one or more software units, the method further comprises:
生成对所述一个或多个软件单元的代码覆盖率进行测试时的一个或多个软 件单元测试结果。  One or more software unit test results are generated when testing the code coverage of the one or more software units.
5. 根据权利要求 4所述的方法, 其中, 在生成的所述一个或多个软件单元的一个 或多个代码覆盖率测试结果和所述一个或多个软件单元测试结果之后,还包括: 对所述一个或多个代码覆盖率测试结果和 /或所述一个或多个软件单元测 试结果进行显示。 5. The method of claim 4, wherein after the one or more code coverage test results of the one or more software units and the one or more software unit test results are generated, the method further comprises: The one or more code coverage test results and/or the one or more software unit test results are displayed.
6. 一种代码覆盖率处理装置, 包括: 6. A code coverage processing apparatus, comprising:
扫描模块, 设置为对软件单元进行扫描;  a scanning module, configured to scan a software unit;
测试模块,设置为对扫描到的一个或多个软件单元的代码覆盖率进行测试; 第一生成模块, 设置为生成所述一个或多个软件单元的代码覆盖率测试结 果。 a test module configured to test code coverage of one or more software units scanned; The first generation module is configured to generate a code coverage test result of the one or more software units.
7. 根据权利要求 6所述的装置, 其中, 所述扫描模块包括: The device according to claim 6, wherein the scanning module comprises:
确定单元, 设置为确定对所述软件单元进行扫描的预定扫描条件; 扫描单元,设置为依据确定的所述预定扫描条件对所述软件单元进行扫描。  a determining unit, configured to determine a predetermined scanning condition for scanning the software unit; and a scanning unit configured to scan the software unit according to the determined predetermined scanning condition.
8. 根据权利要求 6所述的装置, 其中, 所述测试模块包括: The device according to claim 6, wherein the test module comprises:
选择单元, 设置为选择对所述一个或多个软件单元的所述代码覆盖率进行 测试的测试用例、测试工具、以及与所述测试用例和测试工具对应的测试环境; 测试单元, 设置为在所述测试环境下, 采用所述测试工具以及所述测试用 例对扫描到的所述一个或多个软件单元的代码覆盖率进行测试。  a selection unit configured to select a test case, a test tool, and a test environment corresponding to the test case and the test tool for testing the code coverage of the one or more software units; the test unit is set to In the test environment, the test tool and the test case are used to test the code coverage of the scanned one or more software units.
9. 根据权利要求 6所述的装置, 其中, 还包括: 第二生成模块, 设置为生成对所述一个或多个软件单元的代码覆盖率进行 测试时的一个或多个软件单元测试结果。 9. The apparatus of claim 6, further comprising: a second generation module configured to generate one or more software unit test results when testing code coverage of the one or more software units.
10. 根据权利要求 9所述的装置, 其中, 还包括: 显示模块,设置为对所述一个或多个代码覆盖率测试结果和 /或所述一个或 多个软件单元测试结果进行显示。 10. The apparatus of claim 9, further comprising: a display module configured to display the one or more code coverage test results and/or the one or more software unit test results.
PCT/CN2014/078560 2013-12-06 2014-05-27 Code coverage rate processing method and device WO2014180396A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310656105.8 2013-12-06
CN201310656105.8A CN104699596A (en) 2013-12-06 2013-12-06 Method and device for processing code coverage rate

Publications (1)

Publication Number Publication Date
WO2014180396A1 true WO2014180396A1 (en) 2014-11-13

Family

ID=51866776

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/078560 WO2014180396A1 (en) 2013-12-06 2014-05-27 Code coverage rate processing method and device

Country Status (2)

Country Link
CN (1) CN104699596A (en)
WO (1) WO2014180396A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106294182A (en) * 2016-08-24 2017-01-04 腾讯科技(深圳)有限公司 A kind of determine many survey the feedback method of effectiveness, test equipment and system
CN106294129A (en) * 2016-07-27 2017-01-04 北京小米移动软件有限公司 Code coverage method of testing and device
CN109460357A (en) * 2018-10-19 2019-03-12 北京新能源汽车股份有限公司 A kind of test method of code coverage, device and equipment

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111104333A (en) * 2019-12-20 2020-05-05 广州品唯软件有限公司 Coverage rate test method, test device and computer readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1744092A (en) * 2004-09-04 2006-03-08 华为技术有限公司 Method and system for automatic schedule logic simulation and code coverage rate analysis
CN1983209A (en) * 2005-12-14 2007-06-20 中兴通讯股份有限公司 System and method for automatically testing software unit
CN101706751A (en) * 2009-11-23 2010-05-12 中兴通讯股份有限公司 Method and system for calculating coverage rate of service functions of software
CN103365771A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Method and equipment for obtaining code coverage rate
CN103425573A (en) * 2012-05-24 2013-12-04 腾讯科技(深圳)有限公司 Code testing information collecting method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060236156A1 (en) * 2005-04-15 2006-10-19 Microsoft Corporation Methods and apparatus for handling code coverage data

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1744092A (en) * 2004-09-04 2006-03-08 华为技术有限公司 Method and system for automatic schedule logic simulation and code coverage rate analysis
CN1983209A (en) * 2005-12-14 2007-06-20 中兴通讯股份有限公司 System and method for automatically testing software unit
CN101706751A (en) * 2009-11-23 2010-05-12 中兴通讯股份有限公司 Method and system for calculating coverage rate of service functions of software
CN103365771A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Method and equipment for obtaining code coverage rate
CN103425573A (en) * 2012-05-24 2013-12-04 腾讯科技(深圳)有限公司 Code testing information collecting method and system

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106294129A (en) * 2016-07-27 2017-01-04 北京小米移动软件有限公司 Code coverage method of testing and device
CN106294182A (en) * 2016-08-24 2017-01-04 腾讯科技(深圳)有限公司 A kind of determine many survey the feedback method of effectiveness, test equipment and system
CN106294182B (en) * 2016-08-24 2021-02-09 腾讯科技(深圳)有限公司 Method, test equipment and system for determining public test feedback effectiveness
CN109460357A (en) * 2018-10-19 2019-03-12 北京新能源汽车股份有限公司 A kind of test method of code coverage, device and equipment

Also Published As

Publication number Publication date
CN104699596A (en) 2015-06-10

Similar Documents

Publication Publication Date Title
CN105389191B (en) A kind of method for upgrading software based on LAN, device and system
CN111159049B (en) Automatic interface testing method and system
CN105550051B (en) The asynchronous processing method and device of service request
JP2019501551A5 (en) Cloud-based system and method for managing messages related to operation of cable test devices and computing devices
CN105302722B (en) CTS automatic testing method and device
WO2015192608A1 (en) Method for updating app in android system, terminal and storage medium
WO2014180396A1 (en) Code coverage rate processing method and device
US20060218263A1 (en) System and method to simulate a plurality of networked programmable logic controllers
CN107491321A (en) A kind of processing method and processing device for being used to realize automatic software updating
CN106533803B (en) CPE configuration method and device based on TR069 agreement
CN103716209A (en) Tunnel concurrent testing system and device
CN115422048A (en) Link stability testing method and device, computer equipment and storage medium
CN105117344B (en) A kind of Interface integration method of testing and system based on PB
CN110543428A (en) Application system testing method and device
CN110445658B (en) Message processing method and system
JP5545846B2 (en) Sequence test apparatus and sequence test method
JP5996150B2 (en) Programmable display and drawing software
CN106059794A (en) Monitoring method and monitoring apparatus
JP5584017B2 (en) Sequence test apparatus and sequence test method
CN112765038B (en) Distributed cluster software testing method, device, equipment and storage medium
CN109960659B (en) Method and device for detecting application program
JP5461646B2 (en) Remote connection process monitoring method and remote connection monitoring system
CN112433938A (en) Method and device for testing application of mobile terminal
JP5814413B2 (en) Test apparatus and test method
WO2017197829A1 (en) Test information management method and apparatus, and test case execution system and device

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: 14794727

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14794727

Country of ref document: EP

Kind code of ref document: A1