WO2019071929A1 - Unit testing code coverage (cc) generation method and apparatus, readable storage medium, and device - Google Patents

Unit testing code coverage (cc) generation method and apparatus, readable storage medium, and device Download PDF

Info

Publication number
WO2019071929A1
WO2019071929A1 PCT/CN2018/082346 CN2018082346W WO2019071929A1 WO 2019071929 A1 WO2019071929 A1 WO 2019071929A1 CN 2018082346 W CN2018082346 W CN 2018082346W WO 2019071929 A1 WO2019071929 A1 WO 2019071929A1
Authority
WO
WIPO (PCT)
Prior art keywords
error
coverage
test
sub
difference
Prior art date
Application number
PCT/CN2018/082346
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 WO2019071929A1 publication Critical patent/WO2019071929A1/en

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Definitions

  • the present invention relates to the field of software testing technologies, and in particular, to a unit test coverage generation method, apparatus, readable storage medium, and device.
  • Unit testing is an important and necessary part of the formal submission of the program to the tester for large-scale functional testing.
  • Unit testing refers to the logic check and verification of the smallest testable unit in the program, where the unit is the specified minimum tested function module.
  • JVM Test Java Virtual Machine Unit Test
  • Equipment Test Instrumentation Test
  • JVM Test it is generally implemented by running a test case written in pure Java code, without relying on other components, because the code runs on the JVM virtual machine, the test speed is faster; for the Instrumentation Test Because this kind of test needs to rely on the components provided by the Android system, it needs to be deployed and run on the real machine or simulator, and needs to be pre-compiled, so the test speed is slow.
  • the coverage ratio is the ratio of the code executed by the unit test to the original code, and the coverage rate is higher. High, the greater the amount of code executed, the higher the quality of the test and the better the robustness of the code.
  • the present invention has been made in order to provide a unit test coverage generation method, apparatus, readable storage medium and apparatus that overcome the above problems or at least partially solve the above problems.
  • An embodiment of the present invention provides a unit test coverage generation method, where the method includes:
  • the first error is calculated by the following formula:
  • Y P is the first error
  • x [n-th sub-alias] The n-th sub-data, t n with the x [n-th sub-alias] parameter corresponding to orthogonal
  • E is the residual Factor
  • n is the number of subpackages.
  • the second error is calculated by the following formula:
  • F is the second error
  • x' ⁇ [x' 0 , x' 1 ... x' n ] is the test coverage data set
  • n' is the number of elements included in the test coverage data set.
  • the absolute value of the difference is obtained by the following formula:
  • is the absolute value of the difference
  • Y P is the first error
  • F is the second error
  • the coverage testing is performed on each sub-packet obtained after the packet processing, including:
  • the coverage test based on the Java virtual machine unit test or the device test is performed separately for each sub-packet obtained after the packet processing.
  • the preset coverage standard value ranges from 0.1 to 0.5.
  • An embodiment of the present invention provides a unit test coverage generation apparatus, where the apparatus includes:
  • a sub-package module for performing S1 performing packetization processing on the multiplexing test code block in the unit test process based on the business logic;
  • a first calculating module configured to execute S2: data of each packet obtained after the packet processing, and calculate a prediction coverage data set error as a first error;
  • a second calculating module configured to perform S3: performing coverage testing on each packet obtained after the packet processing, and calculating a test coverage data set error as a second error;
  • a determining module configured to execute S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
  • a processing module configured to: if the absolute value of the difference is less than or equal to the preset coverage standard value, output the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage
  • the standard value is used to sequentially improve the refinement processing of each sub-packet obtained after the packet processing, and cyclically execute S2-S4 until the absolute value of the difference is less than or equal to the preset. Coverage standard value.
  • the first error is calculated by the following formula:
  • Y P is the first error
  • x [n-th sub-alias] The n-th sub-data, t n with the x [n-th sub-alias] parameter corresponding to orthogonal
  • E is the residual Factor
  • n is the number of subpackages.
  • the embodiment of the invention provides a computer readable storage medium, on which a computer program is stored, and when the program is executed by the processor, the following steps are implemented:
  • An embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored on the memory and operable on the processor, where the processor implements the following steps:
  • the present application first performs packetization processing on the multiplexing test code block in the unit testing process based on the business logic, reduces the coupling degree of the multiplexing test code block, and calculates the prediction coverage based on the data of each packet obtained after the packet processing.
  • the error of the rate data set is the first error.
  • the coverage test is performed on each packet obtained after the packet processing, and the error of the test coverage data set is calculated as the second error, and the first error and the second error are determined.
  • the preset coverage standard value is used to sequentially improve the refinement degree of the business logic, and then perform sub-packet processing on each sub-packet obtained after the packet processing, and cyclically execute the error calculation and comparison judgment process until the absolute value of the difference is less than or equal to
  • the preset coverage standard value effectively solves the coverage base caused by directly incorporating the multiplexed code block into the coverage calculation process. Big problems and improve the accuracy of the calculated coverage and decrease the error coverage.
  • FIG. 1 is a flowchart of a unit test coverage generation method in an embodiment of the present invention
  • FIG. 2 is a structural diagram of a unit test coverage generation apparatus in an embodiment of the present invention.
  • FIG. 3 is a schematic diagram showing the physical structure of a computer device in an embodiment of the present invention.
  • the embodiment of the present application provides a unit test coverage generation method, which may be applied to an Android system, and the coding language of the method may be Java. As shown in Figure 1, the method includes:
  • S1 Perform packet processing on the multiplexing test code block in the unit testing process based on the business logic.
  • S1 performs the process of packet multiplexing test code blocks, the purpose of which is to reduce the degree of coupling between the various multiplex test code blocks.
  • the application migrates the same multiplexing test code block with the same business logic to the same package path to implement the packet processing.
  • the following provides a sub-package example to explain S1:
  • the business logic corresponding to the packet is an initialization activity, and the business logic of the multiplexing test code block included in the packet belongs to the initialization activity.
  • S2 is performed: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing.
  • X T [x [activity_init] , x [fragment_init] ..., x [utils_verify] ].
  • PLS partial least squares
  • Y P is the first error
  • x [nth packet alias] is the data of the nth packet
  • t n is the orthogonal parameter corresponding to x [nth packet alias]
  • [t 1 ,t 2 ,...t n ] is the orthogonal parameter set
  • E is the residual factor
  • n is the number of packets.
  • the orthogonal parameter set and the residual factor are taken from the standard values of PLSToolBox in Matlab.
  • S3 the coverage test is performed on each packet obtained after the packet processing, and the error of the test coverage data set is calculated as the second error.
  • a coverage test based on the Java Virtual Machine Unit Test (JVM Test) or a coverage test based on the Instrumentation Test may be employed.
  • JVM Test Java Virtual Machine Unit Test
  • Instrumentation Test a coverage test based on the Instrumentation Test
  • de-reprocessing is required, that is, the JVM Test is executed after the Instrumentation Test is executed, and the code block is tagged after the Instrumentation Test is executed, thereby Before executing the JVM Test, determine whether the code block is marked with a tag. If the tag has a tag, skip the JVM Test. If there is no tag, execute the JVM Test to ensure that only the JVM Test or the Instrumentation Test is used for the coverage test.
  • the test environment system will output the coverage dataset file coverage.ec.
  • the coverage.ec is read to obtain the test coverage data set [x' 0 , x' 1 ... x' n ], and then the second error is calculated using the cumulative distribution function:
  • F is the second error
  • x' ⁇ [x' 0 , x' 1 ... x' n ]
  • n' is the number of elements included in the test coverage data set.
  • executing S4 determining whether the absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value, and if the absolute value of the difference is less than or equal to the preset coverage standard value And outputting the predicted coverage data set. If the absolute value of the difference is greater than the preset coverage standard value, the degree of refinement of the service logic is sequentially increased, and each sub-packet obtained after the packet processing is sub-packetized, and S2-S4 is executed cyclically until the absolute value of the difference is less than or equal to the preset coverage standard value.
  • is the absolute value of the difference
  • Y P is the first error
  • F is the second error
  • the preset coverage standard value ranges from 0.1 to 0.5, preferably, the preset coverage.
  • the standard value can be selected as 0.2, and the following process will be described in detail with a preset coverage standard value of 0.2.
  • the prediction coverage data set can be output in the form of a coverage report.
  • the degree of refinement of the business logic is improved, and each sub-packet after the packet processing is sub-packetized, that is, the business logic refinement procedure at the time of sub-packet processing is high.
  • the degree of business logic refinement during the first subcontracting process For example, when the first subcontracting process is performed, the business logic of the first subcontracting is a login operation, and the second subcontracting process can be based on the business logic. : Log in the account name and login password to further subcontract the first subcontract.
  • S2-S4 is repeatedly executed, and the first error is calculated based on the data of each packet obtained after the re-packet processing, and the coverage test is performed on each packet obtained after the re-packet processing, and the second calculation is performed. Error, and then determine whether the absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value, and if the absolute value of the difference is less than or equal to the preset coverage standard value, then The predicted coverage data set obtained twice is output, otherwise the process of sub-packaging and S2-S4 is continued to be performed until the absolute value of the difference is less than or equal to the preset coverage standard value.
  • an embodiment of the present invention further provides a unit test coverage generating apparatus. As shown in FIG. 2, the apparatus includes:
  • the sub-package module 201 is configured to perform S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the service logic;
  • the first calculating module 202 is configured to execute S2: the data of each packet obtained after the packet processing, and calculate the error of the predicted coverage data set as the first error;
  • the second calculating module 203 is configured to perform S3: performing coverage testing on each packet obtained after the packet processing, and calculating a test coverage data set error as a second error;
  • the determining module 204 is configured to execute S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
  • the processing module 205 is configured to: if the absolute value of the difference is less than or equal to the preset coverage standard value, output the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage Rate standard value, then sequentially increase the degree of refinement of the service logic, perform sub-packet processing on each packet obtained after the packet processing, and perform S2-S4 cyclically until the absolute value of the difference is less than or equal to the pre- Set the coverage standard value.
  • the first error is calculated by the following formula:
  • Y P is the first error
  • x [n-th sub-alias] The n-th sub-data, t n with the x [n-th sub-alias] parameter corresponding to orthogonal
  • E is the residual Factor
  • n is the number of subpackages.
  • the second error is calculated by the following formula:
  • F is the second error
  • x' ⁇ [x' 0 , x' 1 ... x' n ] is the test coverage data set
  • n' is the number of elements included in the test coverage data set.
  • the absolute value of the difference is obtained by the following formula:
  • is the absolute value of the difference
  • Y P is the first error
  • F is the second error
  • the coverage testing is performed on each sub-packet obtained after the packet processing, including:
  • the coverage test based on the Java virtual machine unit test or the device test is performed separately for each sub-packet obtained after the packet processing.
  • the preset coverage standard value ranges from 0.1 to 0.5.
  • an embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, and when the program is executed by the processor, the following steps are implemented:
  • the embodiment of the present invention further provides a computer device.
  • a computer device As shown in FIG. 3, for the convenience of description, only parts related to the embodiment of the present invention are shown. If the specific technical details are not disclosed, please refer to the method part of the embodiment of the present invention.
  • the computer device may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), an in-vehicle computer, and the like, and the computer device is used as a mobile phone as an example:
  • FIG. 3 is a block diagram showing a portion of the structure associated with a computer device provided by an embodiment of the present invention.
  • the computer device includes a memory 301 and a processor 302.
  • the computer device architecture illustrated in FIG. 3 does not constitute a limitation to a computer device, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
  • the memory 301 can be used to store software programs and modules, and the processor 302 executes various functional applications and data processing by running software programs and modules stored in the memory 301.
  • the memory 301 can mainly include a storage program area and a storage data area, wherein the storage program area can store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area can store data. (such as audio data, phone book, etc.).
  • the memory 301 may include a high speed random access memory, and may also include a nonvolatile memory such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the processor 302 is a control center of a computer device that performs various functions and processing data by running or executing software programs and/or modules stored in the memory 301, and recalling data stored in the memory 301.
  • the processor 302 may include one or more processing units; preferably, the processor 302 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, and the like.
  • the modem processor primarily handles wireless communications.
  • the processor 302 included in the computer device may have the following functions:
  • the present application first performs packetization processing on the multiplexing test code block in the unit testing process based on the business logic, reduces the coupling degree of the multiplexing test code block, and calculates the data of each packet obtained after the packet processing.
  • the error of the prediction coverage data set is the first error.
  • the coverage test is performed on each packet obtained after the packet processing, and the error of the test coverage data set is calculated as the second error, and the first error and the first error are determined.
  • the predicted coverage data set is output, if the difference is absolute If the value is greater than the preset coverage standard value, the degree of refinement of the service logic is sequentially increased, and each sub-packet obtained after the packet processing is sub-packetized, and the error calculation and comparison judgment process are performed cyclically until the absolute value of the difference is smaller than Or equal to the preset coverage standard value, effectively solving the coverage caused by directly incorporating the multiplexed code block into the coverage calculation process.
  • the problem that the rate base is too large increases the accuracy of the calculated coverage and reduces the error of coverage.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some, or all, of the gateways, proxy servers, systems in accordance with embodiments of the present invention.
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

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)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present invention relates to the technical field of software testing, and particularly to a unit testing code coverage (CC) generation method and apparatus, a readable storage medium, and a device. The method comprises: S1, performing, on the basis of service logic, package division processing on reuse testing code blocks in the unit testing process; S2, calculating, on the basis of data of each subpackage obtained by package division processing, a prediction CC data set error as a first error; S3, respectively performing CC testing on each subpackage obtained by package dividing processing, and calculating to obtain a testing CC data set error as a second error; S4, determining whether the absolute difference value between root-mean-square errors of the first error and the second error is greater than a preset CC standard value; if the absolute difference value is smaller than or equal to the preset CC standard value, outputting the prediction CC data set, and if the absolute difference value is greater than the preset CC standard value, increasing the refinement degree of the service logic in sequence and performing package division processing again on each subpackage obtained by package division processing, and performing S2-S4 in a cycle until the absolute difference value is smaller than or equal to the preset CC standard value.

