CN115794621A - Code coverage test method, device, equipment and storage medium - Google Patents

Code coverage test method, device, equipment and storage medium Download PDF

Info

Publication number
CN115794621A
CN115794621A CN202211430994.1A CN202211430994A CN115794621A CN 115794621 A CN115794621 A CN 115794621A CN 202211430994 A CN202211430994 A CN 202211430994A CN 115794621 A CN115794621 A CN 115794621A
Authority
CN
China
Prior art keywords
code file
code
coverage
database
target
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
CN202211430994.1A
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.)
Pingan Payment Technology Service Co Ltd
Original Assignee
Pingan Payment Technology Service 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 Pingan Payment Technology Service Co Ltd filed Critical Pingan Payment Technology Service Co Ltd
Priority to CN202211430994.1A priority Critical patent/CN115794621A/en
Publication of CN115794621A publication Critical patent/CN115794621A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the field of testing in the field of financial science and technology, and provides a code coverage testing method, device, equipment and storage medium. The method includes the steps of marking an initial front-end code file based on a preset agent identification code to obtain a target front-end code file, locating a target back-end code file and a target database operation code file, conducting coverage test on the target front-end code file and the target back-end code file to obtain a front-end coverage result and a back-end coverage result, generating a database coverage result based on the target database operation code file and a basic code file, conducting full-link display, and improving coverage test efficiency. In addition, the invention also relates to a block chain technology, and the front end coverage result, the back end coverage result and the database coverage result can be stored in a block chain.

Description

