CN112559337A - Code coverage rate testing method and device, electronic equipment and storage medium - Google Patents

Code coverage rate testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112559337A
CN112559337A CN202011439613.7A CN202011439613A CN112559337A CN 112559337 A CN112559337 A CN 112559337A CN 202011439613 A CN202011439613 A CN 202011439613A CN 112559337 A CN112559337 A CN 112559337A
Authority
CN
China
Prior art keywords
code
instrumentation
difference
test
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011439613.7A
Other languages
Chinese (zh)
Inventor
高林龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011439613.7A priority Critical patent/CN112559337A/en
Publication of CN112559337A publication Critical patent/CN112559337A/en
Pending legal-status Critical Current

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
    • 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/3692Test management for test results analysis

Landscapes

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

Abstract

The invention relates to the technical field of testing, and discloses a code coverage rate testing method, which comprises the following steps: acquiring a system source code, identifying a difference code existing in the system source code, and executing instrumentation processing on the difference code to form a difference code instrumentation file; packaging the system source codes to obtain a system operation package; carrying out difference code testing on the system operation package by using a preset system testing machine to obtain a test code instrumentation file; and calculating the code coverage rate of the test code instrumentation file and the difference code instrumentation file, and generating a code coverage rate report. The invention also provides a code coverage rate testing device, electronic equipment and a storage medium. Furthermore, the invention relates to blockchain techniques, in which the system source code can be stored. The invention can improve the accuracy of the code coverage rate test.

Description