Description

单元测试覆盖率生成方法、装置、可读存储介质及设备Unit test coverage generation method, device, readable storage medium and device 技术领域Technical field
本发明涉及软件测试技术领域,尤其涉及单元测试覆盖率生成方法、装置、可读存储介质及设备。The present invention relates to the field of software testing technologies, and in particular, to a unit test coverage generation method, apparatus, readable storage medium, and device.
背景技术Background technique
在应用程序开发过程中,单元测试是程序正式提交给测试人员进行大规模功能测试前的一个重要且必要的环节。单元测试是指对程序中最小可测试单元进行逻辑检查和验证,其中,单元就是规定的最小的被测功能模块。In the application development process, unit testing is an important and necessary part of the formal submission of the program to the tester for large-scale functional testing. Unit testing refers to the logic check and verification of the smallest testable unit in the program, where the unit is the specified minimum tested function module.
在安卓(Android)应用的开发过程中,单元测试分为:Java虚拟机单元测试(JVM Test)和设备测试(Instrumentation Test)。其中,对于JVM Test而言,一般通过运行由纯Java代码编写的测试桩(Test Case)实现,无需依赖其他组件,由于代码运行于JVM虚拟机上,因此测试速度较快;对于Instrumentation Test而言,由于这类测试需要依赖Android系统提供的组件,因此需要在真机或者模拟器上部署运行,并需要进行预编译,因此测试速度较慢。In the development process of Android applications, unit tests are divided into: Java Virtual Machine Unit Test (JVM Test) and Equipment Test (Instrumentation Test). Among them, for the JVM Test, it is generally implemented by running a test case written in pure Java code, without relying on other components, because the code runs on the JVM virtual machine, the test speed is faster; for the Instrumentation Test Because this kind of test needs to rely on the components provided by the Android system, it needs to be deployed and run on the real machine or simulator, and needs to be pre-compiled, so the test speed is slow.
而无论是采用上述的JVM Test还是Instrumentation Test,单元测试中存在一项重要数据指标,即覆盖率(Code Coverage,CC),覆盖率为单元测试所执行的代码与原代码的比值,覆盖率越高,所执行的代码量越大,测试的质量就越高,代码的健壮性则越好。Regardless of whether the above JVM Test or Instrumentation Test is used, there is an important data indicator in the unit test, that is, the coverage (Code Coverage, CC), the coverage ratio is the ratio of the code executed by the unit test to the original code, and the coverage rate is higher. High, the greater the amount of code executed, the higher the quality of the test and the better the robustness of the code.
在Android应用开发中,对于组件化和功能模块的解耦,在单元测试时常常会重复使用同一代码块,从而组件化和模块解耦的代码复用率高。然而,若按照现有的覆盖率生成方法,被复用的代码块会被直接纳入到覆盖率的计算中,从而导致覆盖率的基数过大,致使计算得到的覆盖率不准确,存在较大误差。In Android application development, for the decoupling of componentization and function modules, the same code block is often reused in unit testing, so that the code multiplexing rate of componentization and module decoupling is high. However, according to the existing coverage generation method, the code blocks that are multiplexed are directly included in the calculation of the coverage rate, resulting in an excessive coverage base, resulting in inaccurate coverage and large existence. error.
发明内容Summary of the invention
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的单元测试覆盖率生成方法、装置、可读存储介质及设备。In view of the above problems, the present invention has been made in order to provide a unit test coverage generation method, apparatus, readable storage medium and apparatus that overcome the above problems or at least partially solve the above problems.
本发明实施例提供一种单元测试覆盖率生成方法,所述方法包括:An embodiment of the present invention provides a unit test coverage generation method, where the method includes:
S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the business logic;
S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;S2: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing;
S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;S3: performing coverage test on each packet obtained after the packet processing, and calculating the error of the test coverage data set as the second error;
S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。If the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage standard value, The degree of refinement of the service logic is increased, and each packet obtained after the packet processing is sub-packetized, and S2-S4 is cyclically executed until the absolute value of the difference is less than or equal to the preset coverage standard value.
优选的,采用以下公式计算得到所述第一误差:Preferably, the first error is calculated by the following formula:
Y P=t 1x [第一分包别名]+t 2x [第二分包别名]+...+t nx [第n分包别名]+E Y P =t 1 x [first sub-package alias] +t 2 x [second sub-package alias] +...+t n x [n-th sub-package alias] +E
其中,Y P为所述第一误差,x [第n分包别名]为第n分包的数据,t n为与x [第n分包别 名]对应的正交参数,E为残差因子,n为分包的数量。 Wherein, Y P is the first error, x [n-th sub-alias] The n-th sub-data, t n with the x [n-th sub-alias] parameter corresponding to orthogonal, E is the residual Factor, n is the number of subpackages.
优选的,采用以下公式计算得到所述第二误差:Preferably, the second error is calculated by the following formula:
Figure PCTCN2018082346-appb-000001
Figure PCTCN2018082346-appb-000001
其中,F为所述第二误差,x′∈[x′ 0,x′ 1...x′ n],[x′ 0,x′ 1...x′ n]为测试覆盖率数据集,n′为所述测试覆盖率数据集包含的元素的数量。 Where F is the second error, x'∈[x' 0 , x' 1 ... x' n ], [x' 0 , x' 1 ... x' n ] is the test coverage data set , n' is the number of elements included in the test coverage data set.
优选的,采用以下公式获得所述差值绝对值:Preferably, the absolute value of the difference is obtained by the following formula:
Figure PCTCN2018082346-appb-000002
Figure PCTCN2018082346-appb-000002
其中,σ为所述差值绝对值,Y P为所述第一误差,F为所述第二误差。 Where σ is the absolute value of the difference, Y P is the first error, and F is the second error.
优选的,所述分别对分包处理后得到的各个分包进行覆盖率测试,包括:Preferably, the coverage testing is performed on each sub-packet obtained after the packet processing, including:
分别对分包处理后得到的各个分包进行基于Java虚拟机单元测试或设备测试的覆盖率测试。The coverage test based on the Java virtual machine unit test or the device test is performed separately for each sub-packet obtained after the packet processing.
优选的,所述预设覆盖率标准值的取值范围为0.1~0.5。Preferably, the preset coverage standard value ranges from 0.1 to 0.5.
本发明实施例提供一种单元测试覆盖率生成装置,所述装置包括:An embodiment of the present invention provides a unit test coverage generation apparatus, where the apparatus includes:
分包模块,用于执行S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;a sub-package module for performing S1: performing packetization processing on the multiplexing test code block in the unit test process based on the business logic;
第一计算模块,用于执行S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;a first calculating module, configured to execute S2: data of each packet obtained after the packet processing, and calculate a prediction coverage data set error as a first error;
第二计算模块,用于执行S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;a second calculating module, configured to perform S3: performing coverage testing on each packet obtained after the packet processing, and calculating a test coverage data set error as a second error;
判断模块,用于执行S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;a determining module, configured to execute S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
处理模块,用于若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。a processing module, configured to: if the absolute value of the difference is less than or equal to the preset coverage standard value, output the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage The standard value is used to sequentially improve the refinement processing of each sub-packet obtained after the packet processing, and cyclically execute S2-S4 until the absolute value of the difference is less than or equal to the preset. Coverage standard value.
优选的,采用以下公式计算得到所述第一误差:Preferably, the first error is calculated by the following formula:
Y P=t 1x [第一分包别名]+t 2x [第二分包别名]+...+t nx [第n分包别名]+E Y P =t 1 x [first sub-package alias] +t 2 x [second sub-package alias] +...+t n x [n-th sub-package alias] +E
其中,Y P为所述第一误差,x [第n分包别名]为第n分包的数据,t n为与x [第n分包别 名]对应的正交参数,E为残差因子,n为分包的数量。 Wherein, Y P is the first error, x [n-th sub-alias] The n-th sub-data, t n with the x [n-th sub-alias] parameter corresponding to orthogonal, E is the residual Factor, n is the number of subpackages.
本发明实施例提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现以下步骤:The embodiment of the invention provides a computer readable storage medium, on which a computer program is stored, and when the program is executed by the processor, the following steps are implemented:
S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the business logic;
S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;S2: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing;
S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;S3: performing coverage test on each packet obtained after the packet processing, and calculating the error of the test coverage data set as the second error;
S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。If the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage standard value, The degree of refinement of the service logic is increased, and each packet obtained after the packet processing is sub-packetized, and S2-S4 is cyclically executed until the absolute value of the difference is less than or equal to the preset coverage standard value.
本发明实施例提供一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现以下步骤:An embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored on the memory and operable on the processor, where the processor implements the following steps:
S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the business logic;
S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;S2: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing;
S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;S3: performing coverage test on each packet obtained after the packet processing, and calculating the error of the test coverage data set as the second error;
S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大 于预设覆盖率标准值;S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。If the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage standard value, The degree of refinement of the service logic is increased, and each packet obtained after the packet processing is sub-packetized, and S2-S4 is cyclically executed until the absolute value of the difference is less than or equal to the preset coverage standard value.
本发明实施例中的一个或多个技术方案,至少具有如下技术效果或优点:One or more technical solutions in the embodiments of the present invention have at least the following technical effects or advantages:
本申请通过先基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理,降低复用测试代码块的耦合度,再基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差,接着,分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差,通过判断第一误差和第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值,若差值绝对值小于或等于预设覆盖率标准值,则对预测覆盖率数据集进行输出,若差值绝对值大于预设覆盖率标准值,则依次提高业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行误差的计算和比较判断过程直至差值绝对值小于或等于所述预设覆盖率标准值,有效地解决了直接将复用代码块纳入到覆盖率的计算过程中而导致的覆盖率基数过大的问题,提高了计算得到的覆盖率的准确性,减小了覆盖率的误差。The present application first performs packetization processing on the multiplexing test code block in the unit testing process based on the business logic, reduces the coupling degree of the multiplexing test code block, and calculates the prediction coverage based on the data of each packet obtained after the packet processing. The error of the rate data set is the first error. Then, the coverage test is performed on each packet obtained after the packet processing, and the error of the test coverage data set is calculated as the second error, and the first error and the second error are determined. Whether the absolute value of the root mean square error is greater than a preset coverage standard value, and if the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than The preset coverage standard value is used to sequentially improve the refinement degree of the business logic, and then perform sub-packet processing on each sub-packet obtained after the packet processing, and cyclically execute the error calculation and comparison judgment process until the absolute value of the difference is less than or equal to The preset coverage standard value effectively solves the coverage base caused by directly incorporating the multiplexed code block into the coverage calculation process. Big problems and improve the accuracy of the calculated coverage and decrease the error coverage.
附图说明DRAWINGS
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考图形表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those skilled in the art from a The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting. Further, the same components are denoted by the same reference numerals throughout the drawings. In the drawing:
图1示出了本发明实施例中的一种单元测试覆盖率生成方法的流程图;FIG. 1 is a flowchart of a unit test coverage generation method in an embodiment of the present invention;
图2示出了本发明实施例中的一种单元测试覆盖率生成装置的结构图;2 is a structural diagram of a unit test coverage generation apparatus in an embodiment of the present invention;
图3示出了本发明实施例中的计算机设备的实体结构示意图。FIG. 3 is a schematic diagram showing the physical structure of a computer device in an embodiment of the present invention.
具体实施方式Detailed ways
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the embodiments of the present invention have been shown in the drawings, the embodiments Rather, these embodiments are provided so that this disclosure will be more fully understood and the scope of the disclosure will be fully disclosed.
本申请实施例提供一种单元测试覆盖率生成方法,该方法可以被应用于Android系统中,且,该方法的编码语言可以为Java。如图1所示,所述方法包 括:The embodiment of the present application provides a unit test coverage generation method, which may be applied to an Android system, and the coding language of the method may be Java. As shown in Figure 1, the method includes:
S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理。S1: Perform packet processing on the multiplexing test code block in the unit testing process based on the business logic.
对于S1而言,S1执行的是分包复用测试代码块的过程,其目的是降低各个复用测试代码块之间的耦合度。在具体实施过程中,本申请将业务逻辑相同的复用测试代码块迁移至同一包路径下,以实现分包处理,下面给出一分包实例对S1进行解释说明:For S1, S1 performs the process of packet multiplexing test code blocks, the purpose of which is to reduce the degree of coupling between the various multiplex test code blocks. In the specific implementation process, the application migrates the same multiplexing test code block with the same business logic to the same package path to implement the packet processing. The following provides a sub-package example to explain S1:
Figure PCTCN2018082346-appb-000003
Figure PCTCN2018082346-appb-000003
表1Table 1
以activity_init为例,该分包对应的业务逻辑为初始化Activity,该分包中包含的复用测试代码块的业务逻辑均属于初始化Activity。Taking activity_init as an example, the business logic corresponding to the packet is an initialization activity, and the business logic of the multiplexing test code block included in the packet belongs to the initialization activity.
进一步,在执行完S1之后,执行S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差。Further, after the execution of S1, S2 is performed: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing.
对于S2而言,可以借助AndroidStudio开发工具对各个分包下复用测试代码块所涵盖的源代码进行统计,从而获得复用测试代码块集为X T=[x [第一分包别名],x [第 二分包别名]...,x [第n分包别名]],x [第一分包别名]对应第一分包的数据,x [第二分包别名]对应第二分包的数据,依次类推。以上述实例为例,通过对源代码进行统计,获得的X T=[x [activity_init],x [fragment_init]...,x [utils_verify]]。接着基于偏最小二乘法(PLS)建立正交公式,获得第一误差为: For S2, the source code covered by the multiplexed test code block under each sub-package can be counted by means of the AndroidStudio development tool, thereby obtaining the multiplexed test code block set as X T =[x [first sub-package alias] , x [alias sub-second] ..., x [n-th sub-alias]], x [alias first sub] corresponding to the data of the first sub, x [alias sub-second] corresponding to the second sub- The data of the package, and so on. Taking the above example as an example, by counting the source code, X T =[x [activity_init] , x [fragment_init] ..., x [utils_verify] ]. Then the orthogonal formula is established based on partial least squares (PLS), and the first error is obtained as:
Y P=t 1x [第一分包别名]+t 2x [第二分包别名]+...+t nx [第n分包别名]+E Y P =t 1 x [first sub-package alias] +t 2 x [second sub-package alias] +...+t n x [n-th sub-package alias] +E
其中,Y P为第一误差,x [第n分包别名]为第n分包的数据,t n为与x [第n分包别名]对应的正交参数,而,[t 1,t 2,...t n]为正交参数集,E为残差因子,n为分包的数量。另外,正交参数集和残差因子均取自Matlab中PLSToolBox的标准值。 Where Y P is the first error, x [nth packet alias] is the data of the nth packet, and t n is the orthogonal parameter corresponding to x [nth packet alias] , and [t 1 ,t 2 ,...t n ] is the orthogonal parameter set, E is the residual factor, and n is the number of packets. In addition, the orthogonal parameter set and the residual factor are taken from the standard values of PLSToolBox in Matlab.
在执行完S2之后,执行S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差。After the execution of S2, S3 is performed: the coverage test is performed on each packet obtained after the packet processing, and the error of the test coverage data set is calculated as the second error.
对于S3而言,在具体实施过程中,可以采用基于Java虚拟机单元测试(JVM Test)的覆盖率测试,或者采用基于设备测试(Instrumentation Test)的覆盖率测试。而,为了避免同时采用JVM Test和Instrumentation Test进行覆盖率测试,需要进行去重处理,即,先执行Instrumentation Test后执行JVM Test,并且,在执行Instrumentation Test后对代码块添加标签(Tag),从而在执行JVM Test之前,判断代码块是否标记有Tag,如果标记有Tag则跳过不执行JVM Test,如果没有标记有Tag则执行JVM Test,从而确保仅采用JVM Test或Instrumentation Test进行覆盖率测试。另外,在完成覆盖率测试后,测试环境系统将会输出覆盖率数据集文件coverage.ec。For S3, in the specific implementation process, a coverage test based on the Java Virtual Machine Unit Test (JVM Test) or a coverage test based on the Instrumentation Test may be employed. However, in order to avoid the coverage test using both JVM Test and Instrumentation Test, de-reprocessing is required, that is, the JVM Test is executed after the Instrumentation Test is executed, and the code block is tagged after the Instrumentation Test is executed, thereby Before executing the JVM Test, determine whether the code block is marked with a tag. If the tag has a tag, skip the JVM Test. If there is no tag, execute the JVM Test to ensure that only the JVM Test or the Instrumentation Test is used for the coverage test. In addition, after the coverage test is completed, the test environment system will output the coverage dataset file coverage.ec.
进一步,读取coverage.ec,得到测试覆盖率数据集[x′ 0,x′ 1...x′ n],接着,使用累计分布函数计算第二误差: Further, the coverage.ec is read to obtain the test coverage data set [x' 0 , x' 1 ... x' n ], and then the second error is calculated using the cumulative distribution function:
Figure PCTCN2018082346-appb-000004
Figure PCTCN2018082346-appb-000004
其中,F为第二误差,x′∈[x′ 0,x′ 1...x′ n],n′为测试覆盖率数据集包含的元素的数量。 Where F is the second error, x' ∈ [x' 0 , x' 1 ... x' n ], and n' is the number of elements included in the test coverage data set.
在执行完S3之后,执行S4:判断第一误差和第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值,若差值绝对值小于或等于预设覆盖率标准值,则对预测覆盖率数据集进行输出,若差值绝对值大于预设覆盖率标准值,则依次提高业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至差值绝对值小于或等于预设覆盖率标准值。After the execution of S3, executing S4: determining whether the absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value, and if the absolute value of the difference is less than or equal to the preset coverage standard value And outputting the predicted coverage data set. If the absolute value of the difference is greater than the preset coverage standard value, the degree of refinement of the service logic is sequentially increased, and each sub-packet obtained after the packet processing is sub-packetized, and S2-S4 is executed cyclically until the absolute value of the difference is less than or equal to the preset coverage standard value.
对于S4而言,首先,采用以下公式获得差值绝对值:For S4, first, the absolute value of the difference is obtained using the following formula:
Figure PCTCN2018082346-appb-000005
Figure PCTCN2018082346-appb-000005
其中,σ为差值绝对值,Y P为第一误差,F为第二误差。 Where σ is the absolute value of the difference, Y P is the first error, and F is the second error.
进一步,在得到差值绝对值之后,判断差值绝对值与预设覆盖率标准值之间的大小关系,预设覆盖率标准值的取值范围为0.1~0.5,优选的,预设覆盖率标准值可以选取0.2,下面将以预设覆盖率标准值取值0.2对后续过程进行详细说明。Further, after obtaining the absolute value of the difference, determining the relationship between the absolute value of the difference and the standard value of the preset coverage, the preset coverage standard value ranges from 0.1 to 0.5, preferably, the preset coverage. The standard value can be selected as 0.2, and the following process will be described in detail with a preset coverage standard value of 0.2.
若σ≤0.2,表明测试覆盖率数据误差合理,使用Jacoco插件合并所有预测覆盖率数据,可以以覆盖率报告的形式将预测覆盖率数据集进行输出。If σ ≤ 0.2, it indicates that the test coverage data error is reasonable. Using the Jacobo plug-in to combine all the predicted coverage data, the prediction coverage data set can be output in the form of a coverage report.
若σ>0.2,表明测试覆盖率数据误差较大,则提高业务逻辑的细化程度分包处理后的各个分包进行再分包处理,即,再分包处理时的业务逻辑细化程序高于第一次分包处理时的业务逻辑细化程度,例如,当第一次分包处理时,第一分包的业务逻辑为登录操作,则第二次分包处理时,可以根据业务逻辑:登录账户名和登录密码,对第一分包进行进一步的分包处理。接着,重复执行S2-S4,基于再分包处理后得到的各个分包的数据,计算出第一误差,并分别对再分包处理后得到的各个分包进行覆盖率测试,计算出第二误差,再判断第一误差和第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值,若此次差值绝对值小于或等于预设覆盖率标准值,则对第二次获得的预测覆盖率数据集进行输出,否则继续循环执行分包和S2-S4的过程,直至差值绝对值小于或等于预设覆盖率标准值。If σ>0.2, indicating that the error of the test coverage data is large, the degree of refinement of the business logic is improved, and each sub-packet after the packet processing is sub-packetized, that is, the business logic refinement procedure at the time of sub-packet processing is high. The degree of business logic refinement during the first subcontracting process. For example, when the first subcontracting process is performed, the business logic of the first subcontracting is a login operation, and the second subcontracting process can be based on the business logic. : Log in the account name and login password to further subcontract the first subcontract. Then, S2-S4 is repeatedly executed, and the first error is calculated based on the data of each packet obtained after the re-packet processing, and the coverage test is performed on each packet obtained after the re-packet processing, and the second calculation is performed. Error, and then determine whether the absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value, and if the absolute value of the difference is less than or equal to the preset coverage standard value, then The predicted coverage data set obtained twice is output, otherwise the process of sub-packaging and S2-S4 is continued to be performed until the absolute value of the difference is less than or equal to the preset coverage standard value.
基于同一发明构思,本发明实施例还提供一种单元测试覆盖率生成装置,如图2所示,所述装置包括:Based on the same inventive concept, an embodiment of the present invention further provides a unit test coverage generating apparatus. As shown in FIG. 2, the apparatus includes:
分包模块201,用于执行S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;The sub-package module 201 is configured to perform S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the service logic;
第一计算模块202,用于执行S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;The first calculating module 202 is configured to execute S2: the data of each packet obtained after the packet processing, and calculate the error of the predicted coverage data set as the first error;
第二计算模块203,用于执行S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;The second calculating module 203 is configured to perform S3: performing coverage testing on each packet obtained after the packet processing, and calculating a test coverage data set error as a second error;
判断模块204,用于执行S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;The determining module 204 is configured to execute S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
处理模块205,用于若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆 盖率标准值。The processing module 205 is configured to: if the absolute value of the difference is less than or equal to the preset coverage standard value, output the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage Rate standard value, then sequentially increase the degree of refinement of the service logic, perform sub-packet processing on each packet obtained after the packet processing, and perform S2-S4 cyclically until the absolute value of the difference is less than or equal to the pre- Set the coverage standard value.
优选的,采用以下公式计算得到所述第一误差:Preferably, the first error is calculated by the following formula:
Y P=t 1x [第一分包别名]+t 2x [第二分包别名]+...+t nx [第n分包别名]+E Y P =t 1 x [first sub-package alias] +t 2 x [second sub-package alias] +...+t n x [n-th sub-package alias] +E
其中,Y P为所述第一误差,x [第n分包别名]为第n分包的数据,t n为与x [第n分包别 名]对应的正交参数,E为残差因子,n为分包的数量。 Wherein, Y P is the first error, x [n-th sub-alias] The n-th sub-data, t n with the x [n-th sub-alias] parameter corresponding to orthogonal, E is the residual Factor, n is the number of subpackages.
优选的,采用以下公式计算得到所述第二误差:Preferably, the second error is calculated by the following formula:
Figure PCTCN2018082346-appb-000006
Figure PCTCN2018082346-appb-000006
其中,F为所述第二误差,x′∈[x′ 0,x′ 1...x′ n],[x′ 0,x′ 1...x′ n]为测试覆盖率数据集,n′为所述测试覆盖率数据集包含的元素的数量。 Where F is the second error, x'∈[x' 0 , x' 1 ... x' n ], [x' 0 , x' 1 ... x' n ] is the test coverage data set , n' is the number of elements included in the test coverage data set.
优选的,采用以下公式获得所述差值绝对值:Preferably, the absolute value of the difference is obtained by the following formula:
Figure PCTCN2018082346-appb-000007
Figure PCTCN2018082346-appb-000007
其中,σ为所述差值绝对值,Y P为所述第一误差,F为所述第二误差。 Where σ is the absolute value of the difference, Y P is the first error, and F is the second error.
优选的,所述分别对分包处理后得到的各个分包进行覆盖率测试,包括:Preferably, the coverage testing is performed on each sub-packet obtained after the packet processing, including:
分别对分包处理后得到的各个分包进行基于Java虚拟机单元测试或设备测试的覆盖率测试。The coverage test based on the Java virtual machine unit test or the device test is performed separately for each sub-packet obtained after the packet processing.
优选的,所述预设覆盖率标准值的取值范围为0.1~0.5。Preferably, the preset coverage standard value ranges from 0.1 to 0.5.
基于同一发明构思,本发明实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现以下步骤:Based on the same inventive concept, an embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, and when the program is executed by the processor, the following steps are implemented:
S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the business logic;
S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;S2: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing;
S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;S3: performing coverage test on each packet obtained after the packet processing, and calculating the error of the test coverage data set as the second error;
S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。If the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage standard value, The degree of refinement of the service logic is increased, and each packet obtained after the packet processing is sub-packetized, and S2-S4 is cyclically executed until the absolute value of the difference is less than or equal to the preset coverage standard value.
本发明实施例还提供了一种计算机设备,如图3所示,为了便于说明,仅 示出了与本发明实施例相关的部分,具体技术细节未揭示的,请参照本发明实施例方法部分。该计算机设备可以为包括手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑等任意终端设备,以计算机设备为手机为例:The embodiment of the present invention further provides a computer device. As shown in FIG. 3, for the convenience of description, only parts related to the embodiment of the present invention are shown. If the specific technical details are not disclosed, please refer to the method part of the embodiment of the present invention. . The computer device may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), an in-vehicle computer, and the like, and the computer device is used as a mobile phone as an example:
图3示出的是与本发明实施例提供的计算机设备相关的部分结构的框图。参考图3,该计算机设备包括:存储器301和处理器302。本领域技术人员可以理解,图3中示出的计算机设备结构并不构成对计算机设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。3 is a block diagram showing a portion of the structure associated with a computer device provided by an embodiment of the present invention. Referring to FIG. 3, the computer device includes a memory 301 and a processor 302. Those skilled in the art will appreciate that the computer device architecture illustrated in FIG. 3 does not constitute a limitation to a computer device, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
下面结合图3对计算机设备的各个构成部件进行具体的介绍:The specific components of the computer device will be specifically described below with reference to FIG. 3:
存储器301可用于存储软件程序以及模块,处理器302通过运行存储在存储器301的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器301可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储数据(比如音频数据、电话本等)等。此外,存储器301可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。The memory 301 can be used to store software programs and modules, and the processor 302 executes various functional applications and data processing by running software programs and modules stored in the memory 301. The memory 301 can mainly include a storage program area and a storage data area, wherein the storage program area can store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area can store data. (such as audio data, phone book, etc.). Further, the memory 301 may include a high speed random access memory, and may also include a nonvolatile memory such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
处理器302是计算机设备的控制中心,通过运行或执行存储在存储器301内的软件程序和/或模块,以及调用存储在存储器301内的数据,执行各种功能和处理数据。可选的,处理器302可包括一个或多个处理单元;优选的,处理器302可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。The processor 302 is a control center of a computer device that performs various functions and processing data by running or executing software programs and/or modules stored in the memory 301, and recalling data stored in the memory 301. Optionally, the processor 302 may include one or more processing units; preferably, the processor 302 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, and the like. The modem processor primarily handles wireless communications.
在本发明实施例中,该计算机设备所包括的处理器302可以具有以下功能:In the embodiment of the present invention, the processor 302 included in the computer device may have the following functions:
S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the business logic;
S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;S2: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing;
S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;S3: performing coverage test on each packet obtained after the packet processing, and calculating the error of the test coverage data set as the second error;
S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。If the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage standard value, The degree of refinement of the service logic is increased, and each packet obtained after the packet processing is sub-packetized, and S2-S4 is cyclically executed until the absolute value of the difference is less than or equal to the preset coverage standard value.
总之,本申请通过先基于业务逻辑对单元测试过程中的复用测试代码块进 行分包处理,降低复用测试代码块的耦合度,再基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差,接着,分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差,通过判断第一误差和第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值,若差值绝对值小于或等于预设覆盖率标准值,则对预测覆盖率数据集进行输出,若差值绝对值大于预设覆盖率标准值,则依次提高业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行误差的计算和比较判断过程直至差值绝对值小于或等于所述预设覆盖率标准值,有效地解决了直接将复用代码块纳入到覆盖率的计算过程中而导致的覆盖率基数过大的问题,提高了计算得到的覆盖率的准确性,减小了覆盖率的误差。In summary, the present application first performs packetization processing on the multiplexing test code block in the unit testing process based on the business logic, reduces the coupling degree of the multiplexing test code block, and calculates the data of each packet obtained after the packet processing. The error of the prediction coverage data set is the first error. Then, the coverage test is performed on each packet obtained after the packet processing, and the error of the test coverage data set is calculated as the second error, and the first error and the first error are determined. Whether the absolute value of the difference of the root mean square error of the two errors is greater than the preset coverage standard value, and if the absolute value of the difference is less than or equal to the preset coverage standard value, the predicted coverage data set is output, if the difference is absolute If the value is greater than the preset coverage standard value, the degree of refinement of the service logic is sequentially increased, and each sub-packet obtained after the packet processing is sub-packetized, and the error calculation and comparison judgment process are performed cyclically until the absolute value of the difference is smaller than Or equal to the preset coverage standard value, effectively solving the coverage caused by directly incorporating the multiplexed code block into the coverage calculation process. The problem that the rate base is too large increases the accuracy of the calculated coverage and reduces the error of coverage.
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general purpose systems can also be used with the teaching based on the teachings herein. The structure required to construct such a system is apparent from the above description. Moreover, the invention is not directed to any particular programming language. It is to be understood that the invention may be embodied in a variety of programming language, and the description of the specific language has been described above in order to disclose the preferred embodiments of the invention.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that the embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of the description.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, the various features of the invention are sometimes grouped together into a single embodiment, in the above description of the exemplary embodiments of the invention, Figure, or a description of it. However, the method disclosed is not to be interpreted as reflecting the intention that the claimed invention requires more features than those specifically recited in the claims. Rather, as the following claims reflect, inventive aspects reside in less than all features of the single embodiments disclosed herein. Therefore, the claims following the specific embodiments are hereby explicitly incorporated into the embodiments, and each of the claims as a separate embodiment of the invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征 来代替。Those skilled in the art will appreciate that the modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components. In addition to such features and/or at least some of the processes or units being mutually exclusive, any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined. Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
此外,本领域的技术人员能够理解,尽管在此的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。In addition, those skilled in the art will appreciate that although some embodiments herein include certain features included in other embodiments and not other features, combinations of features of different embodiments are intended to be within the scope of the present invention. And different embodiments are formed. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的网关、代理服务器、系统中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functionality of some, or all, of the gateways, proxy servers, systems in accordance with embodiments of the present invention. The invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein. Such a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It is to be noted that the above-described embodiments are illustrative of the invention and are not intended to be limiting, and that the invention may be devised without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as a limitation. The word "comprising" does not exclude the presence of the elements or steps that are not recited in the claims. The word "a" or "an" The invention can be implemented by means of hardware comprising several distinct elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means can be embodied by the same hardware item. The use of words, second, third, etc. does not indicate any order. These words can be interpreted as names.

