Search

CN-122019382-A - Method, device, computer equipment, computer readable storage medium and computer program product for determining test cases

CN122019382ACN 122019382 ACN122019382 ACN 122019382ACN-122019382-A

Abstract

The present application relates to a method, an apparatus, a computer device, a computer-readable storage medium and a computer program product for determining a test case. The method comprises the steps of analyzing context log code data of a code changing block corresponding to a test object based on a static code analysis model and a function call relation tree corresponding to the test object, determining one or more groups of code execution logic data of the code changing block, determining a plurality of test cases corresponding to logic nodes in the code execution logic data based on a test case and a code association relation library aiming at each group of code execution logic data, determining hit times of each test case in the code execution logic data, determining hit probability values of the code execution logic data, selecting the hit probability values of each test case, and determining the test cases corresponding to the hit probability values meeting preset selected conditions as target test cases of the code execution logic. By adopting the method, the efficiency of accurately testing the codes can be improved.

Inventors

  • QIAN MINQIAN

Assignees

  • 展讯通信(上海)有限公司

Dates

Publication Date
20260512
Application Date
20260127

Claims (10)

  1. 1. A method for determining a test case, the method comprising: based on a static code analysis model and a function call relation tree corresponding to a test object, analyzing context log code data of a change code block corresponding to the test object, and determining one or more groups of code execution logic data of the change code block; Aiming at each group of code execution logic data, determining a plurality of test cases corresponding to each logic node in the code execution logic data based on a test case and code association relation library; determining the hit probability value of each test case selected by the code execution logic data based on the hit times of each test case in the code execution logic data; And determining the test case corresponding to the hit probability value meeting the preset selection condition as the target test case of the code execution logic.
  2. 2. The method according to claim 1, wherein the method further comprises: Analyzing a source code file based on the static code analysis model, determining the position data of each function, determining the calling relation between each function, and generating the function calling relation tree based on the position data and the calling relation.
  3. 3. The method according to claim 2, wherein the method further comprises: analyzing the dynamic log file generated by executing the source code file by each test case based on a log file analysis model to determine dynamic log data; extracting the characteristics of the dynamic log data based on a characteristic generation model to obtain dynamic log characteristics corresponding to each test case; determining sample code execution logic data of each test case based on each dynamic log feature, a static log feature library and the function call relation tree; And determining the corresponding relation between a plurality of test cases and the sample code execution logic data corresponding to each test case as the test case and code association relation library.
  4. 4. The method of claim 3, wherein the dynamic log features include location features and dynamic log content features of logical nodes in the execution logic code executed by the test cases, wherein the determining code execution logic data for each test case based on the dynamic log features, static log feature library and function call relationship tree comprises: Responding to the dynamic log feature not including the position feature, matching the dynamic log content feature with each static log content feature in the static log feature library based on a preset matching algorithm to obtain a first matching result, determining a target static log content feature corresponding to the first matching result meeting a first preset matching condition, and determining the position feature corresponding to the target static log content feature as the position feature corresponding to the dynamic log feature; And determining code execution logic data of each test case based on the function call relation tree, each dynamic log content feature and the position feature corresponding to the dynamic log feature in response to each dynamic log feature of the test case not meeting an execution logic condition.
  5. 5. The method of claim 4, wherein the analyzing the context log code data of the change code block corresponding to the test object based on the static code parsing model and the function call relation tree corresponding to the test object to determine the one or more sets of code execution logic data of the change code block comprises: Determining static log code data of a code logic of the same level of a change code block corresponding to a test object, analyzing the static log code data based on the static code analysis model, and determining a first static log characteristic; determining a plurality of groups of calling functions and called functions corresponding to the changed code blocks based on the first static log features and the function call relation tree; Analyzing the static log code data of the calling function and the called function based on the static code analysis model, determining a second static log characteristic corresponding to the static log code data of the calling function and the called function, and determining a group of code execution logic data of the change code block based on the second static log characteristic data.
  6. 6. The method of claim 5, wherein determining a plurality of test cases corresponding to each logical node in the code execution logical data based on the test case and code association library comprises: And aiming at each logic node in the code execution logic data, calculating a second matching result of the logic node and each sample logic node in the test case and code association relation library based on a preset matching algorithm, and determining the second matching result as the test case corresponding to the logic node, wherein the test case corresponds to the sample logic node which meets the second preset matching condition.
  7. 7. A device for determining a test case, the device comprising: the first determining module is used for analyzing the context log code data of the change code block corresponding to the test object based on the static code analysis model and the function call relation tree corresponding to the test object, and determining one or more groups of code execution logic data of the change code block; the second determining module is used for determining a plurality of test cases corresponding to each logic node in the code execution logic data based on the test case and code association relation library aiming at each group of code execution logic data; And the test module is used for determining the test case corresponding to the hit probability value meeting the preset selection condition as the target test case of the code execution logic.
  8. 8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
  9. 9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
  10. 10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.