Code coverage rate testing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of system testing, and in particular, to a method and an apparatus for testing code coverage, an electronic device, and a computer-readable storage medium.
Background
Code coverage is a measure in software testing that describes the proportion and extent to which source Code is tested in a program, and the resulting proportion is referred to as Code coverage. Currently, code coverage is usually tested by using the IstanBoolean technology, but the code coverage test realized by the IstanBoolean technology has the following defects:
firstly, the IsteBoolean can pile all codes of the whole system project for testing, and for the codes which are stably on-line and do not relate to the testing range, the codes can also be piled with the testing piles, so that the accuracy of the code coverage rate test can be influenced;
secondly, the Isteboolean adopts a source code to convert the AST tree into an instrumentation code, the instrumentation code is completely mixed into a system project source code, and the system project source code which is confused by the Isteboolean, such as a pile of messy codes, can not be seen completely, so that the accuracy of the code coverage rate test is influenced;
thirdly, the instein boolean cannot effectively process multi-warehouse and multi-frame mixed code coverage test of one system project, so that the source code of which section of the system project is covered or not can not be known, and the accuracy of the code coverage test can be influenced.
In summary, the existing code coverage rate test has the problem of low accuracy.
Disclosure of Invention
The invention provides a code coverage rate testing method and device, electronic equipment and a computer readable storage medium, and mainly aims to improve the accuracy of code coverage rate testing.
In order to achieve the above object, the present invention provides a code coverage rate testing method, which includes:
acquiring a system source code, identifying a difference code existing in the system source code, and executing instrumentation processing on the difference code to form a difference code instrumentation file;
packaging the system source codes to obtain a system operation package;
carrying out difference code testing on the system operation package by using a preset system testing machine to obtain a test code instrumentation file;
and calculating the code coverage rate of the test code instrumentation file and the difference code instrumentation file, and generating a code coverage rate report.
Optionally, the identifying the difference code existing in the system source code includes:
querying an open source code corresponding to the system source code from an open source distributed version control system;
and acquiring a difference code from the system source code according to the open source code.
Optionally, the packaging the system source code to obtain a system operation package includes:
acquiring a code compiling environment of the system source code, and establishing storage dependence of the system source code and a local warehouse in the code compiling environment;
and storing the system source code into the local warehouse according to the storage dependence to generate a system operation package.
Optionally, the performing, by using a preset system tester, a difference code running test on the system running package to obtain a test code instrumentation file includes:
testing the difference codes of the system operation packages by using a local tester in the system tester to obtain a local test result;
testing the difference codes of the system operation packages by using a server tester in the system tester to obtain a server test result;
and combining the local test result and the server test result to obtain the test code instrumentation file.
Optionally, the performing instrumentation on the difference code to form a difference code instrumentation file includes:
identifying whether a code instrumentation limit point exists in the difference code;
when no code instrumentation limit point exists, utilizing a code instrumentation statement to mark an instrumentation point in the difference code;
when a code instrumentation limit point exists, utilizing the code instrumentation statement to mark an instrumentation point at the tail end of a code line of the difference code;
and acquiring a code line and a configuration file of the difference code, and summarizing the code line, the configuration file and the pile inserting points to obtain the difference code pile inserting file.
Optionally, the calculating the code coverage of the test code instrumentation file and the difference code instrumentation file includes:
calculating the code coverage of the test code instrumentation file and the difference code instrumentation file using the following method:
ρX,Y=E(XY+μXμYXσY)
where ρ isX,YRepresenting code coverage, X representing the code line of the difference code instrumentation file, Y representing the code line of the test code instrumentation file,. mu.XCode parameter, μ, representing a difference code instrumentation fileYCode parameter, σ, representing a test code instrumentation fileXConfiguration file, sigma, representing instrumentation files for test codesYAnd E represents the expected code coverage rate of the test code instrumentation file and the difference code instrumentation file.
Optionally, the code coverage report includes: differential code coverage, code line coverage, code parameter coverage, and profile coverage.
In order to solve the above problem, the present invention further provides a code coverage testing apparatus, including:
the instrumentation module is used for acquiring a system source code, identifying a difference code existing in the system source code, and executing instrumentation processing on the difference code to form a difference code instrumentation file;
the packaging module is used for packaging the system source code to obtain a system operation package;
the test module is used for carrying out difference code test on the system operation package by using a preset system test machine to obtain a test code instrumentation file;
and the calculation module is used for calculating the code coverage rate of the test code instrumentation file and the difference code instrumentation file and generating a code coverage rate report.
In order to solve the above problem, the present invention also provides an electronic device, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to implement the code coverage testing method described above.
In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored, the at least one computer program being executed by a processor in an electronic device to implement the code coverage testing method described above.
The method comprises the steps of firstly obtaining a system source code, identifying a difference code existing in the system source code, performing instrumentation on the difference code to form a code instrumentation file, and performing instrumentation test on all source codes of a system project through instrumentation of the difference code to prevent the instrumentation code from being mixed into the system source code; secondly, the system source codes are packaged to obtain a system operation package, a preset system testing machine is used for carrying out difference code testing on the system operation package to obtain a test code instrumentation file, and the coverage condition of the difference codes in the system project can be clearly known; further, the embodiment of the present invention calculates the code coverage of the test code instrumentation file and the code instrumentation file to form a code coverage report. Therefore, the code coverage rate testing method, the code coverage rate testing device, the electronic equipment and the storage medium can improve the accuracy of code coverage rate testing.
Drawings
Fig. 1 is a schematic flowchart of a code coverage testing method according to an embodiment of the present invention;
FIG. 2 is a detailed flowchart illustrating one step of the code coverage testing method provided in FIG. 1 according to an embodiment of the present invention;
FIG. 3 is a detailed flowchart illustrating another step of the code coverage testing method provided in FIG. 1 according to an embodiment of the present invention
FIG. 4 is a block diagram of a code coverage testing apparatus according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an internal structure of an electronic device implementing a code coverage testing method according to an embodiment of the present invention;
the implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the application provides a code coverage rate testing method. The execution subject of the code coverage rate testing method includes, but is not limited to, at least one of electronic devices such as a server and a terminal, which can be configured to execute the method provided by the embodiments of the present application. In other words, the code coverage testing method may be performed by software or hardware installed in the terminal device or the server device, and the software may be a block chain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
Referring to fig. 1, which is a schematic flow chart of a code coverage testing method according to an embodiment of the present invention, in an embodiment of the present invention, the code coverage testing method includes:
s1, obtaining a system source code, identifying a difference code existing in the system source code, and performing instrumentation on the difference code to form a difference code instrumentation file.
In the embodiment of the invention, the system source code refers to a text code of a compiling system, and the system source code can be compiled by a developer or downloaded from an open source website. The difference code refers to delta code of existing source code corresponding to system source code, for example, difference code in a new system from an old system in an update process of a system version.
In detail, referring to fig. 2, the identifying the difference code existing in the system source code includes:
s10, inquiring open source codes corresponding to the system source codes from the open source distributed version control systems such as git and the like;
and S11, acquiring difference codes from the system source codes according to the open source codes.
In a preferred embodiment, the open source code refers to a text code that can be stably run on line and does not need to be tested any more, and the difference code is obtained by a preset code recognition script, where the preset code recognition script is compiled by a JavaScript language.
Further, in the embodiment of the present invention, the difference code is instrumented to form a difference code instrumentation file, which is used for comparing with a code instrumentation file tested subsequently to obtain a code coverage rate. Preferably, the code instrumentation file in the present invention includes: the method comprises the steps of code lines for marking instrumented code in the line number of system source code, code parameters and a configuration file, wherein the code parameters refer to instrumented code content, and the configuration file is used for characterizing instrumented code logic.
In detail, the instrumentation the difference code to form a difference code instrumentation file includes: identifying whether the difference code has a code instrumentation limit point; if no code instrumentation limit point exists, marking an instrumentation point in the difference code by using a code instrumentation statement; if the code instrumentation limit points exist, utilizing the code instrumentation statements to mark instrumentation points at the tail ends of the code lines of the difference codes; and acquiring a code line and a configuration file of the difference code, and summarizing the code line, the configuration file and the pile inserting points to obtain the difference code pile inserting file.
In a preferred embodiment, the code instrumentation limit point comprises: functions, objects, classes, etc., the code instrumentation constraint points are identified by js scripts.
In a preferred embodiment, the code instrumentation statement is compiled by JavaScript script, and the instrumentation point is used for marking difference codes.
The instrumentation based on the difference codes avoids instrumentation tests on all source codes of the system project, and prevents instrumentation codes from mixing into the source codes of the system according to code instrumentation limit points.
Further, the embodiment of the invention also comprises the step of uploading the difference code instrumentation file to a server, so that the safety of the code coverage rate test is ensured.
Further, to achieve the reusability and security of the difference code, the difference code may also be stored in a blockchain node.
And S2, packaging the system source codes to obtain a system operation package.
In at least one embodiment of the present invention, the S2 includes: acquiring a code compiling environment of the system source code, and establishing storage dependence of the system source code and a local warehouse in the code compiling environment; and storing the system source code into the local warehouse according to the storage dependence to form a system operation package.
Wherein, the code compiling environment is an integrated environment for compiling the system source code, such as Myeclipse, Eclipse, sublime, etc.; the storage dependency refers to a directory location where the system source code is stored; the local warehouse can be a maven warehouse, the format of the system operation package is jar package, and the system operation package can be operated in a front-end browser.
And S3, carrying out difference code test on the system operation package by using a preset system tester to obtain a test code instrumentation file.
In a preferred embodiment of the present invention, the preset system tester includes a local tester and a server tester, and the code instrumentation file test of the local tester and the server tester can more comprehensively understand the running coverage of the difference codes in the system running package, so that the code coverage of the difference codes can be more accurately tested. Preferably, the server tester is a hit tester.
S30, testing the difference codes of the system operation package by using a local testing machine to obtain a local test result;
s31, testing the difference codes of the system operation package by using a server testing machine to obtain a server test result;
and S32, combining the local test result and the server test result to obtain the test code instrumentation file.
Wherein the S30 includes: and running the difference codes of the system running package by using the local testing machine, and recording the coverage record of the difference codes of the system running package when the difference codes run in the local testing machine until the running of the difference codes of the system running package in the local testing machine is finished to obtain a local testing result. Wherein the overlay record of the difference code is recorded by a get () command in the local tester.
It should be noted that the implementation principle of the S31 is the same as that of the S30, and is not further described here.
Further, the local test result and the server test result are merged, that is, the local test result and the server test result are averaged.
Further, it is to be stated that the test code instrumentation file includes: run code lines of the difference code, run code parameters, and a run configuration file.
Furthermore, the embodiment of the invention also comprises the step of uploading the test code instrumentation file to a server, so that the safety of the code coverage rate test is ensured.
And S4, calculating the code coverage rate of the test code instrumentation file and the difference code instrumentation file to form a code coverage rate report.
In a preferred implementation of the present invention, the code coverage of the test code instrumentation file and the difference code instrumentation file is calculated in the server, which can ensure the safety of the calculation environment of the code coverage.
In an alternative embodiment, the code coverage of the test code instrumentation file and the difference code instrumentation file is calculated using the following method:
ρX,Y=E(XY+μXμYXσY)
where ρ isX,YRepresenting code coverage, X representing the code line of the difference code instrumentation file, Y representing the code line of the test code instrumentation file,. mu.XCode parameter, μ, representing a difference code instrumentation fileYCode parameter, σ, representing a test code instrumentation fileXConfiguration file, sigma, representing instrumentation files for test codesYAnd E represents the expected code coverage rate of the test code instrumentation file and the difference code instrumentation file.
Further, in the embodiment of the present invention, a code coverage report is generated according to the code coverage, where the code coverage report includes: differential code coverage, code line coverage, code parameter coverage, and profile coverage.
The method comprises the steps of firstly obtaining a system source code, identifying a difference code existing in the system source code, performing instrumentation on the difference code to form a code instrumentation file, and performing instrumentation test on all source codes of a system project through instrumentation of the difference code to prevent the instrumentation code from being mixed into the system source code; secondly, the system source codes are packaged to obtain a system operation package, a preset system testing machine is used for carrying out difference code testing on the system operation package to obtain a test code instrumentation file, and the coverage condition of the difference codes in the system project can be clearly known; further, the embodiment of the present invention calculates the code coverage of the test code instrumentation file and the code instrumentation file to form a code coverage report. Therefore, the code coverage rate testing method provided by the invention can improve the accuracy of code coverage rate testing.
Fig. 4 is a functional block diagram of the code coverage testing apparatus according to the present invention.
The code coverage testing apparatus 100 according to the present invention may be installed in an electronic device. According to the implemented functions, the code coverage testing apparatus may include an instrumentation module 101, a packaging module 102, a testing module 103, and a calculation module 104. A module according to the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the instrumentation module 101 is configured to obtain a system source code, identify a difference code existing in the system source code, and perform instrumentation on the difference code to form a difference code instrumentation file.
In the embodiment of the invention, the system source code refers to a text code of a compiling system, and the system source code can be compiled by a developer or downloaded from an open source website. The difference code refers to delta code of existing source code corresponding to system source code, for example, difference code in a new system from an old system in an update process of a system version.
In detail, the instrumentation module 101 identifies the difference code existing in the system source code by the following method:
step A, inquiring an open source code corresponding to a system source code from a git equal open source distributed version control system;
and B, acquiring a difference code from the system source code according to the open source code.
In a preferred embodiment, the open source code refers to a text code that can be stably run on line and does not need to be tested any more, and the difference code is obtained by a preset code recognition script, where the preset code recognition script is compiled by a JavaScript language.
Further, in the embodiment of the present invention, the difference code is instrumented to form a difference code instrumentation file, which is used for comparing with a code instrumentation file tested subsequently to obtain a code coverage rate. Preferably, the code instrumentation file in the present invention includes: the method comprises the steps of code lines for marking instrumented code in the line number of system source code, code parameters and a configuration file, wherein the code parameters refer to instrumented code content, and the configuration file is used for characterizing instrumented code logic.
In detail, the instrumentation of the difference code is performed to form a difference code instrumentation file, and the instrumentation module 101 performs the following steps: identifying whether the difference code has a code instrumentation limit point; if no code instrumentation limit point exists, marking an instrumentation point in the difference code by using a code instrumentation statement; if the code instrumentation limit points exist, utilizing the code instrumentation statements to mark instrumentation points at the tail ends of the code lines of the difference codes; and acquiring a code line and a configuration file of the difference code, and summarizing the code line, the configuration file and the pile inserting points to obtain the difference code pile inserting file.
In a preferred embodiment, the code instrumentation limit point comprises: functions, objects, classes, etc., the code instrumentation constraint points are identified by js scripts.
In a preferred embodiment, the code instrumentation statement is compiled by JavaScript script, and the instrumentation point is used for marking difference codes.
The instrumentation based on the difference codes avoids instrumentation tests on all source codes of the system project, and prevents instrumentation codes from mixing into the source codes of the system according to code instrumentation limit points.
Further, the embodiment of the invention also comprises the step of uploading the difference code instrumentation file to a server, so that the safety of the code coverage rate test is ensured.
Further, to achieve the reusability and security of the difference code, the difference code may also be stored in a blockchain node.
The packing module 102 is configured to pack the system source code to obtain a system operation package.
In at least one embodiment of the invention, the packaging module 102 is specifically configured to: acquiring a code compiling environment of the system source code, and establishing storage dependence of the system source code and a local warehouse in the code compiling environment; and storing the system source code into the local warehouse according to the storage dependence to form a system operation package.
Wherein, the code compiling environment is an integrated environment for compiling the system source code, such as Myeclipse, Eclipse, sublime, etc.; the storage dependency refers to a directory location where the system source code is stored; the local warehouse can be a maven warehouse, the format of the system operation package is jar package, and the system operation package can be operated in a front-end browser.
The test module 103 is configured to perform a difference code test on the system operation package by using a preset system tester to obtain a test code instrumentation file.
In a preferred embodiment of the present invention, the preset system tester includes a local tester and a server tester, and the code instrumentation file test of the local tester and the server tester can more comprehensively understand the running coverage of the difference codes in the system running package, so that the code coverage of the difference codes can be more accurately tested. Preferably, the server tester is a hit tester
In detail, the difference code running test is performed on the system running package by using a preset system tester to obtain a test code instrumentation file, and the test module 103 is specifically configured to:
step I, testing the difference codes of the system operation package by using a local testing machine to obtain a local test result;
step II, testing the difference codes of the system operation package by using a server testing machine to obtain a server testing result;
and III, combining the local test result and the server test result to obtain the test code instrumentation file.
Wherein, the step I comprises the following steps: and running the difference codes of the system running package by using the local testing machine, and recording the coverage record of the difference codes of the system running package when the difference codes run in the local testing machine until the running of the difference codes of the system running package in the local testing machine is finished to obtain a local testing result. Wherein the overlay record of the difference code is recorded by a get () command in the local tester.
It should be noted that the implementation principle of step II is the same as that of step I, and is not further described here.
Further, the local test result and the server test result are merged, that is, the local test result and the server test result are averaged.
Further, it is to be stated that the test code instrumentation file includes: run code lines of the difference code, run code parameters, and a run configuration file.
Furthermore, the embodiment of the invention also comprises the step of uploading the test code instrumentation file to a server, so that the safety of the code coverage rate test is ensured.
The calculating module 104 is configured to calculate code coverage rates of the test code instrumentation file and the difference code instrumentation file, and form a code coverage rate report.
In a preferred implementation of the present invention, the code coverage of the test code instrumentation file and the difference code instrumentation file is calculated in the server, which can ensure the safety of the calculation environment of the code coverage.
In an alternative embodiment, the calculation module 104 calculates the code coverage of the test code instrumentation file and the difference code instrumentation file by:
ρX,Y=E(XY+μXμYXσY)
where ρ isX,YRepresenting code coverage, X representing the code line of the difference code instrumentation file, Y representing the code line of the test code instrumentation file,. mu.XCode parameter, μ, representing a difference code instrumentation fileYCode parameter, σ, representing a test code instrumentation fileXInstrumented file for representing test codesConfiguration file of σYAnd E represents the expected code coverage rate of the test code instrumentation file and the difference code instrumentation file.
Further, the calculation module 104 is configured to generate a code coverage report according to the code coverage, where the code coverage report includes: differential code coverage, code line coverage, code parameter coverage, and profile coverage.
The method comprises the steps of firstly obtaining a system source code, identifying a difference code existing in the system source code, performing instrumentation on the difference code to form a code instrumentation file, and performing instrumentation test on all source codes of a system project through instrumentation of the difference code to prevent the instrumentation code from being mixed into the system source code; secondly, the system source codes are packaged to obtain a system operation package, a preset system testing machine is used for carrying out difference code testing on the system operation package to obtain a test code instrumentation file, and the coverage condition of the difference codes in the system project can be clearly known; further, the embodiment of the present invention calculates the code coverage of the test code instrumentation file and the code instrumentation file to form a code coverage report. Therefore, the code coverage rate testing device provided by the invention can improve the accuracy of the code coverage rate test.
Fig. 5 is a schematic structural diagram of an electronic device implementing the code coverage testing method according to the present invention.
The electronic device 1 may comprise a processor 10, a memory 11 and a bus, and may further comprise a computer program, such as a code coverage test program 12, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device 1, such as a removable hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 1. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 may be used not only to store application software installed in the electronic device 1 and various types of data, such as codes for code coverage tests, but also to temporarily store data that has been output or is to be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the whole electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (for example, performing a code coverage test, etc.) stored in the memory 11 and calling data stored in the memory 11.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 5 only shows an electronic device with components, and it will be understood by a person skilled in the art that the structure shown in fig. 5 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
For example, although not shown, the electronic device 1 may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so as to implement functions of charge management, discharge management, power consumption management, and the like through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 1 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device 1 may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the electronic device 1 and other electronic devices.
Optionally, the electronic device 1 may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The code coverage test 12 stored by the memory 11 in the electronic device 1 is a combination of instructions that, when executed in the processor 10, may implement:
acquiring a system source code, identifying a difference code existing in the system source code, and executing instrumentation processing on the difference code to form a difference code instrumentation file;
packaging the system source codes to obtain a system operation package;
carrying out difference code testing on the system operation package by using a preset system testing machine to obtain a test code instrumentation file;
and calculating the code coverage rate of the test code instrumentation file and the difference code instrumentation file, and generating a code coverage rate report.
Specifically, the specific implementation method of the processor 10 for the instruction may refer to the description of the relevant steps in the embodiments corresponding to fig. 1 to 3, which is not repeated herein.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method for code coverage testing, the method comprising:
acquiring a system source code, identifying a difference code existing in the system source code, and executing instrumentation processing on the difference code to form a difference code instrumentation file;
packaging the system source codes to obtain a system operation package;
carrying out difference code testing on the system operation package by using a preset system testing machine to obtain a test code instrumentation file;
and calculating the code coverage rate of the test code instrumentation file and the difference code instrumentation file, and generating a code coverage rate report.
2. The code coverage testing method of claim 1, wherein said identifying the difference code present in the system source code comprises:
querying an open source code corresponding to the system source code from an open source distributed version control system;
and acquiring a difference code from the system source code according to the open source code.
3. The code coverage testing method of claim 1, wherein the step of packaging the system source code to obtain a system operation package comprises:
acquiring a code compiling environment of the system source code, and establishing storage dependence of the system source code and a local warehouse in the code compiling environment;
and storing the system source code into the local warehouse according to the storage dependence to generate a system operation package.
4. The code coverage testing method of claim 1, wherein the performing a difference code running test on the system running package by using a preset system tester to obtain a test code instrumentation file comprises:
testing the difference codes of the system operation packages by using a local tester in the system tester to obtain a local test result;
testing the difference codes of the system operation packages by using a server tester in the system tester to obtain a server test result;
and combining the local test result and the server test result to obtain the test code instrumentation file.
5. The code coverage testing method of claim 1, wherein said performing instrumentation on said difference code to form a difference code instrumentation file comprises:
identifying whether a code instrumentation limit point exists in the difference code;
when no code instrumentation limit point exists, utilizing a code instrumentation statement to mark an instrumentation point in the difference code;
when a code instrumentation limit point exists, utilizing the code instrumentation statement to mark an instrumentation point at the tail end of a code line of the difference code;
and acquiring a code line and a configuration file of the difference code, and summarizing the code line, the configuration file and the pile inserting points to obtain the difference code pile inserting file.
6. The code coverage testing method of claim 5, wherein said calculating code coverage of the test code instrumentation file and the difference code instrumentation file comprises:
calculating the code coverage of the test code instrumentation file and the difference code instrumentation file using the following method:
ρX,Y=E(XY+μxμYxσY)
where ρ isX,YRepresenting code coverage, X representing the code line of the difference code instrumentation file, Y representing the code line of the test code instrumentation file,. mu.XCode parameter, μ, representing a difference code instrumentation fileYCode parameter, σ, representing a test code instrumentation fileXConfiguration file, sigma, representing instrumentation files for test codesYAnd E represents the expected code coverage rate of the test code instrumentation file and the difference code instrumentation file.
7. The code coverage test method of any one of claims 1 to 6, wherein the code coverage report comprises: differential code coverage, code line coverage, code parameter coverage, and profile coverage.
8. An apparatus for code coverage testing, the apparatus comprising:
the instrumentation module is used for acquiring a system source code, identifying a difference code existing in the system source code, and executing instrumentation processing on the difference code to form a difference code instrumentation file;
the packaging module is used for packaging the system source code to obtain a system operation package;
the test module is used for carrying out difference code test on the system operation package by using a preset system test machine to obtain a test code instrumentation file;
and the calculation module is used for calculating the code coverage rate of the test code instrumentation file and the difference code instrumentation file and generating a code coverage rate report.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the code coverage testing method of any one of claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out a code coverage testing method according to any one of claims 1 to 7.
CN202011439613.7A 2020-12-10 2020-12-10 Code coverage rate testing method and device, electronic equipment and storage medium Pending CN112559337A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011439613.7A CN112559337A (en) 2020-12-10 2020-12-10 Code coverage rate testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011439613.7A CN112559337A (en) 2020-12-10 2020-12-10 Code coverage rate testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112559337A true CN112559337A (en) 2021-03-26