Claims (10)

  1. 一种单元测试覆盖率生成方法,其特征在于,所述方法包括:A unit test coverage generation method, characterized in that the method comprises:
    S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the business logic;
    S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;S2: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing;
    S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;S3: performing coverage test on each packet obtained after the packet processing, and calculating the error of the test coverage data set as the second error;
    S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
    若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。If the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage standard value, The degree of refinement of the service logic is increased, and each packet obtained after the packet processing is sub-packetized, and S2-S4 is cyclically executed until the absolute value of the difference is less than or equal to the preset coverage standard value.
  2. 如权利要求1所述的方法,其特征在于,采用以下公式计算得到所述第一误差:The method of claim 1 wherein said first error is calculated using the following formula:
    Y P=t 1x [第一分包别名]+t 2x [第二分包别名]+...+t nx [第n分包别名]+E Y P =t 1 x [first sub-package alias] +t 2 x [second sub-package alias] +...+t n x [n-th sub-package alias] +E
    其中,Y P为所述第一误差,x [第n分包别名]为第n分包的数据,t n为与x [第n分包别 名]对应的正交参数,E为残差因子,n为分包的数量。 Wherein, Y P is the first error, x [n-th sub-alias] The n-th sub-data, t n with the x [n-th sub-alias] parameter corresponding to orthogonal, E is the residual Factor, n is the number of subpackages.
  3. 如权利要求1所述的方法,其特征在于,采用以下公式计算得到所述第二误差:The method of claim 1 wherein said second error is calculated using the following formula:
    Figure PCTCN2018082346-appb-100001
    Figure PCTCN2018082346-appb-100001
    其中,F为所述第二误差,x′∈[x′ 0,x′ 1...x′ n],[x′ 0,x′ 1...x′ n]为测试覆盖率数据集,n′为所述测试覆盖率数据集包含的元素的数量。 Where F is the second error, x'∈[x' 0 , x' 1 ... x' n ], [x' 0 , x' 1 ... x' n ] is the test coverage data set , n' is the number of elements included in the test coverage data set.
  4. 如权利要求1所述的方法,其特征在于,采用以下公式获得所述差值绝对值:The method of claim 1 wherein the absolute value of the difference is obtained using the following formula:
    Figure PCTCN2018082346-appb-100002
    Figure PCTCN2018082346-appb-100002
    其中,σ为所述差值绝对值,Y P为所述第一误差,F为所述第二误差。 Where σ is the absolute value of the difference, Y P is the first error, and F is the second error.
  5. 如权利要求1所述的方法,其特征在于,所述分别对分包处理后得到的各个分包进行覆盖率测试,包括:The method according to claim 1, wherein the coverage testing is performed on each of the sub-packets obtained after the packet processing, including:
    分别对分包处理后得到的各个分包进行基于Java虚拟机单元测试或设备 测试的覆盖率测试。The coverage test based on the Java virtual machine unit test or the device test is performed separately for each packet obtained after the packet processing.
  6. 如权利要求1所述的方法,其特征在于,所述预设覆盖率标准值的取值范围为0.1~0.5。The method according to claim 1, wherein the preset coverage standard value ranges from 0.1 to 0.5.
  7. 一种单元测试覆盖率生成装置,其特征在于,所述装置包括:A unit test coverage generating apparatus, characterized in that the apparatus comprises:
    分包模块,用于执行S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;a sub-package module for performing S1: performing packetization processing on the multiplexing test code block in the unit test process based on the business logic;
    第一计算模块,用于执行S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;a first calculating module, configured to execute S2: data of each packet obtained after the packet processing, and calculate a prediction coverage data set error as a first error;
    第二计算模块,用于执行S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;a second calculating module, configured to perform S3: performing coverage testing on each packet obtained after the packet processing, and calculating a test coverage data set error as a second error;
    判断模块,用于执行S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;a determining module, configured to execute S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
    处理模块,用于若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。a processing module, configured to: if the absolute value of the difference is less than or equal to the preset coverage standard value, output the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage The standard value is used to sequentially improve the refinement processing of each sub-packet obtained after the packet processing, and cyclically execute S2-S4 until the absolute value of the difference is less than or equal to the preset. Coverage standard value.
  8. 如权利要求7所述的装置,其特征在于,采用以下公式计算得到所述第一误差:The apparatus of claim 7 wherein said first error is calculated using the following formula:
    Y P=t 1x [第一分包别名]+t 2x [第二分包别名]+...+t nx [第n分包别名]+E Y P =t 1 x [first sub-package alias] +t 2 x [second sub-package alias] +...+t n x [n-th sub-package alias] +E
    其中,Y P为所述第一误差,x [第n分包别名]为第n分包的数据,t n为与x [第n分包别 名]对应的正交参数,E为残差因子,n为分包的数量。 Wherein, Y P is the first error, x [n-th sub-alias] The n-th sub-data, t n with the x [n-th sub-alias] parameter corresponding to orthogonal, E is the residual Factor, n is the number of subpackages.
  9. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现以下步骤:A computer readable storage medium having stored thereon a computer program, wherein the program, when executed by the processor, implements the following steps:
    S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the business logic;
    S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;S2: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing;
    S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;S3: performing coverage test on each packet obtained after the packet processing, and calculating the error of the test coverage data set as the second error;
    S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
    若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提 高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。If the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage standard value, The degree of refinement of the service logic is increased, and each packet obtained after the packet processing is sub-packetized, and S2-S4 is cyclically executed until the absolute value of the difference is less than or equal to the preset coverage standard value.
  10. 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现以下步骤:A computer device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor performs the following steps when executing the program:
    S1:基于业务逻辑对单元测试过程中的复用测试代码块进行分包处理;S1: performing packetization processing on the multiplexing test code block in the unit testing process based on the business logic;
    S2:基于分包处理后得到的各个分包的数据,计算预测覆盖率数据集误差为第一误差;S2: calculating the predicted coverage data set error as the first error based on the data of each packet obtained after the packet processing;
    S3:分别对分包处理后得到的各个分包进行覆盖率测试,并计算得到测试覆盖率数据集误差为第二误差;S3: performing coverage test on each packet obtained after the packet processing, and calculating the error of the test coverage data set as the second error;
    S4:判断所述第一误差和所述第二误差的均方根误差的差值绝对值是否大于预设覆盖率标准值;S4: determining whether an absolute value of the difference between the root mean square error of the first error and the second error is greater than a preset coverage standard value;
    若所述差值绝对值小于或等于所述预设覆盖率标准值,则对所述预测覆盖率数据集进行输出,若所述差值绝对值大于所述预设覆盖率标准值,则依次提高所述业务逻辑的细化程度对分包处理后得到的各个分包进行再分包处理,并循环执行S2-S4直至所述差值绝对值小于或等于所述预设覆盖率标准值。If the absolute value of the difference is less than or equal to the preset coverage standard value, outputting the predicted coverage data set, if the absolute value of the difference is greater than the preset coverage standard value, The degree of refinement of the service logic is increased, and each packet obtained after the packet processing is sub-packetized, and S2-S4 is cyclically executed until the absolute value of the difference is less than or equal to the preset coverage standard value.
PCT/CN2018/082346 2017-10-09 2018-04-09 Unit testing code coverage (cc) generation method and apparatus, readable storage medium, and device WO2019071929A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710930604.XA CN107678967B (en) 2017-10-09 2017-10-09 Unit test coverage rate generation method and device, readable storage medium and equipment
CN201710930604.X 2017-10-09

Publications (1)

Publication Number Publication Date
WO2019071929A1 true WO2019071929A1 (en) 2019-04-18

Family

ID=61139315

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/082346 WO2019071929A1 (en) 2017-10-09 2018-04-09 Unit testing code coverage (cc) generation method and apparatus, readable storage medium, and device

Country Status (2)

Country Link
CN (1) CN107678967B (en)
WO (1) WO2019071929A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107678967B (en) * 2017-10-09 2020-02-07 武汉斗鱼网络科技有限公司 Unit test coverage rate generation method and device, readable storage medium and equipment
CN113722232A (en) * 2021-09-10 2021-11-30 中国银行股份有限公司 Unit test coverage rate control method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102419728A (en) * 2011-11-01 2012-04-18 北京邮电大学 Method for determining software test process sufficiency based on coverage rate quantitative indicators
CN104375941A (en) * 2014-12-11 2015-02-25 无锡江南计算技术研究所 Automated evaluation method for binary code coverage of testing case set for executable program
CN105224460A (en) * 2015-10-23 2016-01-06 浪潮电子信息产业股份有限公司 A kind of method based on Program instrumentation statistical test coverage rate
US20170083430A1 (en) * 2015-09-22 2017-03-23 Red Hat Israel, Ltd. Code coverage plugin
CN107678967A (en) * 2017-10-09 2018-02-09 武汉斗鱼网络科技有限公司 Unit testing coverage rate generation method, device, readable storage medium storing program for executing and equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016146032A (en) * 2015-02-06 2016-08-12 日本電気株式会社 Software covering testing device and method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102419728A (en) * 2011-11-01 2012-04-18 北京邮电大学 Method for determining software test process sufficiency based on coverage rate quantitative indicators
CN104375941A (en) * 2014-12-11 2015-02-25 无锡江南计算技术研究所 Automated evaluation method for binary code coverage of testing case set for executable program
US20170083430A1 (en) * 2015-09-22 2017-03-23 Red Hat Israel, Ltd. Code coverage plugin
CN105224460A (en) * 2015-10-23 2016-01-06 浪潮电子信息产业股份有限公司 A kind of method based on Program instrumentation statistical test coverage rate
CN107678967A (en) * 2017-10-09 2018-02-09 武汉斗鱼网络科技有限公司 Unit testing coverage rate generation method, device, readable storage medium storing program for executing and equipment

Also Published As

Publication number Publication date
CN107678967B (en) 2020-02-07
CN107678967A (en) 2018-02-09

Similar Documents

Publication Publication Date Title
US7415444B2 (en) Determining compliance rates for probabilistic requests
US7996818B1 (en) Method for testing using client specified references
EP3602306B1 (en) Automated device test triaging system and techniques
CN110688428B (en) Method and device for issuing intelligent contracts
CN104050054B (en) Processing method for installation package installation failure and cause determining method and device
WO2019071929A1 (en) Unit testing code coverage (cc) generation method and apparatus, readable storage medium, and device
CN108712236B (en) Information processing method and device and electronic equipment
CN113342671B (en) Method, device, electronic equipment and medium for verifying operation module
CN113742221A (en) Method for generating test case, electronic device and storage medium
US20110161716A1 (en) Systems, methods, and apparatuses for providing access to real time information
CN113535578B (en) CTS test method, CTS test device and CTS test equipment
CN110022327B (en) Short message authentication test method and device
CN112133357A (en) eMMC testing method and device
TW201708836A (en) Protocol based automated tester stimulus generator
CN113535580B (en) CTS test method, CTS test device and test equipment
US20230055523A1 (en) Method, apparatus, and storage medium for generating test cases
CN114090355A (en) Method, system, device and storage medium for post-silicon testing
CN112380127B (en) Test case regression method, device, equipment and storage medium
CN112379967B (en) Simulator detection method, device, equipment and medium
CN111190824A (en) Monitoring method, monitoring device, terminal equipment and storage medium
US20160077942A1 (en) Storage system and test method for testing pci express interface
CN113098730A (en) Server testing method and equipment
US9477800B1 (en) System, method, and computer program product for automatically selecting a constraint solver algorithm in a design verification environment
CN111444068B (en) System performance test method, device, computer equipment and storage medium
CN107885659A (en) Method and device, the equipment of request analog response to client

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

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

Country of ref document: EP

Kind code of ref document: A1