WO2019071929A1 - Procédé et appareil de génération de couverture de code (cc) de test unitaire, support de stockage lisible, et dispositif - Google Patents

Procédé et appareil de génération de couverture de code (cc) de test unitaire, support de stockage lisible, et dispositif 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
English (en)
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/fr

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

La présente invention concerne le domaine technique du test de logiciel, et en particulier un procédé et un appareil de génération de couverture de code (CC) de test unitaire, un support de stockage lisible et un dispositif. Le procédé comprend les étapes consistant à : S1, effectuer, sur la base d'une logique de service, un traitement de division de paquet sur des blocs de code de test de réutilisation dans le processus de test unitaire ; S2, calculer, sur la base de données de chaque sous-paquet obtenu par le traitement de division de paquet, une erreur d'ensemble de données de CC de prédiction en tant que première erreur ; S3, effectuer respectivement un test de CC sur chaque sous-paquet obtenu par le traitement de division de paquet, et effectuer un calcul pour obtenir une erreur d'ensemble de données de CC de test en tant que seconde erreur ; S4, déterminer si la valeur de différence absolue entre des erreurs quadratiques moyennes de la première erreur et de la seconde erreur est supérieure à une valeur standard de CC prédéfinie ; si la valeur de différence absolue est inférieure ou égale à la valeur standard de CC prédéfinie, délivrer en sortie l'ensemble de données de CC de prédiction, et si la valeur de différence absolue est supérieure à la valeur standard de CC prédéfinie, augmenter le degré d'affinement de la logique de service en séquence et effectuer de nouveau un traitement de division de paquet sur chaque sous-paquet obtenu par le traitement de division de paquet, et effectuer les étapes S2-S4 en cycle jusqu'à ce que la valeur de différence absolue soit inférieure ou égale à la valeur standard de CC prédéfinie.
PCT/CN2018/082346 2017-10-09 2018-04-09 Procédé et appareil de génération de couverture de code (cc) de test unitaire, support de stockage lisible, et dispositif WO2019071929A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710930604.X 2017-10-09
CN201710930604.XA CN107678967B (zh) 2017-10-09 2017-10-09 单元测试覆盖率生成方法、装置、可读存储介质及设备

Publications (1)

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

Family

ID=61139315

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/082346 WO2019071929A1 (fr) 2017-10-09 2018-04-09 Procédé et appareil de génération de couverture de code (cc) de test unitaire, support de stockage lisible, et dispositif

Country Status (2)

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

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107678967B (zh) * 2017-10-09 2020-02-07 武汉斗鱼网络科技有限公司 单元测试覆盖率生成方法、装置、可读存储介质及设备
CN113722232A (zh) * 2021-09-10 2021-11-30 中国银行股份有限公司 单元测试覆盖率控制方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102419728A (zh) * 2011-11-01 2012-04-18 北京邮电大学 基于覆盖率量化指标确定软件测试过程充分性的方法
CN104375941A (zh) * 2014-12-11 2015-02-25 无锡江南计算技术研究所 可执行程序测试用例集二进制代码覆盖率自动化评估方法
CN105224460A (zh) * 2015-10-23 2016-01-06 浪潮电子信息产业股份有限公司 一种基于插装技术统计测试覆盖率的方法
US20170083430A1 (en) * 2015-09-22 2017-03-23 Red Hat Israel, Ltd. Code coverage plugin
CN107678967A (zh) * 2017-10-09 2018-02-09 武汉斗鱼网络科技有限公司 单元测试覆盖率生成方法、装置、可读存储介质及设备

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016146032A (ja) * 2015-02-06 2016-08-12 日本電気株式会社 ソフトウェアの網羅試験装置および網羅試験方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102419728A (zh) * 2011-11-01 2012-04-18 北京邮电大学 基于覆盖率量化指标确定软件测试过程充分性的方法
CN104375941A (zh) * 2014-12-11 2015-02-25 无锡江南计算技术研究所 可执行程序测试用例集二进制代码覆盖率自动化评估方法
US20170083430A1 (en) * 2015-09-22 2017-03-23 Red Hat Israel, Ltd. Code coverage plugin
CN105224460A (zh) * 2015-10-23 2016-01-06 浪潮电子信息产业股份有限公司 一种基于插装技术统计测试覆盖率的方法
CN107678967A (zh) * 2017-10-09 2018-02-09 武汉斗鱼网络科技有限公司 单元测试覆盖率生成方法、装置、可读存储介质及设备

Also Published As

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

Similar Documents

Publication Publication Date Title
US7415444B2 (en) Determining compliance rates for probabilistic requests
WO2016091034A1 (fr) Procédé et dispositif pour fournir un paquet de canal d'application
WO2019094029A1 (fr) Système et techniques de triage automatisé de test de dispositif
CN104050054B (zh) 安装包安装失败的处理方法及原因确定方法及装置
CN109871312A (zh) 一种接口测试方法、装置、设备及可读存储介质
WO2019071929A1 (fr) Procédé et appareil de génération de couverture de code (cc) de test unitaire, support de stockage lisible, et dispositif
CN113535578B (zh) 一种cts测试方法、装置及测试设备
CN113742221A (zh) 生成测试用例的方法、电子设备及存储介质
CN110688428A (zh) 用于发布智能合约的方法和装置
CN108712236B (zh) 一种信息处理方法、装置以及电子设备
CN113342671B (zh) 对运算模块进行验证的方法、装置、电子设备和介质
US20110161716A1 (en) Systems, methods, and apparatuses for providing access to real time information
CN110022327B (zh) 一种短信认证测试方法和装置
TW201708836A (zh) 基於協定之自動化測試器刺激產生器
CN113535580B (zh) 一种cts测试方法、装置及测试设备
CN113098730B (zh) 一种服务器的测试方法及设备
CN112380127B (zh) 测试用例回归方法、装置、设备和存储介质
CN114090355A (zh) 硅后测试的方法、系统、设备以及存储介质
CN110988661B (zh) 一种fpga原型验证开发板时分分析系统、方法、介质及终端
CN111190824A (zh) 监测方法、装置、终端设备及存储介质
US20160077942A1 (en) Storage system and test method for testing pci express interface
CN108135000B (zh) 一种认证方法及设备
CN111444068B (zh) 系统性能测试方法、装置、计算机设备及存储介质
CN116170717B (zh) 复杂噪声环境下耳机降噪测试方法、装置及电子设备
CN107885659A (zh) 对客户端的请求模拟响应的方法及装置、设备

Legal Events

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

Ref document number: 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