Family

ID=75060570

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011439613.7A Pending CN112559337A (en) 2020-12-10 2020-12-10 Code coverage rate testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112559337A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113360394A (en) * 2021-06-25 2021-09-07 汇付天下有限公司 Code test coverage rate statistical method and device
CN114706749A (en) * 2022-03-03 2022-07-05 网宿科技股份有限公司 Method and device for determining code coverage rate, electronic equipment and storage medium
CN115858354A (en) * 2022-11-29 2023-03-28 广发银行股份有限公司 Test coverage rate calculation method, system, terminal and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113360394A (en) * 2021-06-25 2021-09-07 汇付天下有限公司 Code test coverage rate statistical method and device
CN114706749A (en) * 2022-03-03 2022-07-05 网宿科技股份有限公司 Method and device for determining code coverage rate, electronic equipment and storage medium
CN115858354A (en) * 2022-11-29 2023-03-28 广发银行股份有限公司 Test coverage rate calculation method, system, terminal and storage medium
CN115858354B (en) * 2022-11-29 2023-08-18 广发银行股份有限公司 Test coverage rate calculation method, system, terminal and storage medium

Similar Documents

Publication Publication Date Title
CN112134739B (en) Link state tracking method and device, electronic equipment and computer storage medium
CN112559337A (en) Code coverage rate testing method and device, electronic equipment and storage medium
CN112506779A (en) Software interface testing method and device, electronic equipment and storage medium
CN112486490B (en) Front-end code packaging method and device, electronic equipment and storage medium
CN113377661A (en) Interface testing method and device, electronic equipment and storage medium
CN112579098A (en) Software release method and device, electronic equipment and readable storage medium
CN113238929B (en) Code testing method and device based on Mock data, electronic equipment and storage medium
CN112882995A (en) Script automatic generation method and device, electronic equipment and storage medium
CN112631903A (en) Task testing method and device, electronic equipment and storage medium
CN112527664A (en) Method and device for generating test case, electronic equipment and storage medium
CN112579475A (en) Code testing method, device, equipment and readable storage medium
CN114661423A (en) Cluster configuration detection method and device, computer equipment and storage medium
CN112214256A (en) Operation control method and device for machine learning, electronic equipment and storage medium
CN112541688A (en) Service data checking method and device, electronic equipment and computer storage medium
CN115033489A (en) Code resource detection method and device, electronic equipment and storage medium
CN113051171A (en) Interface test method, device, equipment and storage medium
CN114185588A (en) Incremental package generation method, device, equipment and storage medium
CN112667244A (en) Data verification method and device, electronic equipment and computer readable storage medium
CN113485711A (en) Task triggering method and device based on dependency relationship, electronic equipment and medium
CN113342379B (en) Micro-service upgrading method and device, electronic equipment and storage medium
CN112947974B (en) Desktop icon updating method, device and equipment and computer readable storage medium
CN113064797B (en) Front-end monitoring method and device, electronic equipment and storage medium
CN115357474A (en) Local test method, device, equipment and storage medium
CN113434365B (en) Data characteristic monitoring method and device, electronic equipment and storage medium
CN114237689A (en) System version monitoring method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination