CN116244204A - Program test coverage rate determining method, device and storage medium - Google Patents

Program test coverage rate determining method, device and storage medium Download PDF

Info

Publication number
CN116244204A
CN116244204A CN202310266611.XA CN202310266611A CN116244204A CN 116244204 A CN116244204 A CN 116244204A CN 202310266611 A CN202310266611 A CN 202310266611A CN 116244204 A CN116244204 A CN 116244204A
Authority
CN
China
Prior art keywords
calling
program
program set
determining
relation
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
CN202310266611.XA
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202310266611.XA priority Critical patent/CN116244204A/en
Publication of CN116244204A publication Critical patent/CN116244204A/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/3692Test management for test results analysis
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

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 application discloses a method and a device for determining program test coverage rate and a storage medium. Relates to the field of big data. The method comprises the following steps: acquiring a program set required by executing a target transaction, wherein the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs; generating a directed graph of a program set according to the M programs and the N calling relations, and obtaining a target directed graph; running the program set according to the N calling relations, determining the running state of the execution flow indicated by each calling relation in the running process of the program set, and determining the calling times of each calling relation according to the running state; and after the program set is completed to run, calculating the test coverage rate of the program set according to the calling times of each calling relation. According to the method and the device, the problem of low accuracy of a method for counting the program test coverage rate by adopting a mode of determining whether the program runs in the related art is solved.

Description