Code coverage test method, device, equipment and storage medium
Technical Field
The present invention relates to the field of test technologies, and in particular, to a code coverage test method, apparatus, device, and storage medium.
Background
In the software testing work in the field of financial science and technology, code coverage testing is performed on codes of tested software objects, and the method is an important mode for software testing analysis. Because the environments in which the client software code, the server software code and the database operation code tend to run are different, for example: the front-end software code runs on a mobile phone end, the server-end software code runs on a server end, and the database operation code runs on middleware software such as redis, so that the client-end software code, the server-end software code and the database operation code in the same service scene cannot be directly subjected to coverage test, and the code coverage test efficiency is reduced.
Disclosure of Invention
In view of the above, it is necessary to provide a code coverage test method, device, apparatus and storage medium, which can solve the technical problems that the coverage test cannot be directly performed on the client software code, the server software code and the database operation code in the same service scenario, and the efficiency of the code coverage test is low.
In one aspect, the present invention provides a code coverage testing method, where the code coverage testing method includes:
acquiring an initial front-end code file of a test scene request;
identifying the initial front-end code file based on a preset agent identification code to obtain a target front-end code file;
running the target front-end code file, and positioning a target back-end code file and a target database operation code file based on the preset agent identification code, wherein the target database operation code file refers to a code file of a scene database;
performing a coverage test on the target front-end code file to obtain a front-end coverage result, and performing a coverage test on the target back-end code file to obtain a back-end coverage result;
generating a database coverage result based on the target database operation code file and the basic code file of the scene database;
and carrying out full link display on the front end coverage result, the rear end coverage result and the database coverage result.
According to the preferred embodiment of the present invention, the obtaining of the initial front-end code file of the request test scenario includes:
acquiring a request data packet;
extracting a scene identifier from the request data packet based on a preset scene field;
matching the scene identification with the scene identification code of the test-requested scene;
and if the scene identification is successfully matched with the scene identification code, determining the request data packet as the initial front-end code file.
According to a preferred embodiment of the present invention, the identifying the initial front-end code file based on the preset agent identification code to obtain the target front-end code file includes:
creating an agent field based on a preset agent identification code;
positioning a head code file corresponding to a preset head field from the initial front-end code file;
and writing the agent field and the preset agent identification code into the head code file to obtain a target front-end code file corresponding to the initial front-end code file.
According to a preferred embodiment of the present invention, the performing a coverage test on the target front-end code file to obtain a front-end coverage result includes:
acquiring tool code information of a preset tool;
calling an off-line command and a timing command, and writing the tool code information into the target front-end code file to obtain an instrumentation front-end code file;
and operating the instrumentation front end code file to obtain the front end coverage result.
According to a preferred embodiment of the present invention, the performing a coverage test on the target backend code file to obtain a backend coverage result includes:
identifying a Java virtual machine where the target back-end code file is located;
calling a monitoring code from the Java virtual machine, and loading the monitoring code into the target back-end code file to obtain an instrumented back-end code file;
and compiling, packaging and running the instrumentation post-end code file to obtain the post-end coverage result.
According to a preferred embodiment of the present invention, the generating a database overlay result based on the target database operation code file and the basic code file of the scene database includes:
constructing a first database syntax tree based on the target database operation code file, and constructing a second database syntax tree based on the basic code file;
comparing the first database syntax tree with the second database syntax tree to obtain an incremental object;
acquiring a calling object and a called object of the incremental object from the first database syntax tree;
and respectively acquiring information corresponding to the increment object, the calling object and the called object from the target database operation code file as the database coverage result.
According to the preferred embodiment of the present invention, the performing the full link display on the front-end overlay result, the back-end overlay result, and the database overlay result includes:
acquiring the page size of a visual page;
performing page division on the visual page based on the page size, the front end coverage result, the rear end coverage result and the database coverage result to obtain a front end display area, a rear end display area and a database display area;
displaying the front-end coverage result to the front-end display area based on the code amount and the code execution sequence of the front-end coverage result;
displaying the back-end coverage result to the back-end display area based on the code amount and the code execution sequence of the back-end coverage result;
and displaying the database coverage result to the database display area based on the code amount and the code execution sequence of the database coverage result.
In another aspect, the present invention further provides a code coverage testing apparatus, including:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring an initial front end code file of a test scene;
the identification unit is used for identifying the initial front-end code file based on a preset proxy identification code to obtain a target front-end code file;
the positioning unit is used for operating the target front-end code file and positioning a target back-end code file and a target database operation code file based on the preset agent identification code, wherein the target database operation code file is a code file of a scene database;
the test unit is used for performing coverage test on the target front-end code file to obtain a front-end coverage result and performing coverage test on the target back-end code file to obtain a back-end coverage result;
a generating unit, configured to generate a database coverage result based on the target database operation code file and a basic code file of the scene database;
and the display unit is used for carrying out full-link display on the front-end coverage result, the rear-end coverage result and the database coverage result.
In another aspect, the present invention further provides an electronic device, including:
a memory storing computer readable instructions; and
a processor executing computer readable instructions stored in the memory to implement the code coverage testing method.
In another aspect, the present invention also provides a computer-readable storage medium, in which computer-readable instructions are stored, and the computer-readable instructions are executed by a processor in an electronic device to implement the code coverage testing method.
According to the technical scheme, the initial front-end code file is identified based on the preset agent identification code, the target front-end code file, the target back-end code file and the target database operation code file of the same test request scene can be associated, so that codes of different operation environments in the same service scene can be obtained through the preset agent identification code, further, the target front-end code file, the target back-end code file and the target database operation code file are subjected to coverage test, and the target front-end code file, the target back-end code file and the target database operation code file do not comprise redundant interference codes, so that the accuracy of the coverage test of the test request scene can be improved, and meanwhile, the efficiency of the coverage test can be improved because the codes of different operation environments in the same service scene can be directly subjected to the coverage test. According to the method and the device, the front-end covering result, the rear-end covering result and the database covering result are subjected to full link display, so that the intuitiveness of the scene covering result of the request test scene is improved. This application is applicable to finance science and technology field, through this application, can improve finance science and technology field's relevant staff to the code efficiency of testing of different operational environment under the same business scene to promote the development in wisdom city.
Drawings
FIG. 1 is a flow chart of a preferred embodiment of the code coverage test method of the present invention.
FIG. 2 is a diagram of a first database syntax tree in the present invention.
FIG. 3 is a diagram of a second database syntax tree in the present invention.
FIG. 4 is a functional block diagram of a preferred embodiment of the code coverage testing apparatus of the present invention.
FIG. 5 is a schematic structural diagram of an electronic device implementing a code coverage testing method according to a preferred embodiment of the 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 showing a code coverage test 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 testing method can acquire and process related data based on an artificial intelligence technology. Among them, artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The code coverage test method is applied to one or more electronic devices, which are devices capable of automatically performing numerical calculation and/or information processing according to computer readable instructions set or stored in advance, and the hardware thereof 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 console, an Internet Protocol Television (IPTV), a smart wearable device, and the like.
The electronic device may include a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network electronic device, an electronic device group consisting of a plurality of network electronic devices, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network electronic devices.
The network in which 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.
The code coverage testing method is applied to the field of financial science and technology.
101, obtaining an initial front-end code file of a request test scene.
In at least one embodiment of the present invention, the request test scenario may be a business scenario in the field of financial technology, for example, the request test scenario may be a business scenario corresponding to the sales system a.
The initial front-end code file refers to a request data packet related to the request test scenario, and the file form of the initial front-end code file is usually an HTTP file.
In at least one embodiment of the present invention, the obtaining, by the electronic device, the initial front-end code file of the test scenario includes:
acquiring a request data packet;
extracting a scene identifier from the request data packet based on a preset scene field;
matching the scene identification with the scene identification code of the test-requested scene;
and if the scene identification is successfully matched with the scene identification code, determining the request data packet as the initial front-end code file.
Wherein, the request data packet generally refers to an HTTP file generated by the electronic device. When a user searches a certain service requirement in a preset browser, the electronic equipment generates a corresponding request data packet.
The preset scene field may be a preset field, for example, the preset scene field may be changjing.
The scene identification is obtained by analyzing the request data packet based on the preset scene field.
The scene identification code is used for uniquely identifying the request test scene.
The scene identification can be accurately extracted from the request data packet through the preset scene field, and further, the initial front-end code file can be accurately screened out from the acquired request data packet based on the matching of the scene identification code of the request test scene with the scene identification through the unique identification.
And 102, identifying the initial front-end code file based on a preset agent identification code to obtain a target front-end code file.
In at least one embodiment of the present invention, the preset agent identification code refers to an identification code corresponding to a pre-configured agent, for example, the preset agent identification code may be TranseID, and through the preset agent identification code, a front-end code, a back-end code, and an SQL (Structured Query Language) code in the field of financial technology may be associated.
The target front-end code file is a file obtained after the preset agent identification code is written into a head code file in the initial front-end code file. The running environment of the target front-end code file is usually a client, such as a mobile phone.
In at least one embodiment of the present invention, the identifying, by the electronic device, the initial front-end code file based on a preset agent identification code, and obtaining a target front-end code file includes:
creating an agent field based on a preset agent identification code;
positioning a head code file corresponding to a preset head field from the initial front-end code file;
and writing the agent field and the preset agent identification code into the head code file to obtain a target front-end code file corresponding to the initial front-end code file.
The proxy field is used for representing field information to which the preset proxy identification code belongs.
The preset Header field is used to indicate a Header file in the request packet, and may be, for example, a Header.
The head code file can be accurately positioned from the initial front end code file through the preset head field, and furthermore, the target front end code file can be conveniently associated with the rear end code and the SQL code in the same test request scene through writing the agent field and the preset agent identification code into the head code file.
And 103, operating the target front-end code file, and positioning a target back-end code file and a target database operation code file based on the preset proxy identification code, wherein the target database operation code file refers to a code file of a scene database.
In at least one embodiment of the present invention, the target back-end code file refers to a back-end code in the same request test scenario as the target front-end code file. The operating environment of the target back-end code file is typically a server.
The target database operation code file refers to SQL codes which are in the same request test scene with the target front-end code file. The runtime environment of the target database operation code file is typically a database.
The scene database refers to an operation database for operating the target database operation code file. The scenario database stores the service data of the requested test scenario, and may further include data of other service scenarios, where the service data may be financial data in the field of financial technology.
In at least one embodiment of the present invention, after the electronic device runs the target front-end code file, the back-end code and the SQL code that are in the same request test scenario as the target front-end code file are updated, and a target back-end code file corresponding to the back-end code and a target database operation code file corresponding to the SQL code are obtained.
In at least one embodiment of the present invention, the electronic device locating the target backend code file and the target database operation code file based on the preset agent identification code includes:
capturing a response file from a server in communication with the electronic equipment, and determining the response file containing the preset agent identification code as the target back-end code file;
and acquiring an operation file from the scene database, and determining the operation file containing the preset agent identification code as the target database operation code file.
The response file is generated after the server responds based on the request data packet of the electronic device.
The operation file is a file for recording database operations in the scene database.
And 104, performing coverage test on the target front-end code file to obtain a front-end coverage result, and performing coverage test on the target back-end code file to obtain a back-end coverage result.
In at least one embodiment of the present invention, the front-end coverage result refers to code information of the target front-end code file for completing the test.
The back-end coverage result refers to code information for completing the test in the target back-end code file.
In at least one embodiment of the present invention, the performing, by the electronic device, a coverage test on the target front-end code file, and obtaining a front-end coverage result includes:
acquiring tool code information of a preset tool;
calling an off-line command and a timing command, and writing the tool code information into the target front-end code file to obtain an instrumentation front-end code file;
and operating the instrumentation front-end code file to obtain the front-end coverage result.
Wherein the preset tool may be a tool for coverage testing, for example, the preset tool may be an Istanbul tool.
The tool code information refers to information used for monitoring code execution in the preset tool.
The off-line command refers to a command for transferring the program to a background for execution, and the timing command refers to a command for executing the program at regular time.
The tool code information is acquired through the preset tool, the acquisition efficiency of the tool code information is improved because the tool code information does not need to be created, furthermore, the tool code information can be written into the target front end code file in a timing mode in an off-line state through calling the off-line command and the timing command, the generation efficiency of the pile inserting front end code file can be improved on the premise that the equipment resources of the electronic equipment are not occupied, and the generation efficiency of the front end coverage result can be improved through directly operating the pile inserting front end code file.
In at least one embodiment of the present invention, the performing, by the electronic device, a coverage test on the target backend code file, and obtaining a backend coverage result includes:
identifying a Java virtual machine where the target back-end code file is located;
calling a monitoring code from the Java virtual machine, and loading the monitoring code into the target back-end code file to obtain an instrumentation back-end code file;
and compiling, packaging and running the instrumentation post-end code file to obtain the post-end coverage result.
The Java virtual machine is an abstract computer simulating various computer functions, and the target back-end code file is stored in the Java virtual machine.
The generation efficiency of the instrumentation back-end code file can be improved by calling the monitoring code of the Java virtual machine and writing the monitoring code into the target back-end code file, and the generation convenience of the back-end coverage result is improved by compiling, packaging and running the instrumentation back-end code file.
105, generating a database coverage result based on the target database operation code file and the basic code file of the scene database.
In at least one embodiment of the present invention, the basic code file refers to code information corresponding to the scene database when the scene database is initialized.
And the database coverage result refers to code information for completing the test in the operation code file of the target database.
In at least one embodiment of the present invention, the generating, by the electronic device, a database coverage result based on the target database operation code file and the base code file of the scene database includes:
constructing a first database syntax tree based on the target database operation code file, and constructing a second database syntax tree based on the basic code file;
comparing the first database syntax tree with the second database syntax tree to obtain an incremental object;
acquiring a calling object and a called object of the incremental object from the first database syntax tree;
and respectively acquiring information corresponding to the incremental object, the calling object and the called object from the target database operation code file as a database coverage result.
The first database syntax tree represents the syntax structure of the target database operation code file in a tree form, and each node in the first database syntax tree represents one structure of the target database operation code file. As shown in fig. 2, fig. 2 is a schematic diagram of a first database syntax tree in the present invention. As can be seen from FIG. 2, the structure objects included in FIG. 2 are SELECT, A, B, C, D, E, F, G, X, Y, Z, K, L.
The second database syntax tree represents the syntax structure of the base code file in a tree form, and each node in the second database syntax tree represents a structure of the base code file. As shown in FIG. 3, FIG. 3 is a diagram of a first database syntax tree in the present invention. As can be seen from FIG. 3, the structure objects included in FIG. 3 are SELECT, A, B, C, E, F, G, X, Y.
The incremental object is a structural object added to the first database syntax tree compared to the second database syntax tree. In connection with the examples of fig. 2-3, the delta objects are D, Z, K, L.
The calling object refers to a structure object called by the increment object in the first database syntax tree. In the example shown in fig. 2 to 3, the calling object of the delta object D is K, and the calling object of the delta object K is L.
The called object refers to a structural object of the incremental object called in the first database syntax tree. With reference to the examples of fig. 2-3, the called object of the delta object Z is C, the called object of the delta object L is K, and the called object of the delta object K is D.
The database coverage result comprises code information corresponding to the incremental object in the target database operation code file, code information corresponding to the calling object in the target database operation code file and code information corresponding to the called object in the target database operation code file.
The incremental object can be rapidly acquired by comparing the first database syntax tree with the second database syntax tree, and then the calling object and the called object can be rapidly identified in the first database syntax tree through the incremental object, so that the generation efficiency of the database covering structure is improved.
Specifically, the electronic device building a first database syntax tree based on the target database operation code file includes:
performing lexical analysis on the target database operation code file to obtain a plurality of structural objects and object relations of the structural objects;
identifying a structural object without a father node as a root node and identifying a structural object without a child node as a leaf node based on the object relation;
constructing an initial syntax tree according to the root node and the leaf nodes;
and filling the plurality of structural objects into the initial syntax tree based on the object relation to obtain the first database syntax tree.
And through the object relationship, the root node and the leaf node can be accurately identified, so that the construction accuracy of the initial syntax tree is improved, and further, the initial syntax tree is filled based on the object relationship, so that the construction accuracy of the first database syntax tree is improved.
In other embodiments, the second database syntax tree is constructed in a similar manner to the first database syntax tree, which is not described herein again.
And 106, performing full link display on the front-end coverage result, the back-end coverage result and the database coverage result.
It is emphasized that the front-end overlay result, the back-end overlay result, and the database overlay result may also be stored in a node of a block chain to further ensure privacy and security of the front-end overlay result, the back-end overlay result, and the database overlay result.
In at least one embodiment of the present invention, the performing, by the electronic device, a full-link display on the front-end coverage result, the back-end coverage result, and the database coverage result includes:
acquiring the page size of a visual page;
performing page division on the visual page based on the page size, the front end coverage result, the rear end coverage result and the database coverage result to obtain a front end display area, a rear end display area and a database display area;
displaying the front-end coverage result to the front-end display area based on the code amount and the code execution sequence of the front-end coverage result;
displaying the back-end coverage result to the back-end display area based on the code amount and the code execution sequence of the back-end coverage result;
and displaying the database coverage result to the database display area based on the code amount and the code execution sequence of the database coverage result.
The visualization page may be a display screen of the electronic device, and the page size refers to a length and a width of the visualization page.
By combining the page size, the front-end coverage result, the rear-end coverage result and the database coverage result, the page division is carried out on the visual page, the division rationality of a front-end display area, a rear-end display area and a database display area can be improved, and then the front-end coverage result, the rear-end coverage result and the full-link display of the database coverage result can be reasonably realized based on the corresponding code amount and the code execution sequence.
Specifically, the electronic device performs page division on the visualized page based on the page size, the front-end coverage result, the rear-end coverage result, and the database coverage result, and obtaining a front-end display area, a rear-end display area, and a database display area includes:
counting the total code amount of the front-end covering result, the rear-end covering result and the database covering result;
and dividing the visual page based on the ratio of the code quantity of the front-end coverage result to the total code quantity, the ratio of the code quantity of the rear-end coverage result to the total code quantity, the ratio of the code quantity of the database coverage result to the total code quantity and the page size to obtain the front-end display area, the rear-end display area and the database display area.
The front-end display area, the rear-end display area and the database display area can be reasonably divided by combining the corresponding code amount and the page size.
Specifically, the displaying, by the electronic device, the front-end coverage result to the front-end display area based on the code amount and the code execution order of the front-end coverage result includes:
if the code quantity of the front-end coverage result is larger than the configuration display quantity of the front-end display area, extracting a target coverage result from the front-end coverage result according to a sequence from first to last based on the code execution sequence, wherein the code quantity of the target coverage result is equal to the configuration display quantity;
and writing the target coverage result into the front-end display area, and calling a content display component to display the other front-end coverage results except the target coverage result in the front-end display area in a hidden manner.
In other embodiments, the way in which the back-end coverage result is displayed to the back-end display area and the way in which the database coverage result is displayed to the database display area are similar to the way in which the front-end coverage result is displayed to the front-end display area, and details thereof are not repeated herein.
According to the technical scheme, the initial front-end code file is identified based on the preset agent identification code, the target front-end code file, the target back-end code file and the target database operation code file of the same test request scene can be associated, so that codes of different operation environments in the same service scene can be obtained through the preset agent identification code, further, the target front-end code file, the target back-end code file and the target database operation code file are subjected to coverage test, and the target front-end code file, the target back-end code file and the target database operation code file do not comprise redundant interference codes, so that the accuracy of the coverage test of the test request scene can be improved, and meanwhile, the efficiency of the coverage test can be improved because the codes of different operation environments in the same service scene can be directly subjected to the coverage test. According to the method and the device, the front-end covering result, the rear-end covering result and the database covering result are subjected to full link display, so that the intuitiveness of the scene covering result of the request test scene is improved. This application is applicable to financial science and technology field, through this application, can improve the relevant staff in financial science and technology field to the code efficiency of test of different operational environment under the same business scene to promote the development in wisdom city.
FIG. 4 is a functional block diagram of a code coverage testing apparatus according to a preferred embodiment of the present invention. The code coverage testing device 11 includes an obtaining unit 110, an identifying unit 111, a positioning unit 112, a testing unit 113, a generating unit 114, and a displaying unit 115. The module/unit referred to herein is a series of computer readable instruction segments that can be accessed by the processor 13 and 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 code coverage testing device is applied to the field of financial science and technology.
An obtaining unit 110, configured to obtain an initial front-end code file of a test scenario;
an identifying unit 111, configured to identify the initial front-end code file based on a preset proxy identification code, to obtain a target front-end code file;
a positioning unit 112, configured to run the target front-end code file, and position a target back-end code file and a target database operation code file based on the preset proxy identification code, where the target database operation code file is a code file of a scene database;
the test unit 113 is configured to perform a coverage test on the target front-end code file to obtain a front-end coverage result, and perform a coverage test on the target back-end code file to obtain a back-end coverage result;
a generating unit 114, configured to generate a database coverage result based on the target database operation code file and the basic code file of the scene database;
and a display unit 115, configured to perform full link display on the front-end coverage result, the back-end coverage result, and the database coverage result.
In at least one embodiment of the present invention, the obtaining unit 110 is further configured to:
acquiring a request data packet;
extracting a scene identifier from the request data packet based on a preset scene field;
matching the scene identification with the scene identification code of the test-requested scene;
and if the scene identification is successfully matched with the scene identification code, determining the request data packet as the initial front-end code file.
In at least one embodiment of the present invention, the identifying unit 111 is further configured to:
identifying the initial front-end code file based on a preset agent identification code to obtain a target front-end code file, wherein the method comprises the following steps:
creating an agent field based on a preset agent identification code;
positioning a head code file corresponding to a preset head field from the initial front-end code file;
and writing the agent field and the preset agent identification code into the head code file to obtain a target front-end code file corresponding to the initial front-end code file.
In at least one embodiment of the present invention, the test unit 113 is further configured to:
performing coverage test on the target front-end code file, and obtaining a front-end coverage result comprises:
acquiring tool code information of a preset tool;
calling an off-line command and a timing command, and writing the tool code information into the target front-end code file to obtain an instrumentation front-end code file;
and operating the instrumentation front end code file to obtain the front end coverage result.
In at least one embodiment of the present invention, the test unit 113 is further configured to:
performing coverage test on the target back-end code file, and obtaining a back-end coverage result comprises:
identifying a Java virtual machine where the target back-end code file is located;
calling a monitoring code from the Java virtual machine, and loading the monitoring code into the target back-end code file to obtain an instrumented back-end code file;
and compiling, packaging and running the instrumentation post-end code file to obtain the post-end coverage result.
In at least one embodiment of the present invention, the generating unit 114 is further configured to:
constructing a first database syntax tree based on the target database operation code file, and constructing a second database syntax tree based on the basic code file;
comparing the first database syntax tree with the second database syntax tree to obtain an incremental object;
acquiring a calling object and a called object of the incremental object from the first database syntax tree;
and respectively acquiring information corresponding to the increment object, the calling object and the called object from the target database operation code file as the database coverage result.
In at least one embodiment of the present invention, the display unit 115 is further configured to:
acquiring the page size of a visual page;
performing page division on the visual page based on the page size, the front-end coverage result, the rear-end coverage result and the database coverage result to obtain a front-end display area, a rear-end display area and a database display area;
displaying the front-end coverage result to the front-end display area based on the code amount and the code execution sequence of the front-end coverage result;
displaying the back-end coverage result to the back-end display area based on the code amount and the code execution sequence of the back-end coverage result;
and displaying the database coverage result to the database display area based on the code amount and the code execution sequence of the database coverage result.
According to the technical scheme, the initial front-end code file is identified based on the preset agent identification code, the target front-end code file, the target back-end code file and the target database operation code file of the same test request scene can be associated, so that codes of different operation environments in the same service scene can be obtained through the preset agent identification code, further, the target front-end code file, the target back-end code file and the target database operation code file are subjected to coverage test, and the target front-end code file, the target back-end code file and the target database operation code file do not comprise redundant interference codes, so that the accuracy of the coverage test of the test request scene can be improved, and meanwhile, the efficiency of the coverage test can be improved because the codes of different operation environments in the same service scene can be directly subjected to the coverage test. According to the method and the device, the front-end covering result, the rear-end covering result and the database covering result are subjected to full link display, so that the intuitiveness of the scene covering result of the request test scene is improved. This application is applicable to financial science and technology field, through this application, can improve the relevant staff in financial science and technology field to the code efficiency of test of different operational environment under the same business scene to promote the development in wisdom city.
Fig. 5 is a schematic structural diagram of an electronic device implementing a code coverage testing method according to a preferred embodiment of the present invention.
In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer readable instructions, such as a code coverage test program, stored in the memory 12 and executable on the processor 13.
It will be appreciated by a person skilled in the art that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation of the electronic device 1, and that it may comprise more or less components than shown, or some components may be combined, or different components, e.g. the electronic device 1 may further comprise an input output device, a network access device, a bus, etc.
The Processor 13 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The processor 13 is an operation core and a control center of the electronic device 1, and is connected to each part of the whole electronic device 1 by various interfaces and lines, and executes an operating system of the electronic device 1 and various installed application programs, program codes, and the like.
Illustratively, the computer readable instructions may be partitioned into one or more modules/units, which are stored in the memory 12 and executed by the processor 13 to implement the present invention. The one or more modules/units may be a series of computer readable instruction segments capable of performing certain functions, which are used for describing the execution process of the computer readable instructions in the electronic device 1. For example, the computer readable instructions may be partitioned into an acquisition unit 110, an identification unit 111, a positioning unit 112, a testing unit 113, a generation unit 114, and a presentation unit 115.
The memory 12 may be used for storing the computer readable instructions and/or modules, and the processor 13 implements various functions of the electronic device 1 by executing or executing the computer readable instructions and/or modules stored in the memory 12 and invoking data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the electronic device, and the like. The memory 12 may include non-volatile and volatile memories, such as: a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the memory 12 may be a memory in a physical form, such as a memory stick, a TF Card (Trans-flash Card), and the like.
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 of the embodiments described above can be realized by the present invention, and the computer readable instructions can also be used for instructing the related hardware, and the computer readable instructions can be stored in a computer readable storage medium, and when the computer readable instructions are executed by a processor, the steps of the method embodiments described above can be realized.
Wherein the computer readable instructions comprise computer readable instruction code which may be in source code form, object code form, an executable file or some intermediate form, and the like. The computer-readable medium may include: any entity or device capable of carrying said computer readable instruction code, a recording medium, a U disk, a removable hard disk, a magnetic diskette, an optical disk, a computer Memory, a Read-Only Memory (ROM), a Random Access Memory (RAM).
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block includes information of a batch of network transactions for verifying the validity (anti-counterfeiting) of the information and generating a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
In conjunction with fig. 1, the memory 12 in the electronic device 1 stores computer-readable instructions to implement a code coverage testing method, and the processor 13 can execute the computer-readable instructions to implement:
acquiring an initial front-end code file of a test scene request;
identifying the initial front-end code file based on a preset agent identification code to obtain a target front-end code file;
running the target front-end code file, and positioning a target back-end code file and a target database operation code file based on the preset agent identification code, wherein the target database operation code file is a code file of a scene database;
performing a coverage test on the target front-end code file to obtain a front-end coverage result, and performing a coverage test on the target back-end code file to obtain a back-end coverage result;
generating a database coverage result based on the target database operation code file and the basic code file of the scene database;
and carrying out full link display on the front end coverage result, the rear end coverage result and the database coverage result.
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 computer readable instructions, which is not repeated herein.
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 computer readable storage medium has computer readable instructions stored thereon, wherein the computer readable instructions when executed by the processor 13 are configured to implement the steps of:
acquiring an initial front-end code file of a test scene request;
identifying the initial front-end code file based on a preset agent identification code to obtain a target front-end code file;
running the target front-end code file, and positioning a target back-end code file and a target database operation code file based on the preset agent identification code, wherein the target database operation code file is a code file of a scene database;
performing a coverage test on the target front-end code file to obtain a front-end coverage result, and performing a coverage test on the target back-end code file to obtain a back-end coverage result;
generating a database coverage result based on the target database operation code file and the basic code file of the scene database;
and carrying out full link display on the front end coverage result, the back end coverage result and the database coverage result.
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.
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. The plurality of units or devices may also be implemented by one unit or device through software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the same, 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 can be made to 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 code coverage test method, comprising:
acquiring an initial front-end code file of a test scene;
identifying the initial front-end code file based on a preset agent identification code to obtain a target front-end code file;
running the target front-end code file, and positioning a target back-end code file and a target database operation code file based on the preset agent identification code, wherein the target database operation code file refers to a code file of a scene database;
performing a coverage test on the target front-end code file to obtain a front-end coverage result, and performing a coverage test on the target back-end code file to obtain a back-end coverage result;
generating a database coverage result based on the target database operation code file and the basic code file of the scene database;
and carrying out full link display on the front end coverage result, the back end coverage result and the database coverage result.
2. The code coverage testing method of claim 1, wherein obtaining the initial front end code file of the requested test scenario comprises:
acquiring a request data packet;
extracting a scene identifier from the request data packet based on a preset scene field;
matching the scene identification with the scene identification code of the test-requested scene;
and if the scene identification is successfully matched with the scene identification code, determining the request data packet as the initial front-end code file.
3. The code coverage testing method of claim 1, wherein identifying the initial front-end code file based on a preset agent identification code to obtain a target front-end code file comprises:
creating an agent field based on a preset agent identification code;
positioning a head code file corresponding to a preset head field from the initial front-end code file;
and writing the agent field and the preset agent identification code into the head code file to obtain a target front-end code file corresponding to the initial front-end code file.
4. The code coverage test method of claim 1, wherein performing coverage test on the target front-end code file to obtain a front-end coverage result comprises:
acquiring tool code information of a preset tool;
calling an off-line command and a timing command, and writing the tool code information into the target front-end code file to obtain an instrumentation front-end code file;
and operating the instrumentation front end code file to obtain the front end coverage result.
5. The code coverage test method of claim 1, wherein performing coverage test on the target back-end code file to obtain a back-end coverage result comprises:
identifying a Java virtual machine where the target back-end code file is located;
calling a monitoring code from the Java virtual machine, and loading the monitoring code into the target back-end code file to obtain an instrumented back-end code file;
and compiling, packaging and running the instrumentation back-end code file to obtain the back-end coverage result.
6. The code coverage testing method of claim 1, wherein generating a database coverage result based on the target database operation code file and the base code file of the scenario database comprises:
constructing a first database syntax tree based on the target database operation code file, and constructing a second database syntax tree based on the basic code file;
comparing the first database syntax tree with the second database syntax tree to obtain an incremental object;
acquiring a calling object and a called object of the incremental object from the first database syntax tree;
and respectively acquiring information corresponding to the incremental object, the calling object and the called object from the target database operation code file as a database coverage result.
7. The code coverage test method of claim 1, wherein the performing full link exposure on the front-end coverage result, the back-end coverage result, and the database coverage result comprises:
acquiring the page size of a visual page;
performing page division on the visual page based on the page size, the front-end coverage result, the rear-end coverage result and the database coverage result to obtain a front-end display area, a rear-end display area and a database display area;
displaying the front-end coverage result to the front-end display area based on the code amount and the code execution sequence of the front-end coverage result;
displaying the back-end coverage result to the back-end display area based on the code amount and the code execution sequence of the back-end coverage result;
and displaying the database coverage result to the database display area based on the code amount and the code execution sequence of the database coverage result.
8. A code coverage testing apparatus, characterized in that the code coverage testing apparatus comprises:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring an initial front end code file of a test scene;
the identification unit is used for identifying the initial front-end code file based on a preset agent identification code to obtain a target front-end code file;
the positioning unit is used for operating the target front-end code file and positioning a target back-end code file and a target database operation code file based on the preset agent identification code, wherein the target database operation code file is a code file of a scene database;
the test unit is used for performing coverage test on the target front-end code file to obtain a front-end coverage result and performing coverage test on the target back-end code file to obtain a back-end coverage result;
a generating unit, configured to generate a database coverage result based on the target database operation code file and a basic code file of the scene database;
and the display unit is used for carrying out full-link display on the front-end coverage result, the rear-end coverage result and the database coverage result.
9. An electronic device, characterized in that the electronic device comprises:
a memory storing computer readable instructions; and
a processor executing computer readable instructions stored in the memory to implement the code coverage test method of any of claims 1 to 7.
10. A computer-readable storage medium characterized by: the computer-readable storage medium has stored therein computer-readable instructions that are executed by a processor in an electronic device to implement the code coverage testing method of any one of claims 1 to 7.
CN202211430994.1A 2022-11-15 2022-11-15 Code coverage test method, device, equipment and storage medium Pending CN115794621A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211430994.1A CN115794621A (en) 2022-11-15 2022-11-15 Code coverage test method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211430994.1A CN115794621A (en) 2022-11-15 2022-11-15 Code coverage test method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115794621A true CN115794621A (en) 2023-03-14

