CN111400189A - Code coverage rate monitoring method and device, electronic equipment and storage medium - Google Patents

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

Info

Publication number
CN111400189A
CN111400189A CN202010216666.6A CN202010216666A CN111400189A CN 111400189 A CN111400189 A CN 111400189A CN 202010216666 A CN202010216666 A CN 202010216666A CN 111400189 A CN111400189 A CN 111400189A
Authority
CN
China
Prior art keywords
code
target dynamic
code coverage
execution information
coverage rate
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
CN202010216666.6A
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 Bank Co Ltd
Original Assignee
Ping An Bank 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 Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202010216666.6A priority Critical patent/CN111400189A/en
Publication of CN111400189A publication Critical patent/CN111400189A/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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/562Brokering proxy services

Abstract

The invention relates to the technical field of testing, and provides a code coverage monitoring method and device, electronic equipment and a storage medium. The method can arrange proxy nodes in codes of a target dynamic script, when a calling request of the target dynamic script is received, the target dynamic script is executed, code execution information of the target dynamic script is recorded through the proxy nodes, the code execution information is further obtained and analyzed, a code coverage rate data set is obtained, real-time monitoring of code coverage rate is achieved through the proxy nodes, and the problem that the code coverage rate is lost is solved.

Description

Code coverage rate monitoring method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of testing, in particular to a code coverage rate monitoring method and device, electronic equipment and a storage medium.
Background
With the wave of artificial intelligence rolling the world, it is very important to check the code test quality. Code coverage is used as an index for characterizing code test quality, and the demand for real-time acquisition and monitoring of the code coverage is gradually becoming prominent.
In a traditional code coverage rate statistical scheme, a manual analysis mode is generally adopted to count the code coverage rate of a dynamic script, so that the efficiency is low, and the accuracy is low. Therefore, the industry mostly uses open source coverage statistics tools to perform statistics on code coverage, and these statistics tools work in a mode of regularly collecting code coverage data, which may be lost, for example: code coverage data is lost when the application is restarted, resulting in more passive and lagging code coverage statistics.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a code coverage monitoring method, apparatus, electronic device and storage medium, which can implement real-time monitoring of code coverage through a proxy node and solve the problem of code coverage loss.
In order to solve the above problem, the present invention provides a code coverage monitoring method, including:
arranging proxy nodes in the code of the target dynamic script;
executing the target dynamic script when a calling request of the target dynamic script is received;
recording code execution information of the target dynamic script through the proxy node;
and acquiring and analyzing the code execution information to obtain a code coverage rate data set.
According to a preferred embodiment of the present invention, the arranging the agent node in the code of the target dynamic scenario includes:
determining the code types of all code segments of the target dynamic script;
matching each code type in a preset configuration rule;
and arranging the proxy nodes on the code sections corresponding to the matched code types.
According to a preferred embodiment of the present invention, the determining the code types of the code segments of the target dynamic scenario includes:
determining respective code branches of the target dynamic script, and determining a code type of each sub-code segment of each code branch.
According to a preferred embodiment of the present invention, the recording, by the proxy node, the code execution information of the target dynamic scenario includes:
monitoring an access layer log through the proxy node, and transmitting distribution topology information called by the access layer; or
Detecting the topology called by the application program through the proxy node, and transmitting data; or
Detecting a Network logic topology based on an SNMP (Simple Network Management Protocol) through the agent node, and transmitting data; or
And detecting the physical port based on an interface flow analysis method through the proxy node, and transmitting data.
According to the preferred embodiment of the present invention, after the code execution information of the target dynamic scenario is recorded by the proxy node, the method further includes:
performing data compression on the code execution information to obtain a compressed file set of the code execution information;
and storing the compressed file set to a database.
According to the preferred embodiment of the present invention, the obtaining and analyzing the code execution information to obtain a code coverage data set includes:
acquiring the compressed file set from the database;
carrying out data decompression on the compressed file set to obtain the code execution information;
acquiring a test case identifier of the target dynamic script from the code execution information;
carrying out keyword matching on the calling request and the test case identification to obtain a matching result;
calculating a code coverage rate for each time period based on the matching result;
and integrating the calculated code coverage rate to obtain the code coverage rate data set.
According to a preferred embodiment of the invention, the method further comprises:
performing label processing on the code coverage rate in the code coverage rate data set according to the preset configuration rule to obtain a label set;
performing visualization processing on the label set to obtain a processing result;
and displaying the processing result in real time.
In order to solve the above problem, the present invention further provides a code coverage monitoring apparatus, including:
an arrangement unit for arranging the proxy nodes in the code of the target dynamic scenario;
the execution unit is used for executing the target dynamic script when receiving a calling request of the target dynamic script;
the recording unit is used for recording the code execution information of the target dynamic script through the proxy node;
and the analysis unit is used for acquiring and analyzing the code execution information to obtain a code coverage rate data set.
According to a preferred embodiment of the present invention, the arranging unit arranges the proxy node in the code of the target dynamic scenario includes:
determining the code types of all code segments of the target dynamic script;
matching each code type in a preset configuration rule;
and arranging the proxy nodes on the code sections corresponding to the matched code types.
According to a preferred embodiment of the present invention, the determining the code types of the code segments of the target dynamic scenario includes:
determining respective code branches of the target dynamic script, and determining a code type of each sub-code segment of each code branch.
According to a preferred embodiment of the present invention, the recording unit is specifically configured to:
monitoring an access layer log through the proxy node, and transmitting distribution topology information called by the access layer; or
Detecting the topology called by the application program through the proxy node, and transmitting data; or
Detecting a network logic topology based on an SNMP protocol through the agent node, and transmitting data; or
And detecting the physical port based on an interface flow analysis method through the proxy node, and transmitting data.
According to a preferred embodiment of the invention, the apparatus further comprises:
the compression unit is used for performing data compression on the code execution information after the code execution information of the target dynamic script is recorded through the proxy node to obtain a compressed file set of the code execution information;
and the storage unit is used for storing the compressed file set to a database.
According to a preferred embodiment of the present invention, the parsing unit is specifically configured to:
acquiring the compressed file set from the database;
carrying out data decompression on the compressed file set to obtain the code execution information;
acquiring a test case identifier of the target dynamic script from the code execution information;
carrying out keyword matching on the calling request and the test case identification to obtain a matching result;
calculating a code coverage rate for each time period based on the matching result;
and integrating the calculated code coverage rate to obtain the code coverage rate data set.
According to a preferred embodiment of the invention, the apparatus further comprises:
the processing unit is used for performing label processing on the code coverage rate in the code coverage rate data set according to the preset configuration rule to obtain a label set;
the processing unit is further configured to perform visualization processing on the tag set to obtain a processing result;
and the display unit is used for displaying the processing result in real time.
In order to solve the above problem, the present invention also provides an electronic device, including:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the code coverage monitoring method.
In order to solve the above problem, the present invention also provides a computer-readable storage medium having at least one instruction stored therein, where the at least one instruction is executed by a processor in an electronic device to implement the code coverage monitoring method.
According to the technical scheme, the proxy nodes can be arranged in the codes of the target dynamic scripts, when a calling request for the target dynamic scripts is received, the target dynamic scripts are executed, the code execution information of the target dynamic scripts is recorded through the proxy nodes, the code execution information is further obtained and analyzed, a code coverage rate data set is obtained, so that the code coverage rate can be monitored in real time through the proxy nodes, and the problem of code coverage rate loss is solved.
Drawings
Fig. 1 is a flow chart of a code coverage monitoring method according to a preferred embodiment of the present invention.
FIG. 2 is a functional block diagram of a code coverage monitoring apparatus according to a preferred embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device implementing a code coverage monitoring method according to a preferred embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
Fig. 1 is a flow chart of a code coverage monitoring method according to a preferred embodiment of the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The code coverage monitoring method is applied to one or more electronic devices, where the electronic devices are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and hardware of the electronic devices includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive Internet Protocol Television (IPTV), an intelligent wearable device, and the like.
The electronic device may also include a network device and/or a user device. The network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a cloud computing (cloud computing) based cloud consisting of a large number of hosts or network servers.
The Network where the electronic device is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
S10, arranging Agent (Agent) nodes in the code of the target dynamic script.
In at least one embodiment of the present invention, the target dynamic scenario may be any scenario, and different dynamic scenarios can implement different functions after being executed.
In particular, the dynamic scenario may be configured in a service server for implementing a corresponding service logic.
For example, the dynamic scenario to be tested is associated with a certain service (hereinafter referred to as a target service) provided by the service server, and then the code coverage rate of the dynamic scenario in the stage of the service server providing the target service to the user can be tested. In this case, the service server may receive a user call request from the client within a preset time period, further respond to the user call request, execute the dynamic scenario, and subsequently may calculate the code coverage rate of the dynamic scenario within the preset time period according to the execution path recorded in the execution result.
In at least one embodiment of the invention, the proxy node is a proxy node through which information related to script execution can be collected.
In at least one embodiment of the present invention, the arranging the agent node in the code of the target dynamic scenario comprises:
and determining the code types of all code segments of the target dynamic script, matching all the code types in a preset configuration rule, and arranging agent nodes on the code segments corresponding to the matched code types.
In at least one embodiment of the present invention, the determining the code types of the code segments of the target dynamic script includes:
determining respective code branches of the target dynamic script, and determining a code type of each sub-code segment of each code branch. Through the embodiment, the code coverage rate information of each code segment can be efficiently detected in real time.
In other embodiments, the proxy nodes may also be manually arranged by a developer.
For example: and identifying the code branch of the dynamic script to be tested according to experience by a developer, and issuing a branch selection instruction to the service server aiming at the identified code branch. After receiving the branch selection instruction, the service server identifies the code branch of the dynamic script according to the code branch indicated by the received branch selection instruction, and arranges the proxy node on the identified code branch.
S11, when receiving the call request of the target dynamic script, executing the target dynamic script.
In at least one embodiment of the present invention, the number of the call requests may be multiple, and parameters included in each call request may be different.
The parameters can be understood as parameters quoted by each dynamic script when executed, namely, the dynamic script performs certain operation on the parameters provided by the call request to realize corresponding functions.
For example, assume that a dynamic scenario is used to determine whether a user conforms to a service rule of a certain service provided by a service server, where the rule specifically is: when the user is a new user, the user can enjoy the preferential interest A, and when the user is an old user, the user cannot enjoy the preferential interest A. In this case, the dynamic scenario determines whether the user can enjoy the benefit a according to whether the user is a new user, and then the referenced parameter is an identity indicating an identity of the new user or an identity of an old user. Correspondingly, the call request corresponding to the new user includes an identification for indicating the identity of the new user, and the call request corresponding to the old user includes an identification for indicating the identity of the old user. It can be seen that the invocation request corresponding to the new user and the invocation request corresponding to the old user have different parameters and belong to two different types of invocation requests.
In at least one embodiment of the invention, the executing the target dynamic script comprises:
and acquiring parameters from the calling request, determining the operation corresponding to the target dynamic script, and referring to the parameters to execute the operation.
And S12, recording the code execution information of the target dynamic script through the proxy node.
In at least one embodiment of the present invention, the recording, by the proxy node, the code execution information of the target dynamic scenario includes, but is not limited to, any one of the following manners:
(1) monitoring an access layer log through the proxy node, and transmitting distribution topology information called by the access layer;
(2) detecting the topology called by the application program through the proxy node, and transmitting data;
(3) detecting a Network logic topology based on an SNMP (Simple Network Management Protocol) through the agent node, and transmitting data;
(4) and detecting the physical port based on an interface flow analysis method through the proxy node, and transmitting data.
Through the embodiment, the code execution information of the target dynamic script can be recorded in real time through the proxy node, and the proxy node corresponds to the code segment, so that when data abnormity is found, the abnormal code segment can be directly positioned, and the quick positioning of an abnormal point is realized.
In at least one embodiment of the present invention, after recording the code execution information of the target dynamic scenario by the proxy node, the method further includes:
and performing data compression on the code execution information to obtain a compressed file set of the code execution information, and storing the compressed file set to a database.
Through the implementation mode, the code execution information can be compressed and stored in a warehouse so as to be convenient for storage and calling.
And S13, acquiring and analyzing the code execution information to obtain a code coverage rate data set.
In at least one embodiment of the invention, code coverage is used as an important index for measuring code quality, and is used for describing the proportion and the degree of testing of codes in a program.
In at least one embodiment of the present invention, the obtaining and analyzing the code execution information to obtain a code coverage data set includes:
and acquiring the compressed file set from the database, decompressing the compressed file set to obtain the code execution information, acquiring the test case identification of the target dynamic script from the code execution information, further performing keyword matching on the calling request and the test case identification to obtain a matching result, calculating the code coverage rate of each time period based on the matching result, and integrating the calculated code coverage rate to obtain the code coverage rate data set.
Specifically, the calculation method of the code coverage rate according to the present invention is not described in detail because of the conventional technique.
Through the embodiment, the code coverage rate can be determined based on the information recorded by the proxy node, and data loss does not occur.
In at least one embodiment of the invention, the method further comprises:
and labeling the code coverage rate in the code coverage rate data set according to the preset configuration rule to obtain a label set, performing visualization processing on the label set to obtain a processing result, and displaying the processing result in real time.
Through the implementation mode, the label set is visually displayed, the code coverage rate of the target dynamic script is reflected through visualization of the label, and the complexity of directly visualizing the code coverage rate data set is simplified.
In addition, through the visualization processing, the real-time code coverage rate in each time period can be displayed in real time, so that the user can perform aging monitoring on the code coverage rate in the dynamic process of program execution.
Specifically, the embodiment of the present invention may perform labeling processing on the code coverage in the code coverage data set according to the calling scenario of each dynamic scenario, or perform labeling processing on the code coverage in the code coverage data set according to the operation type, which is not limited in this respect.
Further, the visualizing the tag set to obtain a processing result includes:
and carrying out visualization processing on the label set based on a preset visualization component to obtain a processing result.
Wherein the preset visualization components may include, but are not limited to: the system comprises a carousel map visualization component, a zebra pillar map visualization component, a multi-dimensional pie chart visualization component, a line chart visualization component, a map visualization component and the like.
According to the technical scheme, the Agent nodes can be arranged in the codes of the target dynamic script, when a calling request for the target dynamic script is received, the target dynamic script is executed, the code execution information of the target dynamic script is recorded through the Agent nodes, the code execution information is further obtained and analyzed, and a code coverage rate data set is obtained, so that the code coverage rate can be monitored in real time through the Agent nodes, and the problem of code coverage rate loss is solved.
Fig. 2 is a functional block diagram of a code coverage monitoring apparatus according to a preferred embodiment of the present invention. The code coverage monitoring device 11 includes an arrangement unit 110, an execution unit 111, a recording unit 112, an analysis unit 113, a compression unit 114, a storage unit 115, a processing unit 116, and a display unit 117. The module/unit referred to in the present invention refers to a series of computer program segments that can be executed by the processor 13 and that can perform a fixed function, and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
The arranging unit 110 arranges the proxy nodes in the code of the target dynamic scenario.
In at least one embodiment of the present invention, the target dynamic scenario may be any scenario, and different dynamic scenarios can implement different functions after being executed.
In particular, the dynamic scenario may be configured in a service server for implementing a corresponding service logic.
For example, the dynamic scenario to be tested is associated with a certain service (hereinafter referred to as a target service) provided by the service server, and then the code coverage rate of the dynamic scenario in the stage of the service server providing the target service to the user can be tested. In this case, the service server may receive a user call request from the client within a preset time period, further respond to the user call request, execute the dynamic scenario, and subsequently may calculate the code coverage rate of the dynamic scenario within the preset time period according to the execution path recorded in the execution result.
In at least one embodiment of the invention, the proxy node is a proxy node through which information related to script execution can be collected.
In at least one embodiment of the present invention, the arranging unit 110 arranges the proxy node in the code of the target dynamic scenario includes:
the arranging unit 110 determines the code types of the code segments of the target dynamic script, matches the code types in a preset configuration rule, and the arranging unit 110 arranges the agent nodes on the code segments corresponding to the matched code types.
In detail, the arranging unit 110 determines each code branch of the target dynamic script and determines a code type of each sub-code segment of each code branch, and the arranging unit 110 matches each determined code type in a preset rule, and further arranges a proxy node on the sub-code segment corresponding to the matched code type.
Through the embodiment, the code coverage rate information of each code segment can be efficiently detected in real time.
In other embodiments, the proxy nodes may also be manually arranged by a developer.
For example: and identifying the code branch of the dynamic script to be tested according to experience by a developer, and issuing a branch selection instruction to the service server aiming at the identified code branch. After receiving the branch selection instruction, the service server identifies the code branch of the dynamic script according to the code branch indicated by the received branch selection instruction, and arranges the proxy node on the identified code branch.
When a call request for the target dynamic scenario is received, the execution unit 111 executes the target dynamic scenario.
In at least one embodiment of the present invention, the number of the call requests may be multiple, and parameters included in each call request may be different.
The parameters can be understood as parameters quoted by each dynamic script when executed, namely, the dynamic script performs certain operation on the parameters provided by the call request to realize corresponding functions.
For example, assume that a dynamic scenario is used to determine whether a user conforms to a service rule of a certain service provided by a service server, where the rule specifically is: when the user is a new user, the user can enjoy the preferential interest A, and when the user is an old user, the user cannot enjoy the preferential interest A. In this case, the dynamic scenario determines whether the user can enjoy the benefit a according to whether the user is a new user, and then the referenced parameter is an identity indicating an identity of the new user or an identity of an old user. Correspondingly, the call request corresponding to the new user includes an identification for indicating the identity of the new user, and the call request corresponding to the old user includes an identification for indicating the identity of the old user. It can be seen that the invocation request corresponding to the new user and the invocation request corresponding to the old user have different parameters and belong to two different types of invocation requests.
In at least one embodiment of the present invention, the executing unit 111 executing the target dynamic scenario includes:
the execution unit 111 obtains a parameter from the call request, and determines an operation corresponding to the target dynamic scenario, and the execution unit 111 refers to the parameter to execute the operation.
The recording unit 112 records the code execution information of the target dynamic scenario through the proxy node.
In at least one embodiment of the present invention, the recording unit 112 records the code execution information of the target dynamic scenario through the proxy node, including, but not limited to, any one of the following ways:
(1) the recording unit 112 monitors the access stratum log through the proxy node and transmits the distribution topology information called by the access stratum.
(2) The recording unit 112 probes the topology called by the application program through the proxy node and transmits data.
(3) The recording unit 112 detects a network logic topology based on an SNMP (Simple network management Protocol) Protocol through the proxy node, and transmits data.
(4) The recording unit 112 detects a physical port based on an interface traffic analysis method through the proxy node, and transmits data.
Through the embodiment, the code execution information of the target dynamic script can be recorded in real time through the proxy node, and the proxy node corresponds to the code segment, so that when data abnormity is found, the abnormal code segment can be directly positioned, and the quick positioning of an abnormal point is realized.
In at least one embodiment of the present invention, after recording the code execution information of the target dynamic scenario by the proxy node, the method further includes:
the compression unit 114 performs data compression on the code execution information to obtain a compressed file set of the code execution information, and the storage unit 115 stores the compressed file set to a database.
Through the implementation mode, the code execution information can be compressed and stored in a warehouse so as to be convenient for storage and calling.
The parsing unit 113 obtains and parses the code execution information, resulting in a code coverage data set.
In at least one embodiment of the invention, code coverage is used as an important index for measuring code quality, and is used for describing the proportion and the degree of testing of codes in a program.
In at least one embodiment of the present invention, the obtaining and parsing the code execution information by the parsing unit 113 to obtain a code coverage data set includes:
the analysis unit 113 obtains the compressed file set from the database, decompresses the compressed file set to obtain the code execution information, obtains the test case identifier of the target dynamic script from the code execution information, further performs keyword matching between the call request and the test case identifier to obtain a matching result, and the analysis unit 113 calculates the code coverage rate of each time period based on the matching result and integrates the calculated code coverage rate to obtain the code coverage rate dataset.
Specifically, the calculation method of the code coverage rate according to the present invention is not described in detail because of the conventional technique.
Through the embodiment, the code coverage rate can be determined based on the information recorded by the proxy node, and data loss does not occur.
In at least one embodiment of the invention, the method further comprises:
the processing unit 116 performs labeling processing on the code coverage rate in the code coverage rate dataset according to the preset configuration rule to obtain a label set, performs visualization processing on the label set to obtain a processing result, and the display unit 117 displays the processing result in real time.
Through the implementation mode, the label set is visually displayed, the code coverage rate of the target dynamic script is reflected through visualization of the label, and the complexity of directly visualizing the code coverage rate data set is simplified.
In addition, through the visualization processing, the real-time code coverage rate in each time period can be displayed in real time, so that the user can perform aging monitoring on the code coverage rate in the dynamic process of program execution.
Specifically, the processing unit 116 may perform labeling processing on the code coverage in the code coverage data set according to a calling scenario of each dynamic scenario, or perform labeling processing on the code coverage in the code coverage data set according to an operation type, which is not limited in the present invention.
Further, the processing unit 116 performs visualization processing on the tag set, and obtaining a processing result includes:
the processing unit 116 performs visualization processing on the tag set based on a preset visualization component to obtain a processing result.
Wherein the preset visualization components may include, but are not limited to: the system comprises a carousel map visualization component, a zebra pillar map visualization component, a multi-dimensional pie chart visualization component, a line chart visualization component, a map visualization component and the like.
According to the technical scheme, the Agent nodes can be arranged in the codes of the target dynamic script, when a calling request for the target dynamic script is received, the target dynamic script is executed, the code execution information of the target dynamic script is recorded through the Agent nodes, the code execution information is further obtained and analyzed, and a code coverage rate data set is obtained, so that the code coverage rate can be monitored in real time through the Agent nodes, and the problem of code coverage rate loss is solved.
Fig. 3 is a schematic structural diagram of an electronic device implementing a code coverage monitoring method according to a preferred embodiment of the present invention.
The electronic device 1 may comprise a memory 12, a processor 13 and a bus, and may further comprise a computer program, such as a code coverage monitoring program, stored in the memory 12 and executable on the processor 13.
It will be understood by those skilled in the art that the schematic diagram is merely an example of the electronic device 1, and does not constitute a limitation to the electronic device 1, the electronic device 1 may have a bus-type structure or a star-type structure, the electronic device 1 may further include more or less hardware or software than those shown in the figures, or different component arrangements, for example, the electronic device 1 may further include an input and output device, a network access device, and the like.
It should be noted that the electronic device 1 is only an example, and other existing or future electronic products, such as those that can be adapted to the present invention, should also be included in the scope of the present invention, and are included herein by reference.
The memory 12 includes at least one type of readable storage medium, which includes flash memory, removable hard disks, multimedia cards, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disks, optical disks, etc. The memory 12 may in some embodiments be an internal storage unit of the electronic device 1, for example a removable hard disk of the electronic device 1. The memory 12 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 provided on the electronic device 1. Further, the memory 12 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 12 may be used not only to store application software installed in the electronic device 1 and various types of data, such as codes of a code coverage monitoring program, etc., but also to temporarily store data that has been output or is to be output.
The processor 13 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 13 is a Control Unit (Control Unit) of the electronic device 1, integrates various components of the electronic device 1 by using various interfaces and line connections, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (for example, executing a code coverage monitoring program and the like) stored in the memory 12 and calling data stored in the memory 12.
The processor 13 executes an operating system of the electronic device 1 and various installed application programs. The processor 13 executes the application program to implement the steps in the various code coverage monitoring method embodiments described above, such as steps S10, S11, S12, S13 shown in fig. 1.
Alternatively, the processor 13, when executing the computer program, implements the functions of the modules/units in the above device embodiments, for example:
arranging proxy nodes in the code of the target dynamic script;
executing the target dynamic script when a calling request of the target dynamic script is received;
recording code execution information of the target dynamic script through the proxy node;
and acquiring and analyzing the code execution information to obtain a code coverage rate data set.
Illustratively, the computer program may be divided into one or more modules/units, which are stored in the memory 12 and executed by the processor 13 to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into an arrangement unit 110, an execution unit 111, a recording unit 112, a parsing unit 113, a compression unit 114, a storage unit 115, a processing unit 116, a display unit 117.
The integrated unit implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a computer device, or a network device) or a processor (processor) to execute parts of the methods according to the embodiments of the present invention.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. 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).
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. For ease of illustration, only one arrow is shown in FIG. 3, but this does not indicate only one bus or one type of bus. The bus is arranged to enable connection communication between the memory 12 and at least one processor 13 or the like.
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 13 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 (Keyboard)), optionally, a standard wired interface, a wireless interface, optionally, in some embodiments, the Display may be an L ED Display, a liquid crystal Display, a touch-sensitive liquid crystal Display, an O L ED (Organic light-Emitting Diode) touch-sensitive device, etc.
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.
Fig. 3 only shows the electronic device 1 with components 12-13, and it will be understood by a person skilled in the art that the structure shown in fig. 3 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.
With reference to fig. 1, the memory 12 of the electronic device 1 stores a plurality of instructions to implement a code coverage monitoring method, and the processor 13 executes the plurality of instructions to implement:
arranging proxy nodes in the code of the target dynamic script;
executing the target dynamic script when a calling request of the target dynamic script is received;
recording code execution information of the target dynamic script through the proxy node;
and acquiring and analyzing the code execution information to obtain a code coverage rate data set.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the instruction, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may 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.
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 of code coverage monitoring, the method comprising:
arranging proxy nodes in the code of the target dynamic script;
executing the target dynamic script when a calling request of the target dynamic script is received;
recording code execution information of the target dynamic script through the proxy node;
and acquiring and analyzing the code execution information to obtain a code coverage rate data set.
2. The code coverage monitoring method of claim 1, wherein the arranging of the proxy nodes in the code of the target dynamic scenario comprises:
determining the code types of all code segments of the target dynamic script;
matching each code type in a preset configuration rule;
and arranging the proxy nodes on the code sections corresponding to the matched code types.
3. The code coverage monitoring method of claim 2, wherein the determining code types of respective code segments of the target dynamic script comprises: :
determining respective code branches of the target dynamic script, and determining a code type of each sub-code segment of each code branch.
4. The code coverage monitoring method of claim 1, wherein the recording, by the proxy node, code execution information of the target dynamic scenario comprises:
monitoring an access layer log through the proxy node, and transmitting distribution topology information called by the access layer; or
Detecting the topology called by the application program through the proxy node, and transmitting data; or
Detecting a network logic topology based on an SNMP protocol through the agent node, and transmitting data; or
And detecting the physical port based on an interface flow analysis method through the proxy node, and transmitting data.
5. The code coverage monitoring method of claim 1, wherein after recording code execution information of the target dynamic scenario by the proxy node, the method further comprises:
performing data compression on the code execution information to obtain a compressed file set of the code execution information;
and storing the compressed file set to a database.
6. The code coverage monitoring method of claim 5, wherein the obtaining and parsing the code execution information to obtain a code coverage data set comprises:
acquiring the compressed file set from the database;
carrying out data decompression on the compressed file set to obtain the code execution information;
acquiring a test case identifier of the target dynamic script from the code execution information;
carrying out keyword matching on the calling request and the test case identification to obtain a matching result;
calculating a code coverage rate for each time period based on the matching result;
and integrating the calculated code coverage rate to obtain the code coverage rate data set.
7. The code coverage monitoring method of any one of claims 1 to 6, wherein the method further comprises:
performing label processing on the code coverage rate in the code coverage rate data set according to the preset configuration rule to obtain a label set;
performing visualization processing on the label set to obtain a processing result;
and displaying the processing result in real time.
8. A code coverage monitoring apparatus, the apparatus comprising:
an arrangement unit for arranging the proxy nodes in the code of the target dynamic scenario;
the execution unit is used for executing the target dynamic script when receiving a calling request of the target dynamic script;
the recording unit is used for recording the code execution information of the target dynamic script through the proxy node;
and the analysis unit is used for acquiring and analyzing the code execution information to obtain a code coverage rate data set.
9. An electronic device, characterized in that the electronic device comprises:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the code coverage monitoring method of any one of claims 1 to 7.
10. A computer-readable storage medium characterized by: the computer-readable storage medium has stored therein at least one instruction that is executable by a processor in an electronic device to implement the code coverage monitoring method of any one of claims 1 to 7.
CN202010216666.6A 2020-03-25 2020-03-25 Code coverage rate monitoring method and device, electronic equipment and storage medium Pending CN111400189A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010216666.6A CN111400189A (en) 2020-03-25 2020-03-25 Code coverage rate monitoring method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010216666.6A CN111400189A (en) 2020-03-25 2020-03-25 Code coverage rate monitoring method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111400189A true CN111400189A (en) 2020-07-10