Program test coverage rate determining method, device and storage medium
Technical Field
The present invention relates to the field of big data, and in particular, to a method and apparatus for determining program test coverage rate, and a storage medium.
Background
When testing an application or a system, it is necessary to test the program test coverage in the application or system, i.e. whether the test is to test all programs and steps at this time. At present, when testing the program test coverage rate, the method used is as follows: firstly counting the total program quantity existing in the tested object, then counting the running program quantity, and finally calculating the test coverage rate by the method of (the running program quantity/the total program quantity) which is 100%.
However, the test coverage calculated by "(number of executed programs/total number of programs) ×100%", is not accurate, such as: program A calls program C and program B calls program C, and if only statistics of whether program C is triggered to run or not, the statistics accuracy can only stay at the program level, and whether the program C is triggered by the program A or the program B cannot be distinguished. That is, in the case where the program a successfully runs and successfully calls the program C, the program C also becomes functional to run, and the program C is not successfully called after the program B successfully runs, the test coverage obtained by the above method is 100%, but the procedure of calling the program C by the program B is not executed, and thus the test coverage is not 100%.
Aiming at the problem of low accuracy of a method for counting program test coverage rate by adopting a mode of determining whether a program runs in the related art, no effective solution is proposed at present.
Disclosure of Invention
The application provides a method and a device for determining program test coverage rate and a storage medium, so as to solve the problem of low accuracy of a method for counting program test coverage rate by adopting a mode of determining whether a program runs in the related technology.
According to one aspect of the present application, a method of determining program test coverage is provided. The method comprises the following steps: acquiring a program set required by executing a target transaction, wherein the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs; generating a directed graph of a program set according to the M programs and the N calling relations, and obtaining a target directed graph; running the program set according to the N calling relations, determining the running state of the execution flow indicated by each calling relation in the running process of the program set, and determining the calling times of each calling relation according to the running state; and after the program set is completed to run, calculating the test coverage rate of the program set according to the calling times of each calling relation.
Optionally, generating a directed graph of the program set according to the M programs and the N call relations, and obtaining the target directed graph includes: determining each program as a node to obtain M nodes; connecting M nodes through directed edges according to N calling relations to obtain an initial directed graph, wherein the indication direction of each directed edge is that a main calling node points to a called node; setting the initial call times of the call relation associated with each directed edge in the initial directed graph as a preset value to obtain a target directed graph.
Optionally, the initial operation number is associated with each directed edge in the target directed graph, determining an operation state of the execution flow indicated by each calling relation, and determining the calling number of each calling relation according to the operation state includes: monitoring the running state of the execution flow indicated by the N calling relations in the program set, and adding one to the initial calling times of the directed edges associated with the target calling relations in the target directed graph under the condition that the running of the execution flow indicated by the target calling relations is detected, so as to obtain an updated target directed graph until the program set finishes running, wherein the target calling relations are any calling relation in the N calling relations; and acquiring the current calling times of each directed edge in the updated target directed graph, and changing the calling times of the calling relationship corresponding to each directed edge into the current calling times.
Optionally, calculating the test coverage of the program set according to the call times of each call relation includes: acquiring preset calling times of each calling relation in a program set, and acquiring N preset calling times; adding N preset calling times to obtain preset total calling times; adding the current calling times of each directed edge in the target directed graph to obtain the current total calling times; dividing the current total calling times and the preset total calling times to obtain the test coverage rate.
Optionally, after calculating the test coverage of the program set according to the number of calls of each call relation, the method further comprises: judging whether the test coverage rate is a preset coverage rate or not; under the condition that the test coverage rate is the preset coverage rate, displaying the directed edges in the target directed graph through a first mode; under the condition that the test coverage rate is not the preset coverage rate, comparing the preset calling times of the same calling relation with the current calling times to obtain a plurality of comparison results; obtaining abnormal comparison results in the comparison results, displaying directed edges related to the calling relation indicated by the abnormal comparison results through a second pattern, and displaying the other directed edges in the target directed graph through a first pattern, wherein the abnormal comparison results represent that the preset calling times are different from the current calling times.
Optionally, before the program set completes running, the method further comprises: determining the initial time when the program set starts to run, and calculating the running time of the program set according to the current time and the initial time; judging whether the operation time exceeds a preset time; and under the condition that the running time exceeds the preset time, determining that the program set runs overtime, and sending out alarm information.
Optionally, before connecting the M nodes through the directed edges according to the N call relations to obtain the initial directed graph, the method further includes: sequentially identifying keywords in each calling relation to obtain N identification results; and determining the direction of the directed edge of each calling relation according to each recognition result, wherein the recognition results are used for indicating the calling relation and the called relation between the two programs.
According to another aspect of the present application, a program test coverage determination apparatus is provided. The device comprises: the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a program set required by executing a target transaction, the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs; the generating unit is used for generating a directed graph of the program set according to the M programs and the N calling relations to obtain a target directed graph; the first determining unit is used for operating the program set according to the N calling relations, determining the operation state of the execution flow indicated by each calling relation in the operation process of the program set, and determining the calling times of each calling relation according to the operation state; and the calculating unit is used for calculating the test coverage rate of the program set according to the calling times of each calling relation after the program set finishes running.
According to another aspect of the embodiment of the present invention, there is also provided a computer storage medium for storing a program, where the program is run to control a device in which the computer storage medium is located to execute a method for determining a program test coverage rate.
According to another aspect of embodiments of the present invention, there is also provided an electronic device including one or more processors and a memory; the memory has stored therein computer readable instructions for execution by the processor, wherein the computer readable instructions when executed perform a method of determining program test coverage.
Through the application, the following steps are adopted: acquiring a program set required by executing a target transaction, wherein the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs; generating a directed graph of a program set according to the M programs and the N calling relations, and obtaining a target directed graph; running the program set according to the N calling relations, determining the running state of the execution flow indicated by each calling relation in the running process of the program set, and determining the calling times of each calling relation according to the running state; and after the program set is completed to run, calculating the test coverage rate of the program set according to the calling times of each calling relation. The method for counting the program test coverage rate by adopting the mode of determining whether the program runs in the related art is low in accuracy. Generating a directed graph through the calling relation between the programs, recording the calling steps of the completed operation when the program set operates, determining the calling times of the calling relation which is completed, calculating the program test coverage rate according to the calling times of the calling relation, and further achieving the effect of accurately determining the program test coverage rate.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, illustrate and explain the application and are not to be construed as limiting the application. In the drawings:
FIG. 1 is a flow chart of a method of determining program test coverage provided in accordance with an embodiment of the present application;
FIG. 2 is a schematic illustration of an alternative directed graph provided in accordance with an embodiment of the present application;
FIG. 3 is a schematic diagram II of an alternative directed graph provided in accordance with an embodiment of the present application;
FIG. 4 is a schematic diagram III of an alternative directed graph provided in accordance with an embodiment of the present application;
FIG. 5 is a schematic diagram of a device for determining program test coverage provided according to an embodiment of the present application;
fig. 6 is a schematic diagram of an electronic device according to an embodiment of the present application.
Detailed Description
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the present application described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that, related information (including, but not limited to, user equipment information, user personal information, etc.) and data (including, but not limited to, data for presentation, analyzed data, etc.) related to the present disclosure are information and data authorized by a user or sufficiently authorized by each party. For example, an interface is provided between the system and the relevant user or institution, before acquiring the relevant information, the system needs to send an acquisition request to the user or institution through the interface, and acquire the relevant information after receiving the consent information fed back by the user or institution.
It should be noted that the method, the device and the storage medium for determining the program test coverage rate determined by the present disclosure may be used in the big data field, and may also be used in any field other than the big data field, and the method, the device and the application field of the storage medium for determining the program test coverage rate determined by the present disclosure are not limited.
According to an embodiment of the application, a method for determining program test coverage rate is provided.
Fig. 1 is a flowchart of a method for determining program test coverage according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
step S101, a program set required for executing a target transaction is acquired, where the program set includes M programs and N call relations, where each call relation indicates an execution flow between two programs.
Specifically, after determining a target transaction to be tested in a test process, a program set required for executing the transaction needs to be acquired, wherein the program set comprises M program source codes and calling relations among the M program source codes, so that the program set is operated according to the calling relations, and further execution of the target transaction is completed, wherein the calling relations among the M program source codes are M (M-1)/2 at most, but because calling relations do not exist between every two program source codes, N calling relations can exist among the M program source codes, and N is greater than or equal to M.
For example, the program collection may be stored in a physical library, which is a source library that stores host applications, containing the full amount of program source code P1, P2, P3, P4 … …. The programs have complicated calling relations, such as P1 calling P2, P2 calling P4, P4 calling P3, P3 calling P2 and the like, and the calling directions of the program source codes can be represented by using keywords such as CALL or LINK, so that the calling party program and the called party program can be determined according to the keywords.
It should be noted that, each call relationship is recorded and executed by a program source code, and each program source code may include a plurality of call relationships, for example, the program 1 may include two call relationships, that is, a call relationship a and a call relationship B, where the call relationship a may represent a call relationship between the program 1 and the program 2, and the call relationship B may represent a call relationship between the program 1 and the program 3, so that the number of N is greater than or equal to the number of M, and thus the call condition between the programs may be determined by the plurality of call relationships.
Step S102, generating a directed graph of a program set according to M programs and N calling relations, and obtaining a target directed graph.
Specifically, after the program set is obtained, each program in the program set can be used as a node, and the relation between the programs is embodied in the form of directed edges between the nodes, so that a target directed graph corresponding to the program set is obtained.
For example, in a program parsing module, there may be two main units: the host program source code analyzing unit scans and reads programs in the program set one by one from the entity program library, and analyzes source codes according to keywords between the programs, such as 'CALL' or 'LINK', and the like, so as to obtain the calling party program name and the called party program name; and the executable statement generating unit is responsible for converting the calling party program name and the called party program name obtained by the analysis of the host program source code analyzing unit into 'nodes' of the graph database, converting the program calling relation into 'directed edges' of the graph database and generating a target directed graph according to the 'nodes' and the 'directed edges'.
Step S103, running the program set according to the N calling relations, determining the running state of the execution flow indicated by each calling relation in the running process of the program set, and determining the calling times of each calling relation according to the running state.
Specifically, after determining the call relationships between the programs, the first program in the program set can be started to be executed according to the N call relationships and the directed graph, and the subsequent programs can be sequentially executed according to the call relationships, so that the execution of the test flow of the program set is completed.
Meanwhile, in the running process of the program set, a calling event of the program set in the executing process can be captured through the running data acquisition module, when the calling event among the programs occurs, the executing condition of the calling event is recorded, and the executing condition is recorded on the corresponding directed edge in the directed graph, so that after the execution of the test flow of the program set is completed, the executing times of the calling event of the corresponding calling relation are recorded on each directed edge.
Fig. 2 is a schematic diagram of an optional directed graph provided according to an embodiment of the present application, as shown in fig. 2, assuming that after execution of a test procedure of a program set is completed, a record of the number of times of execution of each directed edge in the directed graph is shown in fig. 2, where Link is a key corresponding to a call relationship, and the number in brackets identifies the number of times the call relationship is executed during testing, for example, the number of times of execution of P1 call P2 is 1, and the number of times of execution of P3 call P5 is 2, so that coverage may be determined according to the number of times of call relationships recorded in the directed graph by the operation data acquisition module.
Step S104, after the program set is completed to run, calculating the test coverage rate of the program set according to the calling times of each calling relation.
Specifically, after the directed graph and the call times shown in fig. 2 are obtained, the call times recorded in the test and the preset call times, in which the call relationship recorded in the source code should be executed, can be used to calculate, so as to obtain the coverage rate of the test.
The method for determining the program test coverage rate comprises the steps of obtaining a program set required by executing target transaction, wherein the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs; generating a directed graph of a program set according to the M programs and the N calling relations, and obtaining a target directed graph; running the program set according to the N calling relations, determining the running state of the execution flow indicated by each calling relation in the running process of the program set, and determining the calling times of each calling relation according to the running state; and after the program set is completed to run, calculating the test coverage rate of the program set according to the calling times of each calling relation. The method for counting the program test coverage rate by adopting the mode of determining whether the program runs in the related art is low in accuracy. Generating a directed graph through the calling relation between the programs, recording the calling steps of the completed operation when the program set operates, determining the calling times of the calling relation which is completed, calculating the program test coverage rate according to the calling times of the calling relation, and further achieving the effect of accurately determining the program test coverage rate.
Optionally, in the method for determining program test coverage provided in the embodiment of the present application, calculating the test coverage of the program set according to the number of calls of each call relation includes: acquiring preset calling times of each calling relation in a program set, and acquiring N preset calling times; adding N preset calling times to obtain preset total calling times; adding the current calling times of each directed edge in the target directed graph to obtain the current total calling times; dividing the current total calling times and the preset total calling times to obtain the test coverage rate.
Specifically, after the call times are obtained, the source code of the program set can be obtained from the entity program library, the call times preset for each call relation when the program set is executed are obtained from the source code, N preset call times are obtained, and the N preset call times are added to obtain the total preset call times.
Further, after the directed graph is obtained, the call times on each directed edge in the directed graph can be added to obtain the current total call times, and the current total call times are divided from the preset total call times to obtain the test coverage rate. Therefore, the coverage rate of the test can be accurately determined according to the calling condition of the calling relation.
Optionally, in the method for determining program test coverage provided in the embodiment of the present application, generating a directed graph of a program set according to M programs and N call relations, where obtaining a target directed graph includes: determining each program as a node to obtain M nodes; connecting M nodes through directed edges according to N calling relations to obtain an initial directed graph, wherein the indication direction of each directed edge is that a main calling node points to a called node; setting the initial call times of the call relation associated with each directed edge in the initial directed graph as a preset value to obtain a target directed graph.
Specifically, when the directed graph is generated, each program can be used as a node to obtain M nodes, and the nodes are connected according to the calling relationship to obtain multiple groups of nodes, wherein each group of nodes comprises two nodes and a directed edge between the two nodes.
Further, multiple groups of nodes are combined according to the same node to obtain a directed graph, and a preset value is assigned to each edge in the directed graph, wherein the preset value may be 0, so as to obtain a target directed graph, fig. 3 is a schematic diagram two of an optional directed graph provided according to an embodiment of the present application, and as shown in fig. 3, a value in a bracket after link of each directed edge may be set to 0, so as to perform assignment operation for each directed edge.
In order to accurately determine the pointing direction of the directed edge, optionally, in the method for determining the program test coverage rate provided in the embodiment of the present application, before connecting M nodes through the directed edge according to N call relationships, to obtain an initial directed graph, the method further includes: sequentially identifying keywords in each calling relation to obtain N identification results; and determining the direction of the directed edge of each calling relation according to each recognition result, wherein the recognition results are used for indicating the calling relation and the called relation between the two programs.
Specifically, before the target directed graph is generated, keywords in each CALL relationship, for example, the keywords such as CALL or LINK, can be identified, and after the keywords are determined, the direction of the directed edge is determined through the keywords, for example, if the keywords between P1 and P2 are LINK, the node P1 needs to be directed to the node P2 in the directed graph, and if the keywords between P1 and P2 are CALL, the node P2 needs to be directed to the node P1 in the directed graph, so that the accuracy of the direction of the directed edge is ensured.
Optionally, in the method for determining program test coverage provided in the embodiment of the present application, the initial operation number is associated with each directed edge in the target directed graph, and determining an operation state of an execution flow indicated by each calling relationship, and determining the calling number of each calling relationship according to the operation state includes: monitoring the running state of the execution flow indicated by the N calling relations in the program set, and adding one to the initial calling times of the directed edges associated with the target calling relations in the target directed graph under the condition that the running of the execution flow indicated by the target calling relations is detected, so as to obtain an updated target directed graph until the program set finishes running, wherein the target calling relations are any calling relation in the N calling relations; and acquiring the current calling times of each directed edge in the updated target directed graph, and changing the calling times of the calling relationship corresponding to each directed edge into the current calling times.
Specifically, when the program set is operated, the operation state of the program set can be monitored in real time, and when a certain calling relation is detected to be executed and called, the calling times are increased by one on the directed edge corresponding to the calling relation in the target directed graph, so that the record of the calling times is completed.
For example, fig. 4 is a schematic diagram III of an optional directed graph provided according to an embodiment of the present application, on the basis of fig. 3, when detecting that a step of calling P3 by P1 is performed in a program set, link (0) on a directed edge between P1 and P3 is updated to Link (1), so that the directed graph in fig. 3 is updated to the directed graph in fig. 4, and the directed graph is changed along with the execution of the program set according to the update procedure, so that after the execution of the program set is completed, an updated target directed graph is obtained, and program coverage is calculated according to the number of calls on the directed edge in the target directed graph that is updated currently.
Optionally, in the method for determining program test coverage provided in the embodiment of the present application, after calculating the test coverage of the program set according to the number of calls of each call relation, the method further includes: judging whether the test coverage rate is a preset coverage rate or not; under the condition that the test coverage rate is the preset coverage rate, displaying the directed edges in the target directed graph through a first mode; under the condition that the test coverage rate is not the preset coverage rate, comparing the preset calling times of the same calling relation with the current calling times to obtain a plurality of comparison results; obtaining abnormal comparison results in the comparison results, displaying directed edges related to the calling relation indicated by the abnormal comparison results through a second pattern, and displaying the other directed edges in the target directed graph through a first pattern, wherein the abnormal comparison results represent that the preset calling times are different from the current calling times.
Specifically, after the test coverage rate is calculated, and the test coverage rate is obtained, if the test coverage rate is the preset coverage rate, it is characterized that the test coverage rate is not abnormal, then all the directed edges can be displayed through a first mode, so that the indication that no abnormality exists, and if the test coverage rate is not the preset coverage rate, it is characterized that no running calling operation exists in the test, at this time, the calling times corresponding to each calling relation need to be obtained from the source code, the actual calling times detected in the test are obtained from the directed graph, and the actual calling times of each directed edge are compared with the calling times in the source code, so that the determination of which directed edge has the abnormality at all is achieved, and the effect of locating the abnormal occurrence position is achieved. And the directed edges corresponding to the calling relation of the abnormality are displayed in a second style, so that the effect of displaying the abnormal directed edges is achieved.
Optionally, in the method for determining program test coverage provided in the embodiment of the present application, before the program set completes running, the method further includes: determining the initial time when the program set starts to run, and calculating the running time of the program set according to the current time and the initial time; judging whether the operation time exceeds a preset time; and under the condition that the running time exceeds the preset time, determining that the program set runs overtime, and sending out alarm information.
Specifically, when the program set is running, there may be abnormal running conditions, so that the running time of the program set needs to be determined in real time, the running time is compared with a preset time, and when the running time exceeds the preset time, the running time of the program set is represented to be overtime, the running needs to be restarted, and further, a worker can be prompted to process in time by sending out alarm information.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
The embodiment of the application also provides a device for determining the program test coverage rate, and it should be noted that the device for determining the program test coverage rate of the embodiment of the application can be used for executing the method for determining the program test coverage rate provided by the embodiment of the application. The following describes a device for determining program test coverage provided in the embodiment of the present application.
Fig. 5 is a schematic diagram of a determining apparatus for program test coverage provided according to an embodiment of the present application. As shown in fig. 5, the apparatus includes: an acquisition unit 51, a generation unit 52, a first determination unit 53, a calculation unit 54.
The acquiring unit 51 is configured to acquire a program set required for executing the target transaction, where the program set includes M programs and N call relations, where each call relation indicates an execution flow between two programs.
The generating unit 52 is configured to generate a directed graph of the program set according to the M programs and the N call relations, and obtain a target directed graph.
The first determining unit 53 is configured to run the program set according to the N call relationships, determine an running state of an execution flow indicated by each call relationship during a running process of the program set, and determine a number of times of call of each call relationship according to the running state.
And the calculating unit 54 is used for calculating the test coverage rate of the program set according to the calling times of each calling relation after the program set finishes running.
The program test coverage rate determining device provided by the embodiment of the application obtains a program set required by executing a target transaction through the obtaining unit 51, wherein the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs; the generating unit 52 generates a directed graph of the program set according to the M programs and the N call relations, and obtains a target directed graph; the first determining unit 53 operates the program set according to the N call relations, determines an operation state of the execution flow indicated by each call relation in an operation process of the program set, and determines the number of times of call of each call relation according to the operation state; after the program set is completed to run, the calculation unit 54 calculates the test coverage of the program set according to the number of calls of each call relation. The method for counting the program test coverage rate by adopting the mode of determining whether the program runs in the related art is low in accuracy. Generating a directed graph through the calling relation between the programs, recording the calling steps of the completed operation when the program set operates, determining the calling times of the calling relation which is completed, calculating the program test coverage rate according to the calling times of the calling relation, and further achieving the effect of accurately determining the program test coverage rate.
Alternatively, in the determination apparatus of program test coverage provided in the embodiment of the present application, the generating unit 52 includes: the determining module is used for determining each program as a node to obtain M nodes; the connection module is used for connecting M nodes through directed edges according to N calling relations to obtain an initial directed graph, wherein the indication direction of each directed edge is that a main calling node points to a called node; the setting module is used for setting the initial call times of the call relation associated with each directed edge in the initial directed graph as a preset value to obtain the target directed graph.
Optionally, in the determining apparatus for program test coverage provided in the embodiment of the present application, each directed edge in the target directed graph is associated with an initial number of runs, and the first determining unit 53 includes: the monitoring module is used for monitoring the running states of the execution flows indicated by the N calling relations in the program set, and adding one to the initial calling times of the directed edges associated with the target calling relations in the target directed graph under the condition that the execution flows indicated by the target calling relations are detected to run, so as to obtain an updated target directed graph until the program set finishes running, wherein the target calling relations are any calling relation in the N calling relations; the first acquisition module is used for acquiring the current calling times of each directed edge in the updated target directed graph and changing the calling times of the calling relationship corresponding to each directed edge into the current calling times.
Optionally, in the apparatus for determining program test coverage provided in the embodiment of the present application, the calculating unit 54 includes: the second acquisition module is used for acquiring preset calling times of each calling relation in the program set to obtain N preset calling times; the first calculation module is used for adding the N preset calling times to obtain preset total calling times; the second calculation module is used for adding the current calling times of each directed edge in the target directed graph to obtain the current total calling times; and the third calculation module is used for dividing the current total calling times and the preset total calling times to obtain the test coverage rate.
Optionally, in the apparatus for determining program test coverage provided in the embodiment of the present application, the apparatus further includes: the first judging unit is used for judging whether the test coverage rate is a preset coverage rate or not; the first display unit is used for displaying the directed edges in the target directed graph through a first mode under the condition that the test coverage rate is a preset coverage rate; the comparison unit is used for comparing the preset calling times of the same calling relation with the current calling times under the condition that the test coverage rate is not the preset coverage rate, so as to obtain a plurality of comparison results; the second display unit is used for acquiring an abnormal comparison result in the comparison results, displaying the directed edges related to the calling relation indicated by the abnormal comparison result through a second style, and displaying the other directed edges in the target directed graph through a first style, wherein the abnormal comparison result represents that the preset calling times are different from the current calling times.
Optionally, in the apparatus for determining program test coverage provided in the embodiment of the present application, the apparatus further includes: the second determining unit is used for determining the initial time when the program set starts to run and calculating the running time of the program set according to the current time and the initial time; the second judging unit is used for judging whether the operation time length exceeds the preset time length; and the third determining unit is used for determining that the program set runs overtime and sending out alarm information under the condition that the running time exceeds the preset time.
Optionally, in the apparatus for determining program test coverage provided in the embodiment of the present application, the apparatus further includes: the recognition unit is used for sequentially recognizing the keywords in each calling relation to obtain N recognition results; and a fourth determining unit configured to determine, according to each recognition result, a direction of the directed edge of each calling relationship, where the recognition result is used to indicate the calling relationship and the called relationship between the two programs.
The determination device of the program test coverage includes a processor and a memory, the acquisition unit 51, the generation unit 52, the first determination unit 53, the calculation unit 54, and the like are stored as program units in the memory, and the processor executes the program units stored in the memory to realize the corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one kernel, and the problem of low accuracy of a method for counting the program test coverage rate by adopting a mode of determining whether the program runs in the related technology is solved by adjusting kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
The embodiment of the invention provides a computer readable storage medium, on which a program is stored, which when executed by a processor, implements a method for determining the program test coverage.
The embodiment of the invention provides a processor which is used for running a program, wherein the program runs to execute a method for determining the program test coverage rate.
As shown in fig. 6, an embodiment of the present invention provides an electronic device, the electronic device 60 includes a processor, a memory, and a program stored on the memory and executable on the processor, and the processor implements the following steps when executing the program: acquiring a program set required by executing a target transaction, wherein the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs; generating a directed graph of a program set according to the M programs and the N calling relations, and obtaining a target directed graph; running the program set according to the N calling relations, determining the running state of the execution flow indicated by each calling relation in the running process of the program set, and determining the calling times of each calling relation according to the running state; and after the program set is completed to run, calculating the test coverage rate of the program set according to the calling times of each calling relation. The device herein may be a server, PC, PAD, cell phone, etc.
The present application also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: acquiring a program set required by executing a target transaction, wherein the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs; generating a directed graph of a program set according to the M programs and the N calling relations, and obtaining a target directed graph; running the program set according to the N calling relations, determining the running state of the execution flow indicated by each calling relation in the running process of the program set, and determining the calling times of each calling relation according to the running state; and after the program set is completed to run, calculating the test coverage rate of the program set according to the calling times of each calling relation.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (10)