Description

Method, device, computer equipment, computer readable storage medium and computer program product for determining test cases Technical Field The present application relates to the field of computer technology, and in particular, to a method, an apparatus, a computer device, a readable storage medium, and a program product for determining a test case. Background Along with the continuous evolution process of software development, the software code volume under the scenes of communication service, android system and the like is larger and larger, the program complexity is higher and higher, and the test case library is larger and larger, and the cost of test and case maintenance is higher and higher. In order to improve the test efficiency, the whole test process is more efficient, accurate and reliable, and the accurate test technology is generated. The accurate test refers to obtaining a final test case list according to a code change range and an association relation between a test case and a code (the association relation is generally established through a function and a context of function call), so that the code test range can be accurately positioned. In the related technology, the accurate test method generally comprises the steps of adding one test case each time, running the test case by means of code instrumentation, obtaining code dynamic execution logic, obtaining code static call logic by static compiling and analyzing source codes, finally obtaining code dynamic execution logic with higher matching degree according to the change range submitted by the codes and analyzing by combining the code static call logic, and further obtaining corresponding test cases, however, the code instrumentation needs to additionally insert additional code fragments into the source codes, instrumentation is generally carried out at the positions of an in-function and an out-function, and the accuracy of testing the changed codes is lower for functions with higher ring complexity. Disclosure of Invention In view of the foregoing, it is desirable to provide a method, an apparatus, a computer device, a computer-readable storage medium, and a computer program product for determining test cases that can improve the efficiency of performing accurate testing on codes. In a first aspect, the present application provides a method for determining a test case, including: based on a static code analysis model and a function call relation tree corresponding to a test object, analyzing context log code data of a change code block corresponding to the test object, and determining one or more groups of code execution logic data of the change code block; Aiming at each group of code execution logic data, determining a plurality of test cases corresponding to each logic node in the code execution logic data based on a test case and code association relation library; determining the hit probability value of each test case selected by the code execution logic data based on the hit times of each test case in the code execution logic data; And determining the test case corresponding to the hit probability value meeting the preset selection condition as the target test case of the code execution logic. In one embodiment, the method further comprises: Analyzing a source code file based on the static code analysis model, determining the position data of each function, determining the calling relation between each function, and generating the function calling relation tree based on the position data and the calling relation. In one embodiment, the method further comprises: analyzing the dynamic log file generated by executing the source code file by each test case based on a log file analysis model to determine dynamic log data; extracting the characteristics of the dynamic log data based on a characteristic generation model to obtain dynamic log characteristics corresponding to each test case; determining sample code execution logic data of each test case based on each dynamic log feature, a static log feature library and the function call relation tree; And determining the corresponding relation between a plurality of test cases and the sample code execution logic data corresponding to each test case as the test case and code association relation library. In one embodiment, the dynamic log feature includes a location feature and a dynamic log content feature of each logical node in an execution logic code executed by the test case, and the determining code execution logic data of each test case based on each dynamic log feature, a static log feature library and the function call relation tree includes: Responding to the dynamic log feature not including the position feature, matching the dynamic log content feature with each static log content feature in the static log feature library based on a preset matching algorithm to obtain a first matching result, determining a target static log content feature corresponding to the first matching