Family

ID=71432826

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010216666.6A Pending CN111400189A (en) 2020-03-25 2020-03-25 Code coverage rate monitoring method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111400189A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111884882A (en) * 2020-07-29 2020-11-03 北京千丁互联科技有限公司 Monitoring coverage rate detection method and device
CN112015663A (en) * 2020-09-15 2020-12-01 平安银行股份有限公司 Test data recording method, device, equipment and medium
CN112363924A (en) * 2020-11-10 2021-02-12 中国平安人寿保险股份有限公司 Text coverage rate testing method based on directed graph and related equipment
CN112667245A (en) * 2021-01-15 2021-04-16 腾讯音乐娱乐科技(深圳)有限公司 Code processing method and device, electronic equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111884882A (en) * 2020-07-29 2020-11-03 北京千丁互联科技有限公司 Monitoring coverage rate detection method and device
CN112015663A (en) * 2020-09-15 2020-12-01 平安银行股份有限公司 Test data recording method, device, equipment and medium
CN112015663B (en) * 2020-09-15 2024-03-15 平安银行股份有限公司 Test data recording method, device, equipment and medium
CN112363924A (en) * 2020-11-10 2021-02-12 中国平安人寿保险股份有限公司 Text coverage rate testing method based on directed graph and related equipment
CN112363924B (en) * 2020-11-10 2023-09-29 中国平安人寿保险股份有限公司 Text coverage rate testing method based on directed graph and related equipment
CN112667245A (en) * 2021-01-15 2021-04-16 腾讯音乐娱乐科技(深圳)有限公司 Code processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111400189A (en) Code coverage rate monitoring method and device, electronic equipment and storage medium
CN109359007B (en) Method and system for processing error log, electronic device and storage medium
CN107992415B (en) Fault positioning and analyzing method of transaction system and related server
CN111614483A (en) Link monitoring method and device, storage medium and computer equipment
CN112015663B (en) Test data recording method, device, equipment and medium
CN111400130A (en) Task monitoring method and device, electronic equipment and storage medium
CN111754123B (en) Data monitoring method, device, computer equipment and storage medium
CN111950621A (en) Target data detection method, device, equipment and medium based on artificial intelligence
CN110674034A (en) Health examination method and device, electronic equipment and storage medium
CN112817814A (en) Abnormity monitoring method, system, storage medium and electronic device
CN112100239A (en) Portrait generation method and apparatus for vehicle detection device, server and readable storage medium
CN113949652B (en) User abnormal behavior detection method and device based on artificial intelligence and related equipment
CN115129753A (en) Data blood relationship analysis method and device, electronic equipment and storage medium
CN109800124B (en) CPU utilization monitoring method and device, electronic equipment and storage medium
CN112286762A (en) System information analysis method and device based on cloud environment, electronic equipment and medium
CN110825466B (en) Program jamming processing method and jamming processing device
CN109558300B (en) Whole cabinet alarm processing method and device, terminal and storage medium
CN114841165B (en) User data analysis and display method and device, electronic equipment and storage medium
CN115687406A (en) Sampling method, device and equipment of call chain data and storage medium
CN116205624A (en) Equipment operation management method based on digital twin and related products
CN115982787A (en) Industrial equipment exception handling method, system, device and storage medium
CN113434397B (en) Task system testing method and device, electronic equipment and storage medium
CN115344495A (en) Data analysis method and device for batch task test, computer equipment and medium
CN110348984B (en) Automatic credit card data input method and related equipment under different transaction channels
CN115022397A (en) Interface parameter simplifying method and device, electronic equipment and 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