1. A method for determining program test coverage, comprising:
acquiring a program set required by executing target transaction, wherein the program set comprises M programs and N calling relations, each calling relation indicates an execution flow between two programs, M is smaller than or equal to N, and M, N is a positive integer;
Generating a directed graph of the program set according to the M programs and the N calling relations, and obtaining a target directed graph;
operating the program set according to the N calling relations, determining the operation state of an execution flow indicated by each calling relation in the operation process of the program set, and determining the calling times of each calling relation according to the operation state;
and after the program set finishes running, calculating the test coverage rate of the program set according to the calling times of each calling relation.
2. The method of claim 1, wherein generating a directed graph of the set of programs from the M programs and the N call relationships, the obtaining a target directed graph comprising:
determining each program as a node to obtain M nodes;
connecting the M nodes through directed edges according to the N calling relations to obtain an initial directed graph, wherein the indication direction of each directed edge is that a main calling node points to a called node;
setting the initial call times of the call relation associated with each directed edge in the initial directed graph as a preset value to obtain the target directed graph.
3. The method of claim 1, wherein each directed edge in the target directed graph is associated with an initial number of runs, wherein determining the run state of the execution flow indicated by each call relationship, and wherein determining the number of calls for each call relationship based on the run state comprises:
Monitoring the running state of the execution flow indicated by the N calling relations in the program set, and adding one to the initial calling times of the directed edges associated with the target calling relations in the target directed graph under the condition that the running of the execution flow indicated by the target calling relations is detected, so as to obtain an updated target directed graph until the program set finishes running, wherein the target calling relations are any one calling relation of the N calling relations;
and acquiring the current calling times of each directed edge in the updated target directed graph, and changing the calling times of the calling relationship corresponding to each directed edge into the current calling times.
4. The method of claim 3, wherein calculating the test coverage of the program set based on the number of calls per call relationship comprises:
acquiring preset calling times of each calling relation in the program set to obtain N preset calling times;
adding the N preset calling times to obtain preset total calling times;
adding the current calling times of each directed edge in the target directed graph to obtain the current total calling times;
Dividing the current total calling times with the preset total calling times to obtain the test coverage rate.
5. The method of claim 4, wherein after calculating the test coverage of the program set based on the number of calls per call relationship, the method further comprises:
judging whether the test coverage rate is a preset coverage rate or not;
displaying the directed edges in the target directed graph in a first mode under the condition that the test coverage rate is the preset coverage rate;
comparing the preset calling times of the same calling relation with the current calling times under the condition that the test coverage rate is not the preset coverage rate, so as to obtain a plurality of comparison results;
obtaining an abnormal comparison result in the comparison results, displaying the related directed edges of the calling relation indicated by the abnormal comparison result through a second pattern, and displaying the rest directed edges in the target directed graph through the first pattern, wherein the abnormal comparison result represents that the preset calling times are different from the current calling times.
6. The method of claim 1, wherein before the program set completes execution, the method further comprises:
Determining an initial time when the program set starts to run, and calculating the running time of the program set according to the current time and the initial time;
judging whether the operation duration exceeds a preset duration;
and under the condition that the running time exceeds the preset time, determining that the program set runs overtime, and sending out alarm information.
7. The method of claim 2, wherein before connecting the M nodes by directed edges according to the N call relations, the method further comprises:
sequentially identifying keywords in each calling relation to obtain N identification results;
and determining the direction of the directed edge of each calling relation according to each recognition result, wherein the recognition results are used for indicating the calling relation and the called relation between the two programs.
8. A program test coverage rate determining apparatus, comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a program set required by executing target transaction, the program set comprises M programs and N calling relations, and each calling relation indicates an execution flow between two programs;
The generating unit is used for generating a directed graph of the program set according to the M programs and the N calling relations to obtain a target directed graph;
the first determining unit is used for operating the program set according to the N calling relations, determining the operation state of the execution flow indicated by each calling relation in the operation process of the program set, and determining the calling times of each calling relation according to the operation state;
and the calculating unit is used for calculating the test coverage rate of the program set according to the calling times of each calling relation after the program set finishes running.
9. A computer storage medium for storing a program, wherein the program when run controls a device in which the computer storage medium is located to execute the program test coverage determination method according to any one of claims 1 to 7.
10. An electronic device comprising one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of determining program test coverage of any of claims 1-7.
CN202310266611.XA 2023-03-14 2023-03-14 Program test coverage rate determining method, device and storage medium Pending CN116244204A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310266611.XA CN116244204A (en) 2023-03-14 2023-03-14 Program test coverage rate determining method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310266611.XA CN116244204A (en) 2023-03-14 2023-03-14 Program test coverage rate determining method, device and storage medium