Family

ID=85437996

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211430994.1A Pending CN115794621A (en) 2022-11-15 2022-11-15 Code coverage test method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115794621A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116610383A (en) * 2023-05-25 2023-08-18 成都融见软件科技有限公司 Method for partially loading target file

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116610383A (en) * 2023-05-25 2023-08-18 成都融见软件科技有限公司 Method for partially loading target file
CN116610383B (en) * 2023-05-25 2024-02-20 成都融见软件科技有限公司 Method for partially loading target file

Similar Documents

Publication Publication Date Title
ES2291278T3 (en) APPLIANCE AND METHOD FOR CATALOGING SYMBOLIC DATA FOR USE IN COMPUTER PROGRAM OPERATION ANALYSIS.
US9588872B2 (en) Discovery of code paths
CN114035827A (en) Application program updating method, device, equipment and storage medium
CN110825731A (en) Data storage method and device, electronic equipment and storage medium
CN112732567A (en) Mock data testing method and device based on ip, electronic equipment and storage medium
CN115794621A (en) Code coverage test method, device, equipment and storage medium
CN114372060A (en) Data storage method, device, equipment and storage medium
CN114418398A (en) Scene task development method, device, equipment and storage medium
CN112947911A (en) Interface script generation method, device, equipment and storage medium
CN112527280A (en) Interface display method and device, server and readable storage medium
CN114398282A (en) Test script generation method, device, equipment and storage medium
CN115617410A (en) Drive interface identification method, device, equipment and storage medium
CN114489861A (en) Target component conversion method and device, electronic equipment and readable storage medium
CN114692204A (en) Data query method, device, equipment and storage medium
CN114116488A (en) Method, device and equipment for acquiring test coverage rate information and storage medium
CN114003784A (en) Request recording method, device, equipment and storage medium
CN113886263A (en) System testing method, device, equipment and storage medium
CN111859985A (en) AI customer service model testing method, device, electronic equipment and storage medium
CN113282218A (en) Multi-dimensional report generation method, device, equipment and storage medium
CN110327626B (en) Virtual server creation method and device
CN109388398B (en) Interface generation method and device in virtualization system
CN112632098A (en) Dynamic generation method of structured query statement and related equipment
CN112181485A (en) Script execution method and device, electronic equipment and storage medium
CN112416361A (en) Structured query language script examination method and related equipment
CN114741018B (en) Data visualization method, device, 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