Search

CN-121996531-A - Software code coverage rate testing method and terminal

CN121996531ACN 121996531 ACN121996531 ACN 121996531ACN-121996531-A

Abstract

The invention discloses a software code coverage rate testing method and a terminal, which are used for acquiring and recording real-time execution information of script codes of target software in an operating state during testing, obtaining an actual execution path according to the real-time execution information, carrying out static analysis on source codes of the script codes, obtaining all possible paths according to the result of the static analysis, and calculating the coverage rate of the script codes of the target software by combining the actual execution path and all the possible paths. According to the method, the execution conditions of the script codes of the target software are analyzed from the two running stages and the static stages, and then the coverage rate of the script codes of the target software is calculated by combining the actual execution path and all possible paths, so that the condition of new and old codes can be considered more comprehensively, the coverage rate of the script codes can be analyzed rapidly, whether potential problems exist or not can be analyzed conveniently, and the quality and reliability of the codes are ensured.

Inventors

  • LIU DEJIAN
  • You Youqi
  • HAN SHILUN
  • ZHU XIAOMIN
  • ZHENG LIJIE
  • ZHOU CHENG
  • ZOU LISHENG
  • WANG NAN
  • LIN CHEN

Assignees

  • 福建天晴数码有限公司

Dates

Publication Date
20260508
Application Date
20241104

Claims (10)

  1. 1. The software code coverage rate testing method is characterized by comprising the following steps of: s1, acquiring and recording real-time execution information of script codes of target software in an operating state during testing, and obtaining an actual execution path according to the real-time execution information; S2, carrying out static analysis on the source code of the script code, and obtaining all possible paths according to the result of the static analysis; S3, calculating the coverage rate of the script code of the target software by combining the actual execution path and all the possible paths.
  2. 2. The software code coverage rate testing method according to claim 1, wherein the script code comprises at least two key code blocks, and the key code blocks are in one-to-one correspondence with the functions of the target software; The step S3 further includes: acquiring a first actual path corresponding to one key code block from the actual execution paths, and acquiring a first possible path of the key code block corresponding to the first actual path from all possible paths; And calculating the coverage rate of the corresponding key code blocks according to the first actual path and the first possible path.
  3. 3. The software code coverage test method of claim 2, further comprising: S4, calculating and setting corresponding display modes for codes of each key code block according to the coverage rate of each key code block, wherein the display modes of the key code blocks with different coverage rates are different.
  4. 4. The software code coverage test method of claim 1, further comprising: and S5, monitoring whether the script code of the target software is changed, and if so, re-executing the steps S1 to S3 on the target software to generate a coverage rate change report corresponding to the target software.
  5. 5. The software code coverage test method according to claim 1, wherein the step S3 further comprises: comparing the actual execution path with all the possible paths, determining the codes which are not executed according to the comparison result, and setting the display mode of the codes which are not executed as a preset display mode.
  6. 6. A software code coverage test terminal comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the following steps when executing the computer program: s1, acquiring and recording real-time execution information of script codes of target software in an operating state during testing, and obtaining an actual execution path according to the real-time execution information; S2, carrying out static analysis on the source code of the script code, and obtaining all possible paths according to the result of the static analysis; S3, calculating the coverage rate of the script code of the target software by combining the actual execution path and all the possible paths.
  7. 7. The software code coverage rate test terminal according to claim 6, wherein the script code comprises at least two key code blocks, the key code blocks being in one-to-one correspondence with the functions of the target software; The step S3 further includes: acquiring a first actual path corresponding to one key code block from the actual execution paths, and acquiring a first possible path of the key code block corresponding to the first actual path from all possible paths; And calculating the coverage rate of the corresponding key code blocks according to the first actual path and the first possible path.
  8. 8. The software code coverage test terminal of claim 7, further comprising: S4, calculating and setting corresponding display modes for codes of each key code block according to the coverage rate of each key code block, wherein the display modes of the key code blocks with different coverage rates are different.
  9. 9. The software code coverage test terminal of claim 6, further comprising: and S5, monitoring whether the script code of the target software is changed, and if so, re-executing the steps S1 to S3 on the target software to generate a coverage rate change report corresponding to the target software.
  10. 10. The software code coverage test terminal of claim 6, wherein said step S3 further comprises: comparing the actual execution path with all the possible paths, determining the codes which are not executed according to the comparison result, and setting the display mode of the codes which are not executed as a preset display mode.

Description

Software code coverage rate testing method and terminal Technical Field The invention relates to the technical field of software development, in particular to a software code coverage rate testing method and a terminal. Background In the field of software development today, especially game development, the sufficiency of code quality and testing is of paramount importance. With the continuous development of the game industry, the complexity of the service end is increasing, and the need for efficient code testing tools is also increasing. Lightweight scripting languages, such as Lua, are widely used in game server development. Also, in the application process, in order to meet the version update requirement, the software needs to periodically add or change the content of the script code. After updating, the coverage rate of the script code needs to be tested to judge whether the new and old contents can normally run, whether potential loopholes and errors are not found, and the like. However, conventional testing methods often have difficulty covering all code paths, especially when testing for code changes, quickly determining which portions of the code need to be retested. Disclosure of Invention The invention aims to solve the technical problem of providing a software code coverage rate testing method and a terminal, which can rapidly and comprehensively analyze script code coverage rate and ensure code quality and reliability. In order to solve the technical problems, the invention adopts the following technical scheme: A software code coverage rate testing method comprises the following steps: s1, acquiring and recording real-time execution information of script codes of target software in an operating state during testing, and obtaining an actual execution path according to the real-time execution information; S2, carrying out static analysis on the source code of the script code, and obtaining all possible paths according to the result of the static analysis; S3, calculating the coverage rate of the script code of the target software by combining the actual execution path and all the possible paths. In order to solve the technical problems, the invention adopts another technical scheme that: a software code coverage test terminal comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program: s1, acquiring and recording real-time execution information of script codes of target software in an operating state during testing, and obtaining an actual execution path according to the real-time execution information; S2, carrying out static analysis on the source code of the script code, and obtaining all possible paths according to the result of the static analysis; S3, calculating the coverage rate of the script code of the target software by combining the actual execution path and all the possible paths. The method and the terminal for testing the coverage rate of the software code have the beneficial effects that the method and the terminal for testing the coverage rate of the software code are provided, the execution condition of the script code of the target software is analyzed from the two layers of an operation stage and a static state by combining operation information acquisition and static analysis technology, the coverage rate of the script code of the target software is calculated by combining an actual execution path and all possible paths, the condition of new and old codes can be considered more comprehensively, the coverage rate of the script code is analyzed rapidly, whether potential problems exist or not is analyzed conveniently, and the quality and the reliability of the code are ensured. Drawings FIG. 1 is a schematic diagram showing steps of a software code coverage rate testing method according to the present invention; FIG. 2 is a system block diagram of a software code coverage test terminal according to the present invention. Description of the reference numerals: 1. a software code coverage rate test terminal, 2, a memory, 3, a processor. Detailed Description In order to describe the technical contents, the achieved objects and effects of the present invention in detail, the following description will be made with reference to the embodiments in conjunction with the accompanying drawings. Referring to fig. 1, a software code coverage rate testing method includes the following steps: s1, acquiring and recording real-time execution information of script codes of target software in an operating state during testing, and obtaining an actual execution path according to the real-time execution information; S2, carrying out static analysis on the source code of the script code, and obtaining all possible paths according to the result of the static analysis; S3, calculating the coverage rate of the script code of the target software by combining the actual ex