Publications (1)

Publication Number Publication Date
CN116244204A true CN116244204A (en) 2023-06-09

Family

ID=86629562

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310266611.XA Pending CN116244204A (en) 2023-03-14 2023-03-14 Program test coverage rate determining method, device and storage medium

Country Status (1)

Country Link
CN (1) CN116244204A (en)

Similar Documents

Publication Publication Date Title
US8719791B1 (en) Display of aggregated stack traces in a source code viewer
CN110601900B (en) Network fault early warning method and device
TW201941058A (en) Anomaly detection method and device
CN107967209B (en) Method for detecting error in front-end webpage code, detection equipment and server
KR102097953B1 (en) Failure risk index estimation device and failure risk index estimation method
CN106445938B (en) Data detection method and device
CN110688063A (en) Method, device, equipment and medium for screening Raid slow disc
CN110188793B (en) Data anomaly analysis method and device
CN115292163A (en) Application program detection method and device and computer readable storage medium
JP2018060332A (en) Incident analysis program, incident analysis method, information processing device, service specification program, service specification method and service specification device
CN110134583B (en) Software testing and data processing method and device
EP3011454A1 (en) Generating a fingerprint representing a response of an application to a simulation of a fault of an external service
CN108763092B (en) Code defect detection method and device based on cross validation
CN111444093A (en) Method and device for determining quality of project development process and computer equipment
CN113535538A (en) Application full-link automatic testing method and device, electronic equipment and storage medium
CN116244204A (en) Program test coverage rate determining method, device and storage medium
CN115757138A (en) Method and device for determining script abnormal reason, storage medium and electronic equipment
CN112965791B (en) Timing task detection method, device, equipment and storage medium
CN114490413A (en) Test data preparation method and device, storage medium and electronic equipment
CN113986739A (en) Monitoring method and device for website memory leakage, storage medium and processor
CN112882854B (en) Method and device for processing request exception
CN114153712A (en) Exception handling method, device, equipment and storage medium
CN114428744A (en) Application program starting time monitoring method, monitoring server and system
CN112905449A (en) Target test method, device, equipment and storage medium
US10437710B2 (en) Code coverage testing utilizing test-to-file